mirror of https://github.com/docker/cli.git
Add support for config-only, config-from and scope options
- To promote a network to swarm mode Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
b3e7e1ff74
commit
b5e43fb5ec
|
@ -18,6 +18,7 @@ import (
|
||||||
|
|
||||||
type createOptions struct {
|
type createOptions struct {
|
||||||
name string
|
name string
|
||||||
|
scope string
|
||||||
driver string
|
driver string
|
||||||
driverOpts opts.MapOpts
|
driverOpts opts.MapOpts
|
||||||
labels opts.ListOpts
|
labels opts.ListOpts
|
||||||
|
@ -25,6 +26,8 @@ type createOptions struct {
|
||||||
ipv6 bool
|
ipv6 bool
|
||||||
attachable bool
|
attachable bool
|
||||||
ingress bool
|
ingress bool
|
||||||
|
configOnly bool
|
||||||
|
configFrom string
|
||||||
|
|
||||||
ipamDriver string
|
ipamDriver string
|
||||||
ipamSubnet []string
|
ipamSubnet []string
|
||||||
|
@ -62,6 +65,12 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags.SetAnnotation("attachable", "version", []string{"1.25"})
|
flags.SetAnnotation("attachable", "version", []string{"1.25"})
|
||||||
flags.BoolVar(&options.ingress, "ingress", false, "Create swarm routing-mesh network")
|
flags.BoolVar(&options.ingress, "ingress", false, "Create swarm routing-mesh network")
|
||||||
flags.SetAnnotation("ingress", "version", []string{"1.29"})
|
flags.SetAnnotation("ingress", "version", []string{"1.29"})
|
||||||
|
flags.StringVar(&options.scope, "scope", "", "Control the network's scope")
|
||||||
|
flags.SetAnnotation("scope", "version", []string{"1.30"})
|
||||||
|
flags.BoolVar(&options.configOnly, "config-only", false, "Create a configuration only network")
|
||||||
|
flags.SetAnnotation("config-only", "version", []string{"1.30"})
|
||||||
|
flags.StringVar(&options.configFrom, "config-from", "", "The network from which copying the configuration")
|
||||||
|
flags.SetAnnotation("config-from", "version", []string{"1.30"})
|
||||||
|
|
||||||
flags.StringVar(&options.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
|
flags.StringVar(&options.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
|
||||||
flags.StringSliceVar(&options.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
|
flags.StringSliceVar(&options.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
|
||||||
|
@ -96,9 +105,17 @@ func runCreate(dockerCli *command.DockerCli, options createOptions) error {
|
||||||
EnableIPv6: options.ipv6,
|
EnableIPv6: options.ipv6,
|
||||||
Attachable: options.attachable,
|
Attachable: options.attachable,
|
||||||
Ingress: options.ingress,
|
Ingress: options.ingress,
|
||||||
|
Scope: options.scope,
|
||||||
|
ConfigOnly: options.configOnly,
|
||||||
Labels: runconfigopts.ConvertKVStringsToMap(options.labels.GetAll()),
|
Labels: runconfigopts.ConvertKVStringsToMap(options.labels.GetAll()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if from := options.configFrom; from != "" {
|
||||||
|
nc.ConfigFrom = &network.ConfigReference{
|
||||||
|
Network: from,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := client.NetworkCreate(context.Background(), options.name, nc)
|
resp, err := client.NetworkCreate(context.Background(), options.name, nc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue