From 973331be8b7bc85c34edc0be905b6a548a2b04de Mon Sep 17 00:00:00 2001 From: Albin Kerouanton Date: Mon, 20 Nov 2023 10:21:46 +0100 Subject: [PATCH] Add a network-scoped mac_address field Related to: - https://github.com/moby/moby/pull/45905 - https://github.com/compose-spec/compose-spec/pull/435 Signed-off-by: Albin Kerouanton --- loader/full-example.yml | 1 + loader/full-struct_test.go | 4 +++- schema/compose-spec.json | 6 +++++- types/types.go | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/loader/full-example.yml b/loader/full-example.yml index 99f7f3086..a021235e5 100644 --- a/loader/full-example.yml +++ b/loader/full-example.yml @@ -235,6 +235,7 @@ services: other-network: ipv4_address: 172.16.238.10 ipv6_address: 2001:3984:3989::10 + mac_address: 02:42:72:98:65:08 other-other-network: pid: "host" diff --git a/loader/full-struct_test.go b/loader/full-struct_test.go index e035a101c..641be7282 100644 --- a/loader/full-struct_test.go +++ b/loader/full-struct_test.go @@ -775,6 +775,7 @@ services: other-network: ipv4_address: 172.16.238.10 ipv6_address: 2001:3984:3989::10 + mac_address: 02:42:72:98:65:08 other-other-network: null some-network: aliases: @@ -1392,7 +1393,8 @@ func fullExampleJSON(workingDir, homeDir string) string { "networks": { "other-network": { "ipv4_address": "172.16.238.10", - "ipv6_address": "2001:3984:3989::10" + "ipv6_address": "2001:3984:3989::10", + "mac_address": "02:42:72:98:65:08" }, "other-other-network": null, "some-network": { diff --git a/schema/compose-spec.json b/schema/compose-spec.json index 81dacbcf2..73026ea62 100644 --- a/schema/compose-spec.json +++ b/schema/compose-spec.json @@ -273,7 +273,10 @@ "additionalProperties": false, "patternProperties": {"^x-": {}} }, - "mac_address": {"type": "string"}, + "mac_address": { + "type": "string", + "deprecated": true + }, "mem_limit": {"type": ["number", "string"]}, "mem_reservation": {"type": ["string", "integer"]}, "mem_swappiness": {"type": "integer"}, @@ -294,6 +297,7 @@ "ipv4_address": {"type": "string"}, "ipv6_address": {"type": "string"}, "link_local_ips": {"$ref": "#/definitions/list_of_strings"}, + "mac_address": {"type": "string"}, "priority": {"type": "number"} }, "additionalProperties": false, diff --git a/types/types.go b/types/types.go index 88846699e..b75556e65 100644 --- a/types/types.go +++ b/types/types.go @@ -97,7 +97,7 @@ type ServiceConfig struct { MemReservation UnitBytes `yaml:"mem_reservation,omitempty" json:"mem_reservation,omitempty"` MemSwapLimit UnitBytes `yaml:"memswap_limit,omitempty" json:"memswap_limit,omitempty"` MemSwappiness UnitBytes `yaml:"mem_swappiness,omitempty" json:"mem_swappiness,omitempty"` - MacAddress string `yaml:"mac_address,omitempty" json:"mac_address,omitempty"` + MacAddress string `yaml:"mac_address,omitempty" json:"mac_address,omitempty"` // Deprecated: [ServiceNetworkConfig.MacAddress] should be used instead Net string `yaml:"net,omitempty" json:"net,omitempty"` NetworkMode string `yaml:"network_mode,omitempty" json:"network_mode,omitempty"` Networks map[string]*ServiceNetworkConfig `yaml:"networks,omitempty" json:"networks,omitempty"` @@ -419,6 +419,7 @@ type ServiceNetworkConfig struct { Ipv4Address string `yaml:"ipv4_address,omitempty" json:"ipv4_address,omitempty"` Ipv6Address string `yaml:"ipv6_address,omitempty" json:"ipv6_address,omitempty"` LinkLocalIPs []string `yaml:"link_local_ips,omitempty" json:"link_local_ips,omitempty"` + MacAddress string `yaml:"mac_address,omitempty" json:"mac_address,omitempty"` Extensions Extensions `yaml:"#extensions,inline" json:"-"` }