mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/t/network: represent MAC addrs as byte slices
Make invalid states unrepresentable by moving away from stringly-typed MAC address values in API structs. As go.dev/issue/29678 has not yet been implemented, provide our own HardwareAddr byte-slice type which implements TextMarshaler and TextUnmarshaler to retain compatibility with the API wire format. When stdlib's net.HardwareAddr type implements TextMarshaler and TextUnmarshaler and GODEBUG=netmarshal becomes the default, we should be able to make the type a straight alias for stdlib net.HardwareAddr as a non-breaking change. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/docker/go-units"
|
||||
"github.com/moby/moby/api/pkg/stdcopy"
|
||||
containertypes "github.com/moby/moby/api/types/container"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/moby/moby/v2/integration/internal/container"
|
||||
net "github.com/moby/moby/v2/integration/internal/network"
|
||||
@@ -295,7 +296,7 @@ func TestMacAddressIsAppliedToMainNetworkWithShortID(t *testing.T) {
|
||||
|
||||
c := container.Inspect(ctx, t, apiClient, cid)
|
||||
assert.Assert(t, c.NetworkSettings.Networks["testnet"] != nil)
|
||||
assert.Equal(t, c.NetworkSettings.Networks["testnet"].MacAddress, "02:42:08:26:a9:55")
|
||||
assert.DeepEqual(t, c.NetworkSettings.Networks["testnet"].MacAddress, networktypes.HardwareAddr{0x02, 0x42, 0x08, 0x26, 0xa9, 0x55})
|
||||
}
|
||||
|
||||
func TestStaticIPOutsideSubpool(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user