Skip to content

Commit a688e74

Browse files
committed
vendor: github.com/moby/moby/api, github.com/moby/moby/client master
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d9c95c9 commit a688e74

File tree

9 files changed

+182
-145
lines changed

9 files changed

+182
-145
lines changed

cli/command/cli.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,14 @@ func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigF
323323
if len(configFile.HTTPHeaders) > 0 {
324324
opts = append(opts, client.WithHTTPHeaders(configFile.HTTPHeaders))
325325
}
326-
opts = append(opts, withCustomHeadersFromEnv(), client.WithUserAgent(UserAgent()))
326+
withCustomHeaders, err := withCustomHeadersFromEnv()
327+
if err != nil {
328+
return nil, err
329+
}
330+
if withCustomHeaders != nil {
331+
opts = append(opts, withCustomHeaders)
332+
}
333+
opts = append(opts, client.WithUserAgent(UserAgent()))
327334
return client.NewClientWithOpts(opts...)
328335
}
329336

cli/command/cli_options.go

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -180,61 +180,59 @@ const envOverrideHTTPHeaders = "DOCKER_CUSTOM_HEADERS"
180180
// override headers with the same name).
181181
//
182182
// TODO(thaJeztah): this is a client Option, and should be moved to the client. It is non-exported for that reason.
183-
func withCustomHeadersFromEnv() client.Opt {
184-
return func(apiClient *client.Client) error {
185-
value := os.Getenv(envOverrideHTTPHeaders)
186-
if value == "" {
187-
return nil
188-
}
189-
csvReader := csv.NewReader(strings.NewReader(value))
190-
fields, err := csvReader.Read()
191-
if err != nil {
192-
return invalidParameter(fmt.Errorf(
193-
"failed to parse custom headers from %s environment variable: value must be formatted as comma-separated key=value pairs",
194-
envOverrideHTTPHeaders,
195-
))
196-
}
197-
if len(fields) == 0 {
198-
return nil
199-
}
200-
201-
env := map[string]string{}
202-
for _, kv := range fields {
203-
k, v, hasValue := strings.Cut(kv, "=")
204-
205-
// Only strip whitespace in keys; preserve whitespace in values.
206-
k = strings.TrimSpace(k)
183+
func withCustomHeadersFromEnv() (client.Opt, error) {
184+
value := os.Getenv(envOverrideHTTPHeaders)
185+
if value == "" {
186+
return nil, nil
187+
}
188+
csvReader := csv.NewReader(strings.NewReader(value))
189+
fields, err := csvReader.Read()
190+
if err != nil {
191+
return nil, invalidParameter(fmt.Errorf(
192+
"failed to parse custom headers from %s environment variable: value must be formatted as comma-separated key=value pairs",
193+
envOverrideHTTPHeaders,
194+
))
195+
}
196+
if len(fields) == 0 {
197+
return nil, nil
198+
}
207199

208-
if k == "" {
209-
return invalidParameter(fmt.Errorf(
210-
`failed to set custom headers from %s environment variable: value contains a key=value pair with an empty key: '%s'`,
211-
envOverrideHTTPHeaders, kv,
212-
))
213-
}
200+
env := map[string]string{}
201+
for _, kv := range fields {
202+
k, v, hasValue := strings.Cut(kv, "=")
214203

215-
// We don't currently allow empty key=value pairs, and produce an error.
216-
// This is something we could allow in future (e.g. to read value
217-
// from an environment variable with the same name). In the meantime,
218-
// produce an error to prevent users from depending on this.
219-
if !hasValue {
220-
return invalidParameter(fmt.Errorf(
221-
`failed to set custom headers from %s environment variable: missing "=" in key=value pair: '%s'`,
222-
envOverrideHTTPHeaders, kv,
223-
))
224-
}
204+
// Only strip whitespace in keys; preserve whitespace in values.
205+
k = strings.TrimSpace(k)
225206

226-
env[http.CanonicalHeaderKey(k)] = v
207+
if k == "" {
208+
return nil, invalidParameter(fmt.Errorf(
209+
`failed to set custom headers from %s environment variable: value contains a key=value pair with an empty key: '%s'`,
210+
envOverrideHTTPHeaders, kv,
211+
))
227212
}
228213

229-
if len(env) == 0 {
230-
// We should probably not hit this case, as we don't skip values
231-
// (only return errors), but we don't want to discard existing
232-
// headers with an empty set.
233-
return nil
214+
// We don't currently allow empty key=value pairs, and produce an error.
215+
// This is something we could allow in future (e.g. to read value
216+
// from an environment variable with the same name). In the meantime,
217+
// produce an error to prevent users from depending on this.
218+
if !hasValue {
219+
return nil, invalidParameter(fmt.Errorf(
220+
`failed to set custom headers from %s environment variable: missing "=" in key=value pair: '%s'`,
221+
envOverrideHTTPHeaders, kv,
222+
))
234223
}
235224

236-
// TODO(thaJeztah): add a client.WithExtraHTTPHeaders() function to allow these headers to be _added_ to existing ones, instead of _replacing_
237-
// see https://github.com/docker/cli/pull/5098#issuecomment-2147403871 (when updating, also update the WARNING in the function and env-var GoDoc)
238-
return client.WithHTTPHeaders(env)(apiClient)
225+
env[http.CanonicalHeaderKey(k)] = v
226+
}
227+
228+
if len(env) == 0 {
229+
// We should probably not hit this case, as we don't skip values
230+
// (only return errors), but we don't want to discard existing
231+
// headers with an empty set.
232+
return nil, nil
239233
}
234+
235+
// TODO(thaJeztah): add a client.WithExtraHTTPHeaders() function to allow these headers to be _added_ to existing ones, instead of _replacing_
236+
// see https://github.com/docker/cli/pull/5098#issuecomment-2147403871 (when updating, also update the WARNING in the function and env-var GoDoc)
237+
return client.WithHTTPHeaders(env), nil
240238
}

vendor.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ require (
2828
github.com/google/uuid v1.6.0
2929
github.com/mattn/go-runewidth v0.0.16
3030
github.com/moby/go-archive v0.1.0
31-
github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554 // master
32-
github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554 // master
31+
github.com/moby/moby/api v1.52.0-alpha.1.0.20250903201806-ac2d8305875f // master
32+
github.com/moby/moby/client v0.1.0-alpha.0.0.20250903201806-ac2d8305875f // master
3333
github.com/moby/patternmatcher v0.6.0
3434
github.com/moby/swarmkit/v2 v2.0.0
3535
github.com/moby/sys/atomicwriter v0.1.0

vendor.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N
170170
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
171171
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
172172
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
173-
github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554 h1:N6U77C4Lro2uqDeBGP4Zz3UIHjaQst8E45P9vOeUY7E=
174-
github.com/moby/moby/api v1.52.0-alpha.1.0.20250827142737-8ac1bfa6c554/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok=
175-
github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554 h1:8Vd0p/2rVqjnyQxUbcaox9uVhbgxr9axxfSWdpq1KXc=
176-
github.com/moby/moby/client v0.1.0-alpha.0.0.20250827142737-8ac1bfa6c554/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w=
173+
github.com/moby/moby/api v1.52.0-alpha.1.0.20250903201806-ac2d8305875f h1:71Oc0lQRDNXdxRr1X2dVuixga1t9qardUwPHvJEqfs0=
174+
github.com/moby/moby/api v1.52.0-alpha.1.0.20250903201806-ac2d8305875f/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok=
175+
github.com/moby/moby/client v0.1.0-alpha.0.0.20250903201806-ac2d8305875f h1:9dfCP11zd/H53MaQ0X2QBGxxSyan1llEs2vk4vlJGxU=
176+
github.com/moby/moby/client v0.1.0-alpha.0.0.20250903201806-ac2d8305875f/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w=
177177
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
178178
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
179179
github.com/moby/swarmkit/v2 v2.0.0 h1:jkWQKQaJ4ltA61/mC9UdPe1McLma55RUcacTO+pPweY=

vendor/github.com/moby/moby/api/types/container/network_settings.go

Lines changed: 41 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/registry/registry.go

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/client/client.go

Lines changed: 22 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)