mirror of https://github.com/docker/cli.git
vendor: github.com/docker/docker c14694a424ab (v25.0.0-dev)
full diff: ed1a61dcb7...c14694a424
Co-authored-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
5ec9eec63d
commit
d46de7087c
|
@ -715,7 +715,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
|
|||
// Put the endpoint-specific MacAddress of the "main" network attachment into the container Config for backward
|
||||
// compatibility with older daemons.
|
||||
if nw, ok := networkingConfig.EndpointsConfig[hostConfig.NetworkMode.NetworkName()]; ok {
|
||||
config.MacAddress = nw.MacAddress
|
||||
config.MacAddress = nw.MacAddress //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||
}
|
||||
|
||||
return &containerConfig{
|
||||
|
|
|
@ -290,8 +290,9 @@ func TestParseWithMacAddress(t *testing.T) {
|
|||
if _, _, _, err := parseRun([]string{invalidMacAddress, "img", "cmd"}); err != nil && err.Error() != "invalidMacAddress is not a valid mac address" {
|
||||
t.Fatalf("Expected an error with %v mac-address, got %v", invalidMacAddress, err)
|
||||
}
|
||||
if config, _ := mustParse(t, validMacAddress); config.MacAddress != "92:d0:c6:0a:29:33" {
|
||||
t.Fatalf("Expected the config to have '92:d0:c6:0a:29:33' as MacAddress, got '%v'", config.MacAddress)
|
||||
if config, _ := mustParse(t, validMacAddress); config.MacAddress != "92:d0:c6:0a:29:33" { //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||
t.Fatalf("Expected the config to have '92:d0:c6:0a:29:33' as container-wide MacAddress, got '%v'",
|
||||
config.MacAddress) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,7 +688,7 @@ func TestParseNetworkConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, config.MacAddress, tc.expectedCfg.MacAddress)
|
||||
assert.DeepEqual(t, config.MacAddress, tc.expectedCfg.MacAddress) //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||
assert.DeepEqual(t, hConfig.NetworkMode, tc.expectedHostCfg.NetworkMode)
|
||||
assert.DeepEqual(t, nwConfig.EndpointsConfig, tc.expected)
|
||||
})
|
||||
|
|
|
@ -12,7 +12,7 @@ require (
|
|||
github.com/creack/pty v1.1.18
|
||||
github.com/distribution/reference v0.5.0
|
||||
github.com/docker/distribution v2.8.3+incompatible
|
||||
github.com/docker/docker v24.0.0-rc.2.0.20231103125139-ed1a61dcb789+incompatible // master (v25.0.0-dev)
|
||||
github.com/docker/docker v24.0.0-rc.2.0.20231107154431-c14694a424ab+incompatible // master (v25.0.0-dev)
|
||||
github.com/docker/docker-credential-helpers v0.8.0
|
||||
github.com/docker/go-connections v0.4.0
|
||||
github.com/docker/go-units v0.5.0
|
||||
|
|
|
@ -54,8 +54,8 @@ github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5
|
|||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||
github.com/docker/docker v24.0.0-rc.2.0.20231103125139-ed1a61dcb789+incompatible h1:aTS2OQ5LXIzi/Cb7WD6TJUvDglK5PV+9bCbd65FZMLs=
|
||||
github.com/docker/docker v24.0.0-rc.2.0.20231103125139-ed1a61dcb789+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v24.0.0-rc.2.0.20231107154431-c14694a424ab+incompatible h1:XqNjq0C7Clz84YBid4PyA1fR7//uawYK/WDLLmNhOCY=
|
||||
github.com/docker/docker v24.0.0-rc.2.0.20231107154431-c14694a424ab+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker-credential-helpers v0.8.0 h1:YQFtbBQb4VrpoPxhFuzEBPQ9E16qz5SpHLS+uswaCp8=
|
||||
github.com/docker/docker-credential-helpers v0.8.0/go.mod h1:UGFXcuoQ5TxPiB54nHOZ32AWRqQdECoh/Mg0AlEYb40=
|
||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||
|
|
|
@ -1313,7 +1313,10 @@ definitions:
|
|||
type: "boolean"
|
||||
x-nullable: true
|
||||
MacAddress:
|
||||
description: "MAC address of the container."
|
||||
description: |
|
||||
MAC address of the container.
|
||||
|
||||
Deprecated: this field is deprecated in API v1.44 and up. Use EndpointSettings.MacAddress instead.
|
||||
type: "string"
|
||||
x-nullable: true
|
||||
OnBuild:
|
||||
|
@ -1381,6 +1384,7 @@ definitions:
|
|||
LinkLocalIPs:
|
||||
- "169.254.34.68"
|
||||
- "fe80::3468"
|
||||
MacAddress: "02:42:ac:12:05:02"
|
||||
Links:
|
||||
- "container_1"
|
||||
- "container_2"
|
||||
|
@ -2455,6 +2459,11 @@ definitions:
|
|||
example:
|
||||
- "container_1"
|
||||
- "container_2"
|
||||
MacAddress:
|
||||
description: |
|
||||
MAC address for the endpoint on this network. The network driver might ignore this parameter.
|
||||
type: "string"
|
||||
example: "02:42:ac:11:00:04"
|
||||
Aliases:
|
||||
type: "array"
|
||||
items:
|
||||
|
@ -2505,11 +2514,6 @@ definitions:
|
|||
type: "integer"
|
||||
format: "int64"
|
||||
example: 64
|
||||
MacAddress:
|
||||
description: |
|
||||
MAC address for the endpoint on this network.
|
||||
type: "string"
|
||||
example: "02:42:ac:11:00:04"
|
||||
DriverOpts:
|
||||
description: |
|
||||
DriverOpts is a mapping of driver options and values. These options
|
||||
|
@ -10130,6 +10134,7 @@ paths:
|
|||
IPAMConfig:
|
||||
IPv4Address: "172.24.56.89"
|
||||
IPv6Address: "2001:db8::5689"
|
||||
MacAddress: "02:42:ac:12:05:02"
|
||||
tags: ["Network"]
|
||||
|
||||
/networks/{id}/disconnect:
|
||||
|
|
|
@ -70,10 +70,13 @@ type Config struct {
|
|||
WorkingDir string // Current directory (PWD) in the command will be launched
|
||||
Entrypoint strslice.StrSlice // Entrypoint to run when starting the container
|
||||
NetworkDisabled bool `json:",omitempty"` // Is network disabled
|
||||
MacAddress string `json:",omitempty"` // Mac Address of the container
|
||||
OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile
|
||||
Labels map[string]string // List of labels set to this container
|
||||
StopSignal string `json:",omitempty"` // Signal to stop a container
|
||||
StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
|
||||
Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
|
||||
// Mac Address of the container.
|
||||
//
|
||||
// Deprecated: this field is deprecated since API v1.44. Use EndpointSettings.MacAddress instead.
|
||||
MacAddress string `json:",omitempty"`
|
||||
OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile
|
||||
Labels map[string]string // List of labels set to this container
|
||||
StopSignal string `json:",omitempty"` // Signal to stop a container
|
||||
StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
|
||||
Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ type EndpointSettings struct {
|
|||
IPAMConfig *EndpointIPAMConfig
|
||||
Links []string
|
||||
Aliases []string
|
||||
MacAddress string
|
||||
// Operational data
|
||||
NetworkID string
|
||||
EndpointID string
|
||||
|
@ -23,7 +24,6 @@ type EndpointSettings struct {
|
|||
IPv6Gateway string
|
||||
GlobalIPv6Address string
|
||||
GlobalIPv6PrefixLen int
|
||||
MacAddress string
|
||||
DriverOpts map[string]string
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
|
|||
if err := cli.NewVersionError(ctx, "1.44", "specify health-check start interval"); config != nil && config.Healthcheck != nil && config.Healthcheck.StartInterval != 0 && err != nil {
|
||||
return response, err
|
||||
}
|
||||
if err := cli.NewVersionError(ctx, "1.44", "specify mac-address per network"); hasEndpointSpecificMacAddress(networkingConfig) && err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
if hostConfig != nil {
|
||||
if versions.LessThan(cli.ClientVersion(), "1.25") {
|
||||
|
@ -55,6 +58,11 @@ func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config
|
|||
}
|
||||
}
|
||||
|
||||
// Since API 1.44, the container-wide MacAddress is deprecated and will trigger a WARNING if it's specified.
|
||||
if versions.GreaterThanOrEqualTo(cli.ClientVersion(), "1.44") {
|
||||
config.MacAddress = "" //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.44.
|
||||
}
|
||||
|
||||
query := url.Values{}
|
||||
if p := formatPlatform(platform); p != "" {
|
||||
query.Set("platform", p)
|
||||
|
@ -91,3 +99,16 @@ func formatPlatform(platform *ocispec.Platform) string {
|
|||
}
|
||||
return path.Join(platform.OS, platform.Architecture, platform.Variant)
|
||||
}
|
||||
|
||||
// hasEndpointSpecificMacAddress checks whether one of the endpoint in networkingConfig has a MacAddress defined.
|
||||
func hasEndpointSpecificMacAddress(networkingConfig *network.NetworkingConfig) bool {
|
||||
if networkingConfig == nil {
|
||||
return false
|
||||
}
|
||||
for _, endpoint := range networkingConfig.EndpointsConfig {
|
||||
if endpoint.MacAddress != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ github.com/docker/distribution/registry/client/transport
|
|||
github.com/docker/distribution/registry/storage/cache
|
||||
github.com/docker/distribution/registry/storage/cache/memory
|
||||
github.com/docker/distribution/uuid
|
||||
# github.com/docker/docker v24.0.0-rc.2.0.20231103125139-ed1a61dcb789+incompatible
|
||||
# github.com/docker/docker v24.0.0-rc.2.0.20231107154431-c14694a424ab+incompatible
|
||||
## explicit
|
||||
github.com/docker/docker/api
|
||||
github.com/docker/docker/api/types
|
||||
|
|
Loading…
Reference in New Issue