From 1b4fcb8da7581ba4eafb76c25f48998a357b75cb Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Tue, 26 Aug 2025 16:20:35 -0500 Subject: [PATCH] api/types/network: move `CreateOptions` type to client module Signed-off-by: Austin Vazquez --- api/types/network/network.go | 15 ++--- client/client_interfaces.go | 2 +- client/network_create.go | 17 ++++- client/network_create_opts.go | 19 ++++++ client/network_create_test.go | 6 +- .../cluster/executor/container/container.go | 30 ++++----- daemon/cluster/executor/container/executor.go | 14 ++-- integration-cli/docker_api_network_test.go | 34 ++++------ integration-cli/docker_api_swarm_test.go | 3 +- integration/container/rename_test.go | 3 +- integration/internal/network/network.go | 15 ++--- integration/internal/network/ops.go | 63 +++++++++--------- .../network/bridge/bridge_linux_test.go | 4 +- .../iptablesdoc/iptablesdoc_linux_test.go | 3 +- .../nftablesdoc/nftablesdoc_linux_test.go | 4 +- integration/network/ipvlan/ipvlan_test.go | 4 +- integration/network/macvlan/macvlan_test.go | 4 +- integration/network/network_linux_test.go | 6 +- integration/networking/bridge_linux_test.go | 66 +++++++++---------- .../networking/port_mapping_linux_test.go | 6 +- .../moby/moby/api/types/network/network.go | 15 ++--- .../moby/moby/client/client_interfaces.go | 2 +- .../moby/moby/client/network_create.go | 17 ++++- .../moby/moby/client/network_create_opts.go | 19 ++++++ 24 files changed, 204 insertions(+), 167 deletions(-) create mode 100644 client/network_create_opts.go create mode 100644 vendor/github.com/moby/moby/client/network_create_opts.go diff --git a/api/types/network/network.go b/api/types/network/network.go index e8325110b4..7e2f59f387 100644 --- a/api/types/network/network.go +++ b/api/types/network/network.go @@ -21,16 +21,7 @@ const ( // CreateRequest is the request message sent to the server for network create call. type CreateRequest struct { - CreateOptions - Name string // Name is the requested name of the network. - - // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client - // package to older daemons. - CheckDuplicate *bool `json:",omitempty"` -} - -// CreateOptions holds options to create a network. -type CreateOptions struct { + Name string // Name is the requested name of the network. Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`) Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level). EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4. @@ -43,6 +34,10 @@ type CreateOptions struct { ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly]. Options map[string]string // Options specifies the network-specific options to use for when creating the network. Labels map[string]string // Labels holds metadata specific to the network being created. + + // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client + // package to older daemons. + CheckDuplicate *bool `json:",omitempty"` } // Inspect is the body of the "get network" http response message. diff --git a/client/client_interfaces.go b/client/client_interfaces.go index 1b597a12c6..f5df3ac28a 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -129,7 +129,7 @@ type ImageAPIClient interface { // NetworkAPIClient defines API client methods for the networks type NetworkAPIClient interface { NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error - NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) + NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error) NetworkDisconnect(ctx context.Context, network, container string, force bool) error NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, error) NetworkInspectWithRaw(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, []byte, error) diff --git a/client/network_create.go b/client/network_create.go index 9babf0cb9c..9c7dc1fd65 100644 --- a/client/network_create.go +++ b/client/network_create.go @@ -9,7 +9,7 @@ import ( ) // NetworkCreate creates a new network in the docker host. -func (cli *Client) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) { +func (cli *Client) NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error) { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // @@ -20,8 +20,19 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options netwo } networkCreateRequest := network.CreateRequest{ - CreateOptions: options, - Name: name, + Name: name, + Driver: options.Driver, + Scope: options.Scope, + EnableIPv4: options.EnableIPv4, + EnableIPv6: options.EnableIPv6, + IPAM: options.IPAM, + Internal: options.Internal, + Attachable: options.Attachable, + Ingress: options.Ingress, + ConfigOnly: options.ConfigOnly, + ConfigFrom: options.ConfigFrom, + Options: options.Options, + Labels: options.Labels, } if versions.LessThan(cli.version, "1.44") { enabled := true diff --git a/client/network_create_opts.go b/client/network_create_opts.go new file mode 100644 index 0000000000..5111d4a933 --- /dev/null +++ b/client/network_create_opts.go @@ -0,0 +1,19 @@ +package client + +import "github.com/moby/moby/api/types/network" + +// NetworkCreateOptions holds options to create a network. +type NetworkCreateOptions struct { + Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`) + Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level). + EnableIPv4 *bool // EnableIPv4 represents whether to enable IPv4. + EnableIPv6 *bool // EnableIPv6 represents whether to enable IPv6. + IPAM *network.IPAM // IPAM is the network's IP Address Management. + Internal bool // Internal represents if the network is used internal only. + Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode. + Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster. + ConfigOnly bool // ConfigOnly creates a config-only network. Config-only networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services. + ConfigFrom *network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly]. + Options map[string]string // Options specifies the network-specific options to use for when creating the network. + Labels map[string]string // Labels holds metadata specific to the network being created. +} diff --git a/client/network_create_test.go b/client/network_create_test.go index fd0b7463ef..25f8819f3a 100644 --- a/client/network_create_test.go +++ b/client/network_create_test.go @@ -21,7 +21,7 @@ func TestNetworkCreateError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, err := client.NetworkCreate(context.Background(), "mynetwork", network.CreateOptions{}) + _, err := client.NetworkCreate(context.Background(), "mynetwork", NetworkCreateOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } @@ -33,7 +33,7 @@ func TestNetworkCreateConnectionError(t *testing.T) { client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid")) assert.NilError(t, err) - _, err = client.NetworkCreate(context.Background(), "mynetwork", network.CreateOptions{}) + _, err = client.NetworkCreate(context.Background(), "mynetwork", NetworkCreateOptions{}) assert.Check(t, is.ErrorType(err, IsErrConnectionFailed)) } @@ -65,7 +65,7 @@ func TestNetworkCreate(t *testing.T) { } enableIPv6 := true - networkResponse, err := client.NetworkCreate(context.Background(), "mynetwork", network.CreateOptions{ + networkResponse, err := client.NetworkCreate(context.Background(), "mynetwork", NetworkCreateOptions{ Driver: "mydriver", EnableIPv6: &enableIPv6, Internal: true, diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go index 4a90d73574..1ff0f675a1 100644 --- a/daemon/cluster/executor/container/container.go +++ b/daemon/cluster/executor/container/container.go @@ -628,34 +628,35 @@ func (c *containerConfig) serviceConfig() *clustertypes.ServiceConfig { func networkCreateRequest(name string, nw *api.Network) clustertypes.NetworkCreateRequest { ipv4Enabled := true ipv6Enabled := nw.Spec.Ipv6Enabled - options := network.CreateOptions{ - // ID: nw.ID, - Labels: nw.Spec.Annotations.Labels, + req := network.CreateRequest{ + Name: name, // TODO(thaJeztah): this is the same as [nw.Spec.Annotations.Name]; consider using that instead + Scope: scope.Swarm, + EnableIPv4: &ipv4Enabled, + EnableIPv6: &ipv6Enabled, Internal: nw.Spec.Internal, Attachable: nw.Spec.Attachable, Ingress: convert.IsIngressNetwork(nw), - EnableIPv4: &ipv4Enabled, - EnableIPv6: &ipv6Enabled, - Scope: scope.Swarm, + Labels: nw.Spec.Annotations.Labels, } if nw.Spec.GetNetwork() != "" { - options.ConfigFrom = &network.ConfigReference{ + req.ConfigFrom = &network.ConfigReference{ Network: nw.Spec.GetNetwork(), } } if nw.DriverState != nil { - options.Driver = nw.DriverState.Name - options.Options = nw.DriverState.Options + req.Driver = nw.DriverState.Name + req.Options = nw.DriverState.Options } + if nw.IPAM != nil { - options.IPAM = &network.IPAM{ + req.IPAM = &network.IPAM{ Driver: nw.IPAM.Driver.Name, Options: nw.IPAM.Driver.Options, } for _, ic := range nw.IPAM.Configs { - options.IPAM.Config = append(options.IPAM.Config, network.IPAMConfig{ + req.IPAM.Config = append(req.IPAM.Config, network.IPAMConfig{ Subnet: ic.Subnet, IPRange: ic.Range, Gateway: ic.Gateway, @@ -664,11 +665,8 @@ func networkCreateRequest(name string, nw *api.Network) clustertypes.NetworkCrea } return clustertypes.NetworkCreateRequest{ - ID: nw.ID, - CreateRequest: network.CreateRequest{ - Name: name, // TODO(thaJeztah): this is the same as [nw.Spec.Annotations.Name]; consider using that instead - CreateOptions: options, - }, + ID: nw.ID, + CreateRequest: req, } } diff --git a/daemon/cluster/executor/container/executor.go b/daemon/cluster/executor/container/executor.go index 28ac981063..982e676b35 100644 --- a/daemon/cluster/executor/container/executor.go +++ b/daemon/cluster/executor/container/executor.go @@ -214,13 +214,14 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error { if ingressNA == nil { e.backend.ReleaseIngress() } else { - options := network.CreateOptions{ + networkCreateRequest := network.CreateRequest{ + Name: ingressNA.Network.Spec.Annotations.Name, Driver: ingressNA.Network.DriverState.Name, IPAM: &network.IPAM{ Driver: ingressNA.Network.IPAM.Driver.Name, }, - Options: ingressNA.Network.DriverState.Options, Ingress: true, + Options: ingressNA.Network.DriverState.Options, } for _, ic := range ingressNA.Network.IPAM.Configs { @@ -229,15 +230,12 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error { IPRange: ic.Range, Gateway: ic.Gateway, } - options.IPAM.Config = append(options.IPAM.Config, c) + networkCreateRequest.IPAM.Config = append(networkCreateRequest.IPAM.Config, c) } _, err := e.backend.SetupIngress(clustertypes.NetworkCreateRequest{ - ID: ingressNA.Network.ID, - CreateRequest: network.CreateRequest{ - Name: ingressNA.Network.Spec.Annotations.Name, - CreateOptions: options, - }, + ID: ingressNA.Network.ID, + CreateRequest: networkCreateRequest, }, ingressNA.Addresses[0]) if err != nil { return err diff --git a/integration-cli/docker_api_network_test.go b/integration-cli/docker_api_network_test.go index 3d67c73f80..a230e554d1 100644 --- a/integration-cli/docker_api_network_test.go +++ b/integration-cli/docker_api_network_test.go @@ -67,12 +67,10 @@ func (s *DockerAPISuite) TestAPINetworkInspectUserDefinedNetwork(c *testing.T) { Config: []network.IPAMConfig{{Subnet: "172.28.0.0/16", IPRange: "172.28.5.0/24", Gateway: "172.28.5.254"}}, } config := network.CreateRequest{ - Name: "br0", - CreateOptions: network.CreateOptions{ - Driver: "bridge", - IPAM: ipam, - Options: map[string]string{"foo": "bar", "opts": "dopts"}, - }, + Name: "br0", + Driver: "bridge", + IPAM: ipam, + Options: map[string]string{"foo": "bar", "opts": "dopts"}, } id0 := createNetwork(c, config, http.StatusCreated) assert.Assert(c, isNetworkAvailable(c, "br0")) @@ -140,11 +138,9 @@ func (s *DockerAPISuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) Config: []network.IPAMConfig{{Subnet: "192.178.0.0/16", IPRange: "192.178.128.0/17", Gateway: "192.178.138.100"}}, } config0 := network.CreateRequest{ - Name: "test0", - CreateOptions: network.CreateOptions{ - Driver: "bridge", - IPAM: ipam0, - }, + Name: "test0", + Driver: "bridge", + IPAM: ipam0, } id0 := createNetwork(c, config0, http.StatusCreated) assert.Assert(c, isNetworkAvailable(c, "test0")) @@ -155,11 +151,9 @@ func (s *DockerAPISuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) } // test1 bridge network overlaps with test0 config1 := network.CreateRequest{ - Name: "test1", - CreateOptions: network.CreateOptions{ - Driver: "bridge", - IPAM: ipam1, - }, + Name: "test1", + Driver: "bridge", + IPAM: ipam1, } createNetwork(c, config1, http.StatusForbidden) assert.Assert(c, !isNetworkAvailable(c, "test1")) @@ -170,11 +164,9 @@ func (s *DockerAPISuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *testing.T) } // test2 bridge network does not overlap config2 := network.CreateRequest{ - Name: "test2", - CreateOptions: network.CreateOptions{ - Driver: "bridge", - IPAM: ipam2, - }, + Name: "test2", + Driver: "bridge", + IPAM: ipam2, } createNetwork(c, config2, http.StatusCreated) assert.Assert(c, isNetworkAvailable(c, "test2")) diff --git a/integration-cli/docker_api_swarm_test.go b/integration-cli/docker_api_swarm_test.go index bbfab8ec82..93a12b99a3 100644 --- a/integration-cli/docker_api_swarm_test.go +++ b/integration-cli/docker_api_swarm_test.go @@ -20,7 +20,6 @@ import ( "github.com/cloudflare/cfssl/initca" cerrdefs "github.com/containerd/errdefs" "github.com/moby/moby/api/types/container" - "github.com/moby/moby/api/types/network" "github.com/moby/moby/api/types/swarm" "github.com/moby/moby/client" "github.com/moby/moby/v2/integration-cli/checker" @@ -1023,7 +1022,7 @@ func (s *DockerSwarmSuite) TestAPINetworkInspectWithScope(c *testing.T) { name := "test-scoped-network" apiclient := d.NewClientT(c) - resp, err := apiclient.NetworkCreate(ctx, name, network.CreateOptions{Driver: "overlay"}) + resp, err := apiclient.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: "overlay"}) assert.NilError(c, err) nw, err := apiclient.NetworkInspect(ctx, name, client.NetworkInspectOptions{}) diff --git a/integration/container/rename_test.go b/integration/container/rename_test.go index 2db28da789..2791f1a080 100644 --- a/integration/container/rename_test.go +++ b/integration/container/rename_test.go @@ -5,6 +5,7 @@ import ( containertypes "github.com/moby/moby/api/types/container" "github.com/moby/moby/api/types/network" + "github.com/moby/moby/client" "github.com/moby/moby/v2/integration/internal/container" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -113,7 +114,7 @@ func TestRenameAnonymousContainer(t *testing.T) { apiClient := testEnv.APIClient() networkName := "network1" + t.Name() - _, err := apiClient.NetworkCreate(ctx, networkName, network.CreateOptions{}) + _, err := apiClient.NetworkCreate(ctx, networkName, client.NetworkCreateOptions{}) assert.NilError(t, err) cID := container.Run(ctx, t, apiClient, func(c *container.TestContainerConfig) { diff --git a/integration/internal/network/network.go b/integration/internal/network/network.go index 1e9a7ece38..d8c9c0fc1a 100644 --- a/integration/internal/network/network.go +++ b/integration/internal/network/network.go @@ -4,32 +4,31 @@ import ( "context" "testing" - "github.com/moby/moby/api/types/network" "github.com/moby/moby/client" "gotest.tools/v3/assert" ) -func createNetwork(ctx context.Context, client client.APIClient, name string, ops ...func(*network.CreateOptions)) (string, error) { - config := network.CreateOptions{} +func createNetwork(ctx context.Context, apiClient client.APIClient, name string, ops ...func(*client.NetworkCreateOptions)) (string, error) { + config := client.NetworkCreateOptions{} for _, op := range ops { op(&config) } - n, err := client.NetworkCreate(ctx, name, config) + n, err := apiClient.NetworkCreate(ctx, name, config) return n.ID, err } // Create creates a network with the specified options -func Create(ctx context.Context, client client.APIClient, name string, ops ...func(*network.CreateOptions)) (string, error) { - return createNetwork(ctx, client, name, ops...) +func Create(ctx context.Context, apiClient client.APIClient, name string, ops ...func(*client.NetworkCreateOptions)) (string, error) { + return createNetwork(ctx, apiClient, name, ops...) } // CreateNoError creates a network with the specified options and verifies there were no errors -func CreateNoError(ctx context.Context, t *testing.T, client client.APIClient, name string, ops ...func(*network.CreateOptions)) string { +func CreateNoError(ctx context.Context, t *testing.T, apiClient client.APIClient, name string, ops ...func(*client.NetworkCreateOptions)) string { t.Helper() - name, err := createNetwork(ctx, client, name, ops...) + name, err := createNetwork(ctx, apiClient, name, ops...) assert.NilError(t, err) return name } diff --git a/integration/internal/network/ops.go b/integration/internal/network/ops.go index 5482e3be91..4fd7180a15 100644 --- a/integration/internal/network/ops.go +++ b/integration/internal/network/ops.go @@ -2,85 +2,86 @@ package network import ( "github.com/moby/moby/api/types/network" + "github.com/moby/moby/client" ) // WithDriver sets the driver of the network -func WithDriver(driver string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithDriver(driver string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Driver = driver } } // WithIPv4 enables/disables IPv4 on the network -func WithIPv4(enable bool) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithIPv4(enable bool) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { enableIPv4 := enable n.EnableIPv4 = &enableIPv4 } } // WithIPv6 Enables IPv6 on the network -func WithIPv6() func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithIPv6() func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { enableIPv6 := true n.EnableIPv6 = &enableIPv6 } } // WithIPv4Disabled makes sure IPv4 is disabled on the network. -func WithIPv4Disabled() func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithIPv4Disabled() func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { enable := false n.EnableIPv4 = &enable } } // WithIPv6Disabled makes sure IPv6 is disabled on the network. -func WithIPv6Disabled() func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithIPv6Disabled() func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { enable := false n.EnableIPv6 = &enable } } // WithInternal enables Internal flag on the create network request -func WithInternal() func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithInternal() func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Internal = true } } // WithConfigOnly sets the ConfigOnly flag in the create network request -func WithConfigOnly(co bool) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithConfigOnly(co bool) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.ConfigOnly = co } } // WithConfigFrom sets the ConfigOnly flag in the create network request -func WithConfigFrom(name string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithConfigFrom(name string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.ConfigFrom = &network.ConfigReference{Network: name} } } // WithAttachable sets Attachable flag on the create network request -func WithAttachable() func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithAttachable() func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Attachable = true } } // WithScope sets the network scope. -func WithScope(s string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithScope(s string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Scope = s } } // WithMacvlan sets the network as macvlan with the specified parent -func WithMacvlan(parent string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithMacvlan(parent string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Driver = "macvlan" if parent != "" { n.Options = map[string]string{ @@ -91,8 +92,8 @@ func WithMacvlan(parent string) func(*network.CreateOptions) { } // WithMacvlanPassthru sets the network as macvlan with the specified parent in passthru mode -func WithMacvlanPassthru(parent string) func(options *network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithMacvlanPassthru(parent string) func(options *client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Driver = "macvlan" n.Options = map[string]string{ "macvlan_mode": "passthru", @@ -104,8 +105,8 @@ func WithMacvlanPassthru(parent string) func(options *network.CreateOptions) { } // WithIPvlan sets the network as ipvlan with the specified parent and mode -func WithIPvlan(parent, mode string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithIPvlan(parent, mode string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { n.Driver = "ipvlan" if n.Options == nil { n.Options = map[string]string{} @@ -120,8 +121,8 @@ func WithIPvlan(parent, mode string) func(*network.CreateOptions) { } // WithOption adds the specified key/value pair to network's options -func WithOption(key, value string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithOption(key, value string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { if n.Options == nil { n.Options = map[string]string{} } @@ -130,13 +131,13 @@ func WithOption(key, value string) func(*network.CreateOptions) { } // WithIPAM adds an IPAM with the specified Subnet and Gateway to the network -func WithIPAM(subnet, gateway string) func(*network.CreateOptions) { +func WithIPAM(subnet, gateway string) func(*client.NetworkCreateOptions) { return WithIPAMRange(subnet, "", gateway) } // WithIPAMRange adds an IPAM with the specified Subnet, IPRange and Gateway to the network -func WithIPAMRange(subnet, iprange, gateway string) func(*network.CreateOptions) { - return func(n *network.CreateOptions) { +func WithIPAMRange(subnet, iprange, gateway string) func(*client.NetworkCreateOptions) { + return func(n *client.NetworkCreateOptions) { if n.IPAM == nil { n.IPAM = &network.IPAM{} } diff --git a/integration/network/bridge/bridge_linux_test.go b/integration/network/bridge/bridge_linux_test.go index 2d2a6559f8..96404529ff 100644 --- a/integration/network/bridge/bridge_linux_test.go +++ b/integration/network/bridge/bridge_linux_test.go @@ -127,7 +127,7 @@ func TestDefaultIPvOptOverride(t *testing.T) { t.Run(fmt.Sprintf("override4=%v,override6=%v", override4, override6), func(t *testing.T) { t.Parallel() netName := fmt.Sprintf("tdioo-%v-%v", override4, override6) - var nopts []func(*networktypes.CreateOptions) + var nopts []func(*client.NetworkCreateOptions) if override4 { nopts = append(nopts, network.WithIPv4(true)) } @@ -373,7 +373,7 @@ func TestPointToPoint(t *testing.T) { testcases := []struct { name string - netOpt func(*networktypes.CreateOptions) + netOpt func(*client.NetworkCreateOptions) }{ { name: "inhibit_ipv4", diff --git a/integration/network/bridge/iptablesdoc/iptablesdoc_linux_test.go b/integration/network/bridge/iptablesdoc/iptablesdoc_linux_test.go index 73bc5ebb8a..cc152a5495 100644 --- a/integration/network/bridge/iptablesdoc/iptablesdoc_linux_test.go +++ b/integration/network/bridge/iptablesdoc/iptablesdoc_linux_test.go @@ -31,7 +31,6 @@ import ( "time" containertypes "github.com/moby/moby/api/types/container" - networktypes "github.com/moby/moby/api/types/network" swarmtypes "github.com/moby/moby/api/types/swarm" "github.com/moby/moby/client" "github.com/moby/moby/v2/daemon/libnetwork/drivers/bridge" @@ -311,7 +310,7 @@ func createBridgeNetworks(ctx context.Context, t *testing.T, d *daemon.Daemon, s if gwMode == "" { gwMode = "nat" } - netOpts := []func(*networktypes.CreateOptions){ + netOpts := []func(*client.NetworkCreateOptions){ network.WithIPAM(docNetworks[i], docGateways[i]), network.WithOption(bridge.BridgeName, nw.name), network.WithOption(bridge.IPv4GatewayMode, gwMode), diff --git a/integration/network/bridge/nftablesdoc/nftablesdoc_linux_test.go b/integration/network/bridge/nftablesdoc/nftablesdoc_linux_test.go index 1064765cba..49faf09663 100644 --- a/integration/network/bridge/nftablesdoc/nftablesdoc_linux_test.go +++ b/integration/network/bridge/nftablesdoc/nftablesdoc_linux_test.go @@ -29,8 +29,8 @@ import ( "text/template" containertypes "github.com/moby/moby/api/types/container" - networktypes "github.com/moby/moby/api/types/network" swarmtypes "github.com/moby/moby/api/types/swarm" + "github.com/moby/moby/client" "github.com/moby/moby/v2/daemon/libnetwork/drivers/bridge" "github.com/moby/moby/v2/integration/internal/container" "github.com/moby/moby/v2/integration/internal/network" @@ -283,7 +283,7 @@ func createBridgeNetworks(ctx context.Context, t *testing.T, d *daemon.Daemon, s if gwMode == "" { gwMode = "nat" } - netOpts := []func(*networktypes.CreateOptions){ + netOpts := []func(*client.NetworkCreateOptions){ network.WithIPAM(docNetworks[i], docGateways[i]), network.WithOption(bridge.BridgeName, nw.name), network.WithOption(bridge.IPv4GatewayMode, gwMode), diff --git a/integration/network/ipvlan/ipvlan_test.go b/integration/network/ipvlan/ipvlan_test.go index 16e0e5ca6a..d4ae489191 100644 --- a/integration/network/ipvlan/ipvlan_test.go +++ b/integration/network/ipvlan/ipvlan_test.go @@ -490,7 +490,7 @@ func TestIpvlanIPAM(t *testing.T) { ctx := testutil.StartSpan(ctx, t) c := d.NewClientT(t, dclient.WithVersion(tc.apiVersion)) - netOpts := []func(*network.CreateOptions){ + netOpts := []func(*dclient.NetworkCreateOptions){ net.WithIPvlan("", "l3"), net.WithIPv4(tc.enableIPv4), } @@ -591,7 +591,7 @@ func TestIPVlanDNS(t *testing.T) { name := fmt.Sprintf("Mode=%v/HasParent=%v/Internal=%v", mode, tc.parent != "", tc.internal) t.Run(name, func(t *testing.T) { ctx := testutil.StartSpan(ctx, t) - createOpts := []func(*network.CreateOptions){ + createOpts := []func(*dclient.NetworkCreateOptions){ net.WithIPvlan(tc.parent, mode), } if tc.internal { diff --git a/integration/network/macvlan/macvlan_test.go b/integration/network/macvlan/macvlan_test.go index 0e362e69cc..d98061913d 100644 --- a/integration/network/macvlan/macvlan_test.go +++ b/integration/network/macvlan/macvlan_test.go @@ -487,7 +487,7 @@ func TestMacvlanIPAM(t *testing.T) { ctx := testutil.StartSpan(ctx, t) c := d.NewClientT(t, client.WithVersion(tc.apiVersion)) - netOpts := []func(*network.CreateOptions){ + netOpts := []func(*client.NetworkCreateOptions){ net.WithMacvlan(""), net.WithOption("macvlan_mode", "bridge"), net.WithIPv4(tc.enableIPv4), @@ -587,7 +587,7 @@ func TestMACVlanDNS(t *testing.T) { for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { ctx := testutil.StartSpan(ctx, t) - createOpts := []func(*network.CreateOptions){ + createOpts := []func(*client.NetworkCreateOptions){ net.WithMacvlan(tc.parent), } if tc.internal { diff --git a/integration/network/network_linux_test.go b/integration/network/network_linux_test.go index 055696c60b..b77178d3ce 100644 --- a/integration/network/network_linux_test.go +++ b/integration/network/network_linux_test.go @@ -143,7 +143,7 @@ func TestDefaultNetworkOpts(t *testing.T) { if tc.configFrom { // Create a new network config - network.CreateNoError(ctx, t, c, "from-net", func(create *networktypes.CreateOptions) { + network.CreateNoError(ctx, t, c, "from-net", func(create *client.NetworkCreateOptions) { create.ConfigOnly = true create.Options = map[string]string{ "com.docker.network.driver.mtu": fmt.Sprint(tc.mtu), @@ -154,7 +154,7 @@ func TestDefaultNetworkOpts(t *testing.T) { // Create a new network networkName := "testnet" - networkId := network.CreateNoError(ctx, t, c, networkName, func(create *networktypes.CreateOptions) { + networkId := network.CreateNoError(ctx, t, c, networkName, func(create *client.NetworkCreateOptions) { if tc.configFrom { create.ConfigFrom = &networktypes.ConfigReference{ Network: "from-net", @@ -196,7 +196,7 @@ func TestForbidDuplicateNetworkNames(t *testing.T) { network.CreateNoError(ctx, t, c, "testnet") defer network.RemoveNoError(ctx, t, c, "testnet") - _, err := c.NetworkCreate(ctx, "testnet", networktypes.CreateOptions{}) + _, err := c.NetworkCreate(ctx, "testnet", client.NetworkCreateOptions{}) assert.Error(t, err, "Error response from daemon: network with name testnet already exists", "2nd NetworkCreate call should have failed") } diff --git a/integration/networking/bridge_linux_test.go b/integration/networking/bridge_linux_test.go index 93682490cf..6ba3399b1a 100644 --- a/integration/networking/bridge_linux_test.go +++ b/integration/networking/bridge_linux_test.go @@ -49,7 +49,7 @@ func TestBridgeICC(t *testing.T) { testcases := []struct { name string - bridgeOpts []func(*networktypes.CreateOptions) + bridgeOpts []func(*client.NetworkCreateOptions) ctr1MacAddress string isIPv6 bool isLinkLocal bool @@ -57,17 +57,17 @@ func TestBridgeICC(t *testing.T) { }{ { name: "IPv4 non-internal network", - bridgeOpts: []func(*networktypes.CreateOptions){}, + bridgeOpts: []func(*client.NetworkCreateOptions){}, }, { name: "IPv4 internal network", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithInternal(), }, }, { name: "IPv6 ULA on non-internal network", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b200::/64", "fdf1:a844:380c:b200::1"), }, @@ -75,7 +75,7 @@ func TestBridgeICC(t *testing.T) { }, { name: "IPv6 ULA on internal network", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithInternal(), network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"), @@ -84,7 +84,7 @@ func TestBridgeICC(t *testing.T) { }, { name: "IPv6 link-local address on non-internal network", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), // There's no real way to specify an IPv6 network is only used with SLAAC link-local IPv6 addresses. // What we can do instead, is to tell the IPAM driver to assign addresses from the link-local prefix. @@ -97,7 +97,7 @@ func TestBridgeICC(t *testing.T) { }, { name: "IPv6 link-local address on internal network", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithInternal(), // See the note above about link-local addresses. @@ -115,7 +115,7 @@ func TestBridgeICC(t *testing.T) { // addresses need not be qualified with a zone index." // So, for this common case, LL addresses should be included in DNS config. name: "IPv6 link-local address on non-internal network ping by name", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fe80::/64", "fe80::1"), }, @@ -128,7 +128,7 @@ func TestBridgeICC(t *testing.T) { // configure two networks with the same LL subnet, although perhaps it should // be). So, again, no zone index is required and the LL address should be // included in DNS config. - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fe80:1234::/64", "fe80:1234::1"), }, @@ -136,7 +136,7 @@ func TestBridgeICC(t *testing.T) { }, { name: "IPv6 non-internal network with SLAAC LL address", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"), }, @@ -148,7 +148,7 @@ func TestBridgeICC(t *testing.T) { }, { name: "IPv6 internal network with SLAAC LL address", - bridgeOpts: []func(*networktypes.CreateOptions){ + bridgeOpts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"), }, @@ -234,8 +234,8 @@ func TestBridgeINC(t *testing.T) { defer c.Close() type bridgesOpts struct { - bridge1Opts []func(*networktypes.CreateOptions) - bridge2Opts []func(*networktypes.CreateOptions) + bridge1Opts []func(*client.NetworkCreateOptions) + bridge2Opts []func(*client.NetworkCreateOptions) } testcases := []struct { @@ -248,27 +248,27 @@ func TestBridgeINC(t *testing.T) { { name: "IPv4 non-internal network", bridges: bridgesOpts{ - bridge1Opts: []func(*networktypes.CreateOptions){}, - bridge2Opts: []func(*networktypes.CreateOptions){}, + bridge1Opts: []func(*client.NetworkCreateOptions){}, + bridge2Opts: []func(*client.NetworkCreateOptions){}, }, stdout: "1 packets transmitted, 0 packets received", }, { name: "IPv4 internal network", bridges: bridgesOpts{ - bridge1Opts: []func(*networktypes.CreateOptions){network.WithInternal()}, - bridge2Opts: []func(*networktypes.CreateOptions){network.WithInternal()}, + bridge1Opts: []func(*client.NetworkCreateOptions){network.WithInternal()}, + bridge2Opts: []func(*client.NetworkCreateOptions){network.WithInternal()}, }, stderr: "sendto: Network is unreachable", }, { name: "IPv6 ULA on non-internal network", bridges: bridgesOpts{ - bridge1Opts: []func(*networktypes.CreateOptions){ + bridge1Opts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b200::/64", "fdf1:a844:380c:b200::1"), }, - bridge2Opts: []func(*networktypes.CreateOptions){ + bridge2Opts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fdf1:a844:380c:b247::/64", "fdf1:a844:380c:b247::1"), }, @@ -279,12 +279,12 @@ func TestBridgeINC(t *testing.T) { { name: "IPv6 ULA on internal network", bridges: bridgesOpts{ - bridge1Opts: []func(*networktypes.CreateOptions){ + bridge1Opts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithInternal(), network.WithIPAM("fdf1:a844:390c:b200::/64", "fdf1:a844:390c:b200::1"), }, - bridge2Opts: []func(*networktypes.CreateOptions){ + bridge2Opts: []func(*client.NetworkCreateOptions){ network.WithIPv6(), network.WithInternal(), network.WithIPAM("fdf1:a844:390c:b247::/64", "fdf1:a844:390c:b247::1"), @@ -1543,7 +1543,7 @@ func TestAdvertiseAddresses(t *testing.T) { testcases := []struct { name string - netOpts []func(*networktypes.CreateOptions) + netOpts []func(*client.NetworkCreateOptions) ipv6LinkLocal bool stopCtr2After time.Duration expNetCreateErr string @@ -1558,21 +1558,21 @@ func TestAdvertiseAddresses(t *testing.T) { }, { name: "disable advertise addrs", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrNMsgs, "0"), }, expNoMACUpdate: true, }, { name: "single message", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrNMsgs, "1"), }, expNMsgs: 1, }, { name: "min interval", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrIntervalMs, "100"), }, expNMsgs: 3, @@ -1580,7 +1580,7 @@ func TestAdvertiseAddresses(t *testing.T) { }, { name: "cancel", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrIntervalMs, "2000"), }, stopCtr2After: 200 * time.Millisecond, @@ -1594,42 +1594,42 @@ func TestAdvertiseAddresses(t *testing.T) { }, { name: "interval too short", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrIntervalMs, "99"), }, expNetCreateErr: "Error response from daemon: com.docker.network.advertise_addr_ms must be in the range 100 to 2000", }, { name: "interval too long", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrIntervalMs, "2001"), }, expNetCreateErr: "Error response from daemon: com.docker.network.advertise_addr_ms must be in the range 100 to 2000", }, { name: "nonsense interval", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrIntervalMs, "nonsense"), }, expNetCreateErr: `Error response from daemon: value for option com.docker.network.advertise_addr_ms "nonsense" must be integer milliseconds`, }, { name: "negative msg count", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrNMsgs, "-1"), }, expNetCreateErr: "Error response from daemon: com.docker.network.advertise_addr_nmsgs must be in the range 0 to 3", }, { name: "too many msgs", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrNMsgs, "4"), }, expNetCreateErr: "Error response from daemon: com.docker.network.advertise_addr_nmsgs must be in the range 0 to 3", }, { name: "nonsense msg count", - netOpts: []func(*networktypes.CreateOptions){ + netOpts: []func(*client.NetworkCreateOptions){ network.WithOption(netlabel.AdvertiseAddrNMsgs, "nonsense"), }, expNetCreateErr: `Error response from daemon: value for option com.docker.network.advertise_addr_nmsgs "nonsense" must be an integer`, @@ -1642,7 +1642,7 @@ func TestAdvertiseAddresses(t *testing.T) { const netName = "dsnet" const brName = "br-advaddr" - netOpts := append([]func(*networktypes.CreateOptions){ + netOpts := append([]func(*client.NetworkCreateOptions){ network.WithOption(bridge.BridgeName, brName), network.WithIPv6(), network.WithIPAM("172.22.22.0/24", "172.22.22.1"), diff --git a/integration/networking/port_mapping_linux_test.go b/integration/networking/port_mapping_linux_test.go index 1993878d5e..5515c7ce18 100644 --- a/integration/networking/port_mapping_linux_test.go +++ b/integration/networking/port_mapping_linux_test.go @@ -108,7 +108,7 @@ func TestDisableNAT(t *testing.T) { ctx := testutil.StartSpan(ctx, t) const netName = "testnet" - nwOpts := []func(options *networktypes.CreateOptions){ + nwOpts := []func(options *client.NetworkCreateOptions){ network.WithIPv6(), network.WithIPAM("fd2a:a2c3:4448::/64", "fd2a:a2c3:4448::1"), } @@ -358,7 +358,7 @@ func TestAccessPublishedPortFromHost(t *testing.T) { defer c.Close() bridgeName := fmt.Sprintf("nat-from-host-%d", tcID) - bridgeOpts := []func(options *networktypes.CreateOptions){ + bridgeOpts := []func(options *client.NetworkCreateOptions){ network.WithDriver("bridge"), network.WithOption(bridge.BridgeName, bridgeName), } @@ -1290,7 +1290,7 @@ func testDirectRemoteAccessOnExposedPort(t *testing.T, ctx context.Context, d *d testutil.StartSpan(ctx, t) - nwOpts := []func(*networktypes.CreateOptions){ + nwOpts := []func(*client.NetworkCreateOptions){ network.WithIPAM(tc.gwAddr.Masked().String(), tc.gwAddr.Addr().String()), network.WithOption(bridge.IPv4GatewayMode, tc.gwMode), network.WithOption(bridge.IPv6GatewayMode, tc.gwMode), diff --git a/vendor/github.com/moby/moby/api/types/network/network.go b/vendor/github.com/moby/moby/api/types/network/network.go index e8325110b4..7e2f59f387 100644 --- a/vendor/github.com/moby/moby/api/types/network/network.go +++ b/vendor/github.com/moby/moby/api/types/network/network.go @@ -21,16 +21,7 @@ const ( // CreateRequest is the request message sent to the server for network create call. type CreateRequest struct { - CreateOptions - Name string // Name is the requested name of the network. - - // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client - // package to older daemons. - CheckDuplicate *bool `json:",omitempty"` -} - -// CreateOptions holds options to create a network. -type CreateOptions struct { + Name string // Name is the requested name of the network. Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`) Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level). EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4. @@ -43,6 +34,10 @@ type CreateOptions struct { ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly]. Options map[string]string // Options specifies the network-specific options to use for when creating the network. Labels map[string]string // Labels holds metadata specific to the network being created. + + // Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client + // package to older daemons. + CheckDuplicate *bool `json:",omitempty"` } // Inspect is the body of the "get network" http response message. diff --git a/vendor/github.com/moby/moby/client/client_interfaces.go b/vendor/github.com/moby/moby/client/client_interfaces.go index 1b597a12c6..f5df3ac28a 100644 --- a/vendor/github.com/moby/moby/client/client_interfaces.go +++ b/vendor/github.com/moby/moby/client/client_interfaces.go @@ -129,7 +129,7 @@ type ImageAPIClient interface { // NetworkAPIClient defines API client methods for the networks type NetworkAPIClient interface { NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error - NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) + NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error) NetworkDisconnect(ctx context.Context, network, container string, force bool) error NetworkInspect(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, error) NetworkInspectWithRaw(ctx context.Context, network string, options NetworkInspectOptions) (network.Inspect, []byte, error) diff --git a/vendor/github.com/moby/moby/client/network_create.go b/vendor/github.com/moby/moby/client/network_create.go index 9babf0cb9c..9c7dc1fd65 100644 --- a/vendor/github.com/moby/moby/client/network_create.go +++ b/vendor/github.com/moby/moby/client/network_create.go @@ -9,7 +9,7 @@ import ( ) // NetworkCreate creates a new network in the docker host. -func (cli *Client) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) { +func (cli *Client) NetworkCreate(ctx context.Context, name string, options NetworkCreateOptions) (network.CreateResponse, error) { // Make sure we negotiated (if the client is configured to do so), // as code below contains API-version specific handling of options. // @@ -20,8 +20,19 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options netwo } networkCreateRequest := network.CreateRequest{ - CreateOptions: options, - Name: name, + Name: name, + Driver: options.Driver, + Scope: options.Scope, + EnableIPv4: options.EnableIPv4, + EnableIPv6: options.EnableIPv6, + IPAM: options.IPAM, + Internal: options.Internal, + Attachable: options.Attachable, + Ingress: options.Ingress, + ConfigOnly: options.ConfigOnly, + ConfigFrom: options.ConfigFrom, + Options: options.Options, + Labels: options.Labels, } if versions.LessThan(cli.version, "1.44") { enabled := true diff --git a/vendor/github.com/moby/moby/client/network_create_opts.go b/vendor/github.com/moby/moby/client/network_create_opts.go new file mode 100644 index 0000000000..5111d4a933 --- /dev/null +++ b/vendor/github.com/moby/moby/client/network_create_opts.go @@ -0,0 +1,19 @@ +package client + +import "github.com/moby/moby/api/types/network" + +// NetworkCreateOptions holds options to create a network. +type NetworkCreateOptions struct { + Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`) + Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level). + EnableIPv4 *bool // EnableIPv4 represents whether to enable IPv4. + EnableIPv6 *bool // EnableIPv6 represents whether to enable IPv6. + IPAM *network.IPAM // IPAM is the network's IP Address Management. + Internal bool // Internal represents if the network is used internal only. + Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode. + Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster. + ConfigOnly bool // ConfigOnly creates a config-only network. Config-only networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services. + ConfigFrom *network.ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly]. + Options map[string]string // Options specifies the network-specific options to use for when creating the network. + Labels map[string]string // Labels holds metadata specific to the network being created. +}