From 0b0843233b4e16fd6045fae2e05d1452c053df67 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 3 Apr 2026 14:51:20 +0200 Subject: [PATCH] vendor: github.com/docker/cli v29.4.0 full diff: https://github.com/docker/cli/compare/v29.3.1...v29.4.0 Signed-off-by: Sebastiaan van Stijn --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/docker/cli/AUTHORS | 17 +++- .../github.com/docker/cli/cli/command/cli.go | 2 +- .../docker/cli/cli/command/context.go | 2 +- .../cli/cli/command/defaultcontextstore.go | 2 +- .../cli/cli/command/formatter/container.go | 33 +++++--- .../cli/cli/command/formatter/custom.go | 2 +- .../cli/cli/command/formatter/disk_usage.go | 3 - .../cli/cli/command/formatter/displayutils.go | 2 +- .../cli/cli/command/formatter/formatter.go | 78 ++++++++++--------- .../cli/cli/command/formatter/reflect.go | 4 +- .../cli/cli/command/telemetry_docker.go | 2 +- .../docker/cli/cli/command/utils.go | 2 +- .../docker/cli/cli/config/configfile/file.go | 2 +- .../cli/cli/config/credentials/file_store.go | 11 ++- .../cli/cli/config/memorystore/store.go | 2 +- .../docker/cli/cli/connhelper/connhelper.go | 2 +- .../cli/cli/context/store/metadatastore.go | 2 +- .../docker/cli/cli/context/store/store.go | 2 +- .../cli/cli/context/store/storeconfig.go | 2 +- .../github.com/docker/cli/cli/streams/in.go | 75 +++++++++++------- .../github.com/docker/cli/cli/streams/out.go | 65 ++++++++++------ .../docker/cli/cli/streams/stream.go | 76 ++++++++++++++---- .../docker/cli/internal/tui/chip.go | 2 +- .../docker/cli/internal/tui/colors.go | 2 +- .../docker/cli/internal/tui/count.go | 2 +- .../docker/cli/internal/tui/note.go | 2 +- .../docker/cli/internal/tui/output.go | 2 +- .../github.com/docker/cli/internal/tui/str.go | 2 +- vendor/github.com/docker/cli/opts/opts.go | 2 +- .../docker/cli/templates/templates.go | 2 +- vendor/modules.txt | 2 +- 33 files changed, 264 insertions(+), 148 deletions(-) diff --git a/go.mod b/go.mod index 5b84fa5d3..0347e1ab3 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/creack/pty v1.1.24 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/distribution/reference v0.6.0 - github.com/docker/cli v29.3.1+incompatible + github.com/docker/cli v29.4.0+incompatible github.com/docker/cli-docs-tool v0.11.0 github.com/docker/docker v28.5.2+incompatible github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 655c3bc5f..a66b821d6 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docker/cli v29.3.1+incompatible h1:M04FDj2TRehDacrosh7Vlkgc7AuQoWloQkf1PA5hmoI= -github.com/docker/cli v29.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v29.4.0+incompatible h1:+IjXULMetlvWJiuSI0Nbor36lcJ5BTcVpUmB21KBoVM= +github.com/docker/cli v29.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli-docs-tool v0.11.0 h1:7d8QARFb7QEobizqxmEM7fOteZEHwH/zWgHQtHZEcfE= github.com/docker/cli-docs-tool v0.11.0/go.mod h1:ma8BKiisUo8D6W05XEYIh3oa1UbgrZhi1nowyKFJa8Q= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= diff --git a/vendor/github.com/docker/cli/AUTHORS b/vendor/github.com/docker/cli/AUTHORS index 57af08b20..accbf6c52 100644 --- a/vendor/github.com/docker/cli/AUTHORS +++ b/vendor/github.com/docker/cli/AUTHORS @@ -2,6 +2,7 @@ # This file lists all contributors to the repository. # See scripts/docs/generate-authors.sh to make modifications. +4RH1T3CT0R7 A. Lester Buck III Aanand Prasad Aaron L. Xu @@ -42,6 +43,7 @@ Alexander Larsson Alexander Morozov Alexander Ryabov Alexandre González +Alexandre Vallières-Lagacé Alexey Igrychev Alexis Couvreur Alfred Landrum @@ -64,6 +66,7 @@ Andres G. Aragoneses Andres Leon Rangel Andrew France Andrew He +Andrew Hopp Andrew Hsu Andrew Macpherson Andrew McDonnell @@ -127,6 +130,7 @@ Brian Goff Brian Tracy Brian Wieder Bruno Sousa +Bruno Verachten Bryan Bess Bryan Boreham Bryan Murphy @@ -178,6 +182,7 @@ Christopher Svensson Christy Norman Chun Chen Clinton Kitson +Codex Coenraad Loubser Colin Hebert Collin Guarino @@ -234,6 +239,7 @@ David Sheets David Williamson David Xia David Young +Davlat Davydov Deng Guangxing Denis Defreyne Denis Gladkikh @@ -241,6 +247,7 @@ Denis Ollier Dennis Docter dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Derek McGowan +Derek Misler Des Preston Deshi Xiao Dharmit Shah @@ -260,6 +267,7 @@ Dominik Braun Don Kjer Dong Chen DongGeon Lee +Dorin Geman Doug Davis Drew Erny Ed Costello @@ -358,7 +366,7 @@ Hugo Gabriel Eyherabide huqun Huu Nguyen Hyzhou Zhy -Iain MacDonald +Iain MacDonald Iain Samuel McLean Elder Ian Campbell Ian Philpot @@ -471,6 +479,7 @@ Justyn Temme Jyrki Puttonen Jérémie Drouet Jérôme Petazzoni +Jörg Sommer Jörg Thalheim Kai Blin Kai Qiang Wu (Kennan) @@ -539,10 +548,12 @@ Lovekesh Kumar Luca Favatella Luca Marturana Lucas Chan +Ludovic Temgoua Abanda Luis Henrique Mulinari Luka Hartwig Lukas Heeren Lukasz Zajaczkowski +Luo Jiyin Lydell Manganti Lénaïc Huard Ma Shimiao @@ -603,6 +614,7 @@ Michael Spetsiotis Michael Steinert Michael Tews Michael West +Michael Zampani Michal Minář Michał Czeraszkiewicz Miguel Angel Alvarez Cabrerizo @@ -617,6 +629,7 @@ Mike Goelzer Mike MacCana mikelinjie <294893458@qq.com> Mikhail Vasin +Milas Bowman Milind Chawre Mindaugas Rukas Miroslav Gula @@ -887,6 +900,7 @@ Vincent Batts Vincent Bernat Vincent Demeester Vincent Woo +Vineet Kumar Vishnu Kannan Vivek Goyal Wang Jie @@ -916,6 +930,7 @@ Yanqiang Miao Yassine Tijani Yi EungJun Ying Li +Yoan Wainmann Yong Tang Yosef Fertel Yu Peng diff --git a/vendor/github.com/docker/cli/cli/command/cli.go b/vendor/github.com/docker/cli/cli/command/cli.go index 42d01b956..d2805f253 100644 --- a/vendor/github.com/docker/cli/cli/command/cli.go +++ b/vendor/github.com/docker/cli/cli/command/cli.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package command diff --git a/vendor/github.com/docker/cli/cli/command/context.go b/vendor/github.com/docker/cli/cli/command/context.go index b926b303a..b876e225e 100644 --- a/vendor/github.com/docker/cli/cli/command/context.go +++ b/vendor/github.com/docker/cli/cli/command/context.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package command diff --git a/vendor/github.com/docker/cli/cli/command/defaultcontextstore.go b/vendor/github.com/docker/cli/cli/command/defaultcontextstore.go index e6315b8e8..54ca58d2d 100644 --- a/vendor/github.com/docker/cli/cli/command/defaultcontextstore.go +++ b/vendor/github.com/docker/cli/cli/command/defaultcontextstore.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package command diff --git a/vendor/github.com/docker/cli/cli/command/formatter/container.go b/vendor/github.com/docker/cli/cli/command/formatter/container.go index fafa6a56e..e17313a6d 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/container.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/container.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package formatter @@ -141,25 +141,36 @@ func (c *ContainerContext) ID() string { // Names returns a comma-separated string of the container's names, with their // slash (/) prefix stripped. Additional names for the container (related to the -// legacy `--link` feature) are omitted. +// legacy `--link` feature) are omitted when formatting "truncated". func (c *ContainerContext) Names() string { - names := StripNamePrefix(c.c.Names) - if c.trunc { - for _, name := range names { - if len(strings.Split(name, "/")) == 1 { - names = []string{name} - break + var b strings.Builder + for i, n := range c.c.Names { + name := strings.TrimPrefix(n, "/") + if c.trunc { + // When printing truncated, we only print a single name. + // + // Pick the first name that's not a legacy link (does not have + // slashes inside the name itself (e.g., "/other-container/link")). + // Normally this would be the first name found. + if strings.IndexByte(name, '/') == -1 { + return name } + continue } + if i > 0 { + b.WriteByte(',') + } + b.WriteString(name) } - return strings.Join(names, ",") + return b.String() } -// StripNamePrefix removes prefix from string, typically container names as returned by `ContainersList` API +// StripNamePrefix removes any "/" prefix from container names returned +// by the "ContainersList" API. func StripNamePrefix(ss []string) []string { sss := make([]string, len(ss)) for i, s := range ss { - sss[i] = s[1:] + sss[i] = strings.TrimPrefix(s, "/") } return sss } diff --git a/vendor/github.com/docker/cli/cli/command/formatter/custom.go b/vendor/github.com/docker/cli/cli/command/formatter/custom.go index 27931af76..b845e191f 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/custom.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/custom.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package formatter diff --git a/vendor/github.com/docker/cli/cli/command/formatter/disk_usage.go b/vendor/github.com/docker/cli/cli/command/formatter/disk_usage.go index b14afc1a0..63b155857 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/disk_usage.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/disk_usage.go @@ -46,7 +46,6 @@ func (ctx *DiskUsageContext) startSubsection(format Format) (*template.Template, ctx.buffer = &bytes.Buffer{} ctx.header = "" ctx.Format = format - ctx.preFormat() return ctx.parseFormat() } @@ -88,7 +87,6 @@ func (ctx *DiskUsageContext) Write() (err error) { return ctx.verboseWrite() } ctx.buffer = &bytes.Buffer{} - ctx.preFormat() tmpl, err := ctx.parseFormat() if err != nil { @@ -213,7 +211,6 @@ func (ctx *DiskUsageContext) verboseWrite() error { return ctx.verboseWriteTable(duc) } - ctx.preFormat() tmpl, err := ctx.parseFormat() if err != nil { return err diff --git a/vendor/github.com/docker/cli/cli/command/formatter/displayutils.go b/vendor/github.com/docker/cli/cli/command/formatter/displayutils.go index 7b0bd687f..ef008006f 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/displayutils.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/displayutils.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package formatter diff --git a/vendor/github.com/docker/cli/cli/command/formatter/formatter.go b/vendor/github.com/docker/cli/cli/command/formatter/formatter.go index 88905cd1b..01c7867f3 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/formatter.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/formatter.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package formatter @@ -33,7 +33,7 @@ func (f Format) IsTable() bool { return strings.HasPrefix(string(f), TableFormatKey) } -// IsJSON returns true if the format is the json format +// IsJSON returns true if the format is the JSON format func (f Format) IsJSON() bool { return string(f) == JSONFormatKey } @@ -43,6 +43,31 @@ func (f Format) Contains(sub string) bool { return strings.Contains(string(f), sub) } +// templateString pre-processes the format and returns it as a string +// for templating. +func (f Format) templateString() string { + out := string(f) + switch out { + case TableFormatKey: + // A bare "--format table" should already be handled before we + // hit this; a literal "table" here means a custom "table" format + // without template. + return "" + case JSONFormatKey: + // "--format json" only; not JSON formats ("--format '{{json .Field}}'"). + return JSONFormat + } + + // "--format 'table {{.Field}}\t{{.Field}}'" -> "{{.Field}}\t{{.Field}}" + if after, isTable := strings.CutPrefix(out, TableFormatKey); isTable { + out = after + } + + out = strings.Trim(out, " ") // trim spaces, but preserve other whitespace. + out = strings.NewReplacer(`\t`, "\t", `\n`, "\n").Replace(out) + return out +} + // Context contains information required by the formatter to print the output as desired. type Context struct { // Output is the output stream to which the formatted string is written. @@ -53,28 +78,12 @@ type Context struct { Trunc bool // internal element - finalFormat string - header any - buffer *bytes.Buffer -} - -func (c *Context) preFormat() { - c.finalFormat = string(c.Format) - // TODO: handle this in the Format type - switch { - case c.Format.IsTable(): - c.finalFormat = c.finalFormat[len(TableFormatKey):] - case c.Format.IsJSON(): - c.finalFormat = JSONFormat - } - - c.finalFormat = strings.Trim(c.finalFormat, " ") - r := strings.NewReplacer(`\t`, "\t", `\n`, "\n") - c.finalFormat = r.Replace(c.finalFormat) + header any + buffer *bytes.Buffer } func (c *Context) parseFormat() (*template.Template, error) { - tmpl, err := templates.Parse(c.finalFormat) + tmpl, err := templates.Parse(c.Format.templateString()) if err != nil { return nil, fmt.Errorf("template parsing error: %w", err) } @@ -82,20 +91,21 @@ func (c *Context) parseFormat() (*template.Template, error) { } func (c *Context) postFormat(tmpl *template.Template, subContext SubContext) { - if c.Output == nil { - c.Output = io.Discard + out := c.Output + if out == nil { + out = io.Discard } - if c.Format.IsTable() { - t := tabwriter.NewWriter(c.Output, 10, 1, 3, ' ', 0) - buffer := bytes.NewBufferString("") - tmpl.Funcs(templates.HeaderFunctions).Execute(buffer, subContext.FullHeader()) - buffer.WriteTo(t) - t.Write([]byte("\n")) - c.buffer.WriteTo(t) - t.Flush() - } else { - c.buffer.WriteTo(c.Output) + if !c.Format.IsTable() { + _, _ = c.buffer.WriteTo(out) + return } + + // Write column-headers and rows to the tab-writer buffer, then flush the output. + tw := tabwriter.NewWriter(out, 10, 1, 3, ' ', 0) + _ = tmpl.Funcs(templates.HeaderFunctions).Execute(tw, subContext.FullHeader()) + _, _ = tw.Write([]byte{'\n'}) + _, _ = c.buffer.WriteTo(tw) + _ = tw.Flush() } func (c *Context) contextFormat(tmpl *template.Template, subContext SubContext) error { @@ -115,8 +125,6 @@ type SubFormat func(func(SubContext) error) error // Write the template to the buffer using this Context func (c *Context) Write(sub SubContext, f SubFormat) error { c.buffer = &bytes.Buffer{} - c.preFormat() - tmpl, err := c.parseFormat() if err != nil { return err diff --git a/vendor/github.com/docker/cli/cli/command/formatter/reflect.go b/vendor/github.com/docker/cli/cli/command/formatter/reflect.go index 89da07b8a..150c01805 100644 --- a/vendor/github.com/docker/cli/cli/command/formatter/reflect.go +++ b/vendor/github.com/docker/cli/cli/command/formatter/reflect.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package formatter @@ -24,7 +24,7 @@ func MarshalJSON(x any) ([]byte, error) { // marshalMap marshals x to map[string]any func marshalMap(x any) (map[string]any, error) { val := reflect.ValueOf(x) - if val.Kind() != reflect.Ptr { + if val.Kind() != reflect.Pointer { return nil, fmt.Errorf("expected a pointer to a struct, got %v", val.Kind()) } if val.IsNil() { diff --git a/vendor/github.com/docker/cli/cli/command/telemetry_docker.go b/vendor/github.com/docker/cli/cli/command/telemetry_docker.go index f0a43a425..0cd37b3a1 100644 --- a/vendor/github.com/docker/cli/cli/command/telemetry_docker.go +++ b/vendor/github.com/docker/cli/cli/command/telemetry_docker.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package command diff --git a/vendor/github.com/docker/cli/cli/command/utils.go b/vendor/github.com/docker/cli/cli/command/utils.go index dcbeed2f7..bf7638f37 100644 --- a/vendor/github.com/docker/cli/cli/command/utils.go +++ b/vendor/github.com/docker/cli/cli/command/utils.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package command diff --git a/vendor/github.com/docker/cli/cli/config/configfile/file.go b/vendor/github.com/docker/cli/cli/config/configfile/file.go index 246f23e98..1a0e5b46c 100644 --- a/vendor/github.com/docker/cli/cli/config/configfile/file.go +++ b/vendor/github.com/docker/cli/cli/config/configfile/file.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package configfile diff --git a/vendor/github.com/docker/cli/cli/config/credentials/file_store.go b/vendor/github.com/docker/cli/cli/config/credentials/file_store.go index c69312b01..e3ef8e25e 100644 --- a/vendor/github.com/docker/cli/cli/config/credentials/file_store.go +++ b/vendor/github.com/docker/cli/cli/config/credentials/file_store.go @@ -99,9 +99,14 @@ func (c *fileStore) Store(authConfig types.AuthConfig) error { return nil } -// ConvertToHostname converts a registry url which has http|https prepended -// to just an hostname. -// Copied from github.com/docker/docker/registry.ConvertToHostname to reduce dependencies. +// ConvertToHostname normalizes a registry URL which has http|https prepended +// to just its hostname. It is used to match credentials, which may be either +// stored as hostname or as hostname including scheme (in legacy configuration +// files). +// +// It's the equivalent to [registry.ConvertToHostname] in the daemon. +// +// [registry.ConvertToHostname]: https://pkg.go.dev/github.com/moby/moby/v2@v2.0.0-beta.7/daemon/pkg/registry#ConvertToHostname func ConvertToHostname(maybeURL string) string { stripped := maybeURL if strings.Contains(stripped, "://") { diff --git a/vendor/github.com/docker/cli/cli/config/memorystore/store.go b/vendor/github.com/docker/cli/cli/config/memorystore/store.go index f8ec62b95..44523d392 100644 --- a/vendor/github.com/docker/cli/cli/config/memorystore/store.go +++ b/vendor/github.com/docker/cli/cli/config/memorystore/store.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package memorystore diff --git a/vendor/github.com/docker/cli/cli/connhelper/connhelper.go b/vendor/github.com/docker/cli/cli/connhelper/connhelper.go index 38e9a2d72..8d97a2a40 100644 --- a/vendor/github.com/docker/cli/cli/connhelper/connhelper.go +++ b/vendor/github.com/docker/cli/cli/connhelper/connhelper.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 // Package connhelper provides helpers for connecting to a remote daemon host with custom logic. package connhelper diff --git a/vendor/github.com/docker/cli/cli/context/store/metadatastore.go b/vendor/github.com/docker/cli/cli/context/store/metadatastore.go index ecef656d8..8703e1c6c 100644 --- a/vendor/github.com/docker/cli/cli/context/store/metadatastore.go +++ b/vendor/github.com/docker/cli/cli/context/store/metadatastore.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package store diff --git a/vendor/github.com/docker/cli/cli/context/store/store.go b/vendor/github.com/docker/cli/cli/context/store/store.go index f73b710c5..2b8b5c311 100644 --- a/vendor/github.com/docker/cli/cli/context/store/store.go +++ b/vendor/github.com/docker/cli/cli/context/store/store.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package store diff --git a/vendor/github.com/docker/cli/cli/context/store/storeconfig.go b/vendor/github.com/docker/cli/cli/context/store/storeconfig.go index 1b7f33106..4b42e7377 100644 --- a/vendor/github.com/docker/cli/cli/context/store/storeconfig.go +++ b/vendor/github.com/docker/cli/cli/context/store/storeconfig.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package store diff --git a/vendor/github.com/docker/cli/cli/streams/in.go b/vendor/github.com/docker/cli/cli/streams/in.go index 1a10f7c83..45c10ab79 100644 --- a/vendor/github.com/docker/cli/cli/streams/in.go +++ b/vendor/github.com/docker/cli/cli/streams/in.go @@ -4,7 +4,6 @@ import ( "errors" "io" "os" - "runtime" "github.com/moby/term" ) @@ -12,8 +11,29 @@ import ( // In is an input stream to read user input. It implements [io.ReadCloser] // with additional utilities, such as putting the terminal in raw mode. type In struct { - commonStream in io.ReadCloser + cs commonStream +} + +// NewIn returns a new [In] from an [io.ReadCloser]. If in is an [*os.File], +// a reference is kept to the file, and accessible through [In.File]. +func NewIn(in io.ReadCloser) *In { + return &In{ + in: in, + cs: newCommonStream(in), + } +} + +// FD returns the file descriptor number for this stream. +func (i *In) FD() uintptr { + return i.cs.fd +} + +// File returns the underlying *os.File if the stream was constructed from one. +// If the stream was created from a non-file (e.g., a pipe, buffer, or wrapper), +// the returned boolean will be false. +func (i *In) File() (*os.File, bool) { + return i.cs.file() } // Read implements the [io.Reader] interface. @@ -26,36 +46,37 @@ func (i *In) Close() error { return i.in.Close() } +// IsTerminal returns whether this stream is connected to a terminal. +func (i *In) IsTerminal() bool { + return i.cs.isTerminal() +} + // SetRawTerminal sets raw mode on the input terminal. It is a no-op if In // is not a TTY, or if the "NORAW" environment variable is set to a non-empty // value. -func (i *In) SetRawTerminal() (err error) { - if !i.isTerminal || os.Getenv("NORAW") != "" { +func (i *In) SetRawTerminal() error { + return i.cs.setRawTerminal(term.SetRawTerminal) +} + +// RestoreTerminal restores the terminal state if SetRawTerminal succeeded earlier. +func (i *In) RestoreTerminal() { + i.cs.restoreTerminal() +} + +// CheckTty reports an error when stdin is requested for a TTY-enabled +// container, but the client stdin is not itself a terminal (for example, +// when input is piped or redirected). +func (i *In) CheckTty(attachStdin, ttyMode bool) error { + // TODO(thaJeztah): consider inlining this code and deprecating the method. + if !ttyMode || !attachStdin || i.cs.isTerminal() { return nil } - i.state, err = term.SetRawTerminal(i.fd) - return err + return errors.New("cannot attach stdin to a TTY-enabled container because stdin is not a terminal") } -// CheckTty checks if we are trying to attach to a container TTY -// from a non-TTY client input stream, and if so, returns an error. -func (i *In) CheckTty(attachStdin, ttyMode bool) error { - // In order to attach to a container tty, input stream for the client must - // be a tty itself: redirecting or piping the client standard input is - // incompatible with `docker run -t`, `docker exec -t` or `docker attach`. - if ttyMode && attachStdin && !i.isTerminal { - const eText = "the input device is not a TTY" - if runtime.GOOS == "windows" { - return errors.New(eText + ". If you are using mintty, try prefixing the command with 'winpty'") - } - return errors.New(eText) - } - return nil -} - -// NewIn returns a new [In] from an [io.ReadCloser]. -func NewIn(in io.ReadCloser) *In { - i := &In{in: in} - i.fd, i.isTerminal = term.GetFdInfo(in) - return i +// SetIsTerminal overrides whether a terminal is connected. It is used to +// override this property in unit-tests, and should not be depended on for +// other purposes. +func (i *In) SetIsTerminal(isTerminal bool) { + i.cs.setIsTerminal(isTerminal) } diff --git a/vendor/github.com/docker/cli/cli/streams/out.go b/vendor/github.com/docker/cli/cli/streams/out.go index 2383b0857..85d69d3a8 100644 --- a/vendor/github.com/docker/cli/cli/streams/out.go +++ b/vendor/github.com/docker/cli/cli/streams/out.go @@ -5,54 +5,71 @@ import ( "os" "github.com/moby/term" - "github.com/sirupsen/logrus" ) // Out is an output stream to write normal program output. It implements // an [io.Writer], with additional utilities for detecting whether a terminal // is connected, getting the TTY size, and putting the terminal in raw mode. type Out struct { - commonStream out io.Writer + cs commonStream } +// NewOut returns a new [Out] from an [io.Writer]. If out is an [*os.File], +// a reference is kept to the file, and accessible through [Out.File]. +func NewOut(out io.Writer) *Out { + return &Out{ + out: out, + cs: newCommonStream(out), + } +} + +// FD returns the file descriptor number for this stream. +func (o *Out) FD() uintptr { + return o.cs.FD() +} + +// File returns the underlying *os.File if the stream was constructed from one. +// If the stream was created from a non-file (e.g., a pipe, buffer, or wrapper), +// the returned boolean will be false. +func (o *Out) File() (*os.File, bool) { + return o.cs.file() +} + +// Write writes to the output stream. func (o *Out) Write(p []byte) (int, error) { return o.out.Write(p) } +// IsTerminal returns whether this stream is connected to a terminal. +func (o *Out) IsTerminal() bool { + return o.cs.isTerminal() +} + // SetRawTerminal puts the output of the terminal connected to the stream // into raw mode. // // On UNIX, this does nothing. On Windows, it disables LF -> CRLF/ translation. // It is a no-op if Out is not a TTY, or if the "NORAW" environment variable is // set to a non-empty value. -func (o *Out) SetRawTerminal() (err error) { - if !o.isTerminal || os.Getenv("NORAW") != "" { - return nil - } - o.state, err = term.SetRawTerminalOutput(o.fd) - return err +func (o *Out) SetRawTerminal() error { + return o.cs.setRawTerminal(term.SetRawTerminalOutput) +} + +// RestoreTerminal restores the terminal state if SetRawTerminal succeeded earlier. +func (o *Out) RestoreTerminal() { + o.cs.restoreTerminal() } // GetTtySize returns the height and width in characters of the TTY, or // zero for both if no TTY is connected. func (o *Out) GetTtySize() (height uint, width uint) { - if !o.isTerminal { - return 0, 0 - } - ws, err := term.GetWinsize(o.fd) - if err != nil { - logrus.WithError(err).Debug("Error getting TTY size") - if ws == nil { - return 0, 0 - } - } - return uint(ws.Height), uint(ws.Width) + return o.cs.terminalSize() } -// NewOut returns a new [Out] from an [io.Writer]. -func NewOut(out io.Writer) *Out { - o := &Out{out: out} - o.fd, o.isTerminal = term.GetFdInfo(out) - return o +// SetIsTerminal overrides whether a terminal is connected. It is used to +// override this property in unit-tests, and should not be depended on for +// other purposes. +func (o *Out) SetIsTerminal(isTerminal bool) { + o.cs.setIsTerminal(isTerminal) } diff --git a/vendor/github.com/docker/cli/cli/streams/stream.go b/vendor/github.com/docker/cli/cli/streams/stream.go index 54c9cda0b..f6356ccf3 100644 --- a/vendor/github.com/docker/cli/cli/streams/stream.go +++ b/vendor/github.com/docker/cli/cli/streams/stream.go @@ -1,35 +1,77 @@ +// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: +//go:build go1.25 + package streams import ( + "os" + "github.com/moby/term" + "github.com/sirupsen/logrus" ) +func newCommonStream(stream any) commonStream { + var f *os.File + if v, ok := stream.(*os.File); ok { + f = v + } + + fd, tty := term.GetFdInfo(stream) + return commonStream{ + f: f, + fd: fd, + tty: tty, + } +} + type commonStream struct { - fd uintptr - isTerminal bool - state *term.State + f *os.File + fd uintptr + tty bool + state *term.State } // FD returns the file descriptor number for this stream. -func (s *commonStream) FD() uintptr { - return s.fd -} +func (s *commonStream) FD() uintptr { return s.fd } -// IsTerminal returns true if this stream is connected to a terminal. -func (s *commonStream) IsTerminal() bool { - return s.isTerminal -} +// file returns the underlying *os.File if the stream was constructed from one. +func (s *commonStream) file() (*os.File, bool) { return s.f, s.f != nil } -// RestoreTerminal restores normal mode to the terminal. -func (s *commonStream) RestoreTerminal() { +// isTerminal returns whether this stream is connected to a terminal. +func (s *commonStream) isTerminal() bool { return s.tty } + +// setIsTerminal overrides whether a terminal is connected for testing. +func (s *commonStream) setIsTerminal(isTerminal bool) { s.tty = isTerminal } + +// restoreTerminal restores the terminal state if SetRawTerminal succeeded earlier. +func (s *commonStream) restoreTerminal() { if s.state != nil { _ = term.RestoreTerminal(s.fd, s.state) } } -// SetIsTerminal overrides whether a terminal is connected. It is used to -// override this property in unit-tests, and should not be depended on for -// other purposes. -func (s *commonStream) SetIsTerminal(isTerminal bool) { - s.isTerminal = isTerminal +func (s *commonStream) setRawTerminal(setter func(uintptr) (*term.State, error)) error { + if !s.tty || os.Getenv("NORAW") != "" { + return nil + } + state, err := setter(s.fd) + if err != nil { + return err + } + s.state = state + return nil +} + +func (s *commonStream) terminalSize() (height uint, width uint) { + if !s.tty { + return 0, 0 + } + ws, err := term.GetWinsize(s.fd) + if err != nil { + logrus.WithError(err).Debug("Error getting TTY size") + if ws == nil { + return 0, 0 + } + } + return uint(ws.Height), uint(ws.Width) } diff --git a/vendor/github.com/docker/cli/internal/tui/chip.go b/vendor/github.com/docker/cli/internal/tui/chip.go index c48158e75..477d43103 100644 --- a/vendor/github.com/docker/cli/internal/tui/chip.go +++ b/vendor/github.com/docker/cli/internal/tui/chip.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package tui diff --git a/vendor/github.com/docker/cli/internal/tui/colors.go b/vendor/github.com/docker/cli/internal/tui/colors.go index 6f1d8e6b7..854e55ecd 100644 --- a/vendor/github.com/docker/cli/internal/tui/colors.go +++ b/vendor/github.com/docker/cli/internal/tui/colors.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package tui diff --git a/vendor/github.com/docker/cli/internal/tui/count.go b/vendor/github.com/docker/cli/internal/tui/count.go index a626b24f8..303d650e5 100644 --- a/vendor/github.com/docker/cli/internal/tui/count.go +++ b/vendor/github.com/docker/cli/internal/tui/count.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package tui diff --git a/vendor/github.com/docker/cli/internal/tui/note.go b/vendor/github.com/docker/cli/internal/tui/note.go index 759d8d0e2..83f1f621e 100644 --- a/vendor/github.com/docker/cli/internal/tui/note.go +++ b/vendor/github.com/docker/cli/internal/tui/note.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package tui diff --git a/vendor/github.com/docker/cli/internal/tui/output.go b/vendor/github.com/docker/cli/internal/tui/output.go index 34bc13a3a..1776640af 100644 --- a/vendor/github.com/docker/cli/internal/tui/output.go +++ b/vendor/github.com/docker/cli/internal/tui/output.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package tui diff --git a/vendor/github.com/docker/cli/internal/tui/str.go b/vendor/github.com/docker/cli/internal/tui/str.go index 82fc59f1c..9d50f7bd3 100644 --- a/vendor/github.com/docker/cli/internal/tui/str.go +++ b/vendor/github.com/docker/cli/internal/tui/str.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package tui diff --git a/vendor/github.com/docker/cli/opts/opts.go b/vendor/github.com/docker/cli/opts/opts.go index 142740bf7..2e0adac6e 100644 --- a/vendor/github.com/docker/cli/opts/opts.go +++ b/vendor/github.com/docker/cli/opts/opts.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package opts diff --git a/vendor/github.com/docker/cli/templates/templates.go b/vendor/github.com/docker/cli/templates/templates.go index 1145e82c8..e156ca575 100644 --- a/vendor/github.com/docker/cli/templates/templates.go +++ b/vendor/github.com/docker/cli/templates/templates.go @@ -1,5 +1,5 @@ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16: -//go:build go1.24 +//go:build go1.25 package templates diff --git a/vendor/modules.txt b/vendor/modules.txt index 778a4f698..3607c7a4e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -296,7 +296,7 @@ github.com/digitorus/timestamp # github.com/distribution/reference v0.6.0 ## explicit; go 1.20 github.com/distribution/reference -# github.com/docker/cli v29.3.1+incompatible +# github.com/docker/cli v29.4.0+incompatible ## explicit github.com/docker/cli/cli github.com/docker/cli/cli-plugins/metadata