Skip to content

Commit 088518b

Browse files
committed
Add support for config-only and config-from options
Signed-off-by: Alessandro Boch <[email protected]>
1 parent b3e7e1f commit 088518b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

cli/command/network/create.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type createOptions struct {
2525
ipv6 bool
2626
attachable bool
2727
ingress bool
28+
configOnly bool
29+
configFrom string
2830

2931
ipamDriver string
3032
ipamSubnet []string
@@ -62,6 +64,10 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
6264
flags.SetAnnotation("attachable", "version", []string{"1.25"})
6365
flags.BoolVar(&options.ingress, "ingress", false, "Create swarm routing-mesh network")
6466
flags.SetAnnotation("ingress", "version", []string{"1.29"})
67+
flags.BoolVar(&opts.configOnly, "config-only", false, "Create a configuration only network")
68+
flags.SetAnnotation("config-only", "version", []string{"1.30"})
69+
flags.StringVar(&opts.configFrom, "config-from", "", "The network from which copying the configuration")
70+
flags.SetAnnotation("config-from", "version", []string{"1.30"})
6571

6672
flags.StringVar(&options.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
6773
flags.StringSliceVar(&options.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
@@ -96,10 +102,17 @@ func runCreate(dockerCli *command.DockerCli, options createOptions) error {
96102
EnableIPv6: options.ipv6,
97103
Attachable: options.attachable,
98104
Ingress: options.ingress,
99-
Labels: runconfigopts.ConvertKVStringsToMap(options.labels.GetAll()),
105+
ConfigOnly: options.configOnly,
106+
Labels: runconfigopts.ConvertKVStringsToMap(opts.labels.GetAll()),
100107
}
101108

102-
resp, err := client.NetworkCreate(context.Background(), options.name, nc)
109+
if from := options.configFrom; from != "" {
110+
nc.ConfigFrom = network.ConfigReference{
111+
Network: from,
112+
}
113+
}
114+
115+
resp, err := client.NetworkCreate(context.Background(), opts.name, nc)
103116
if err != nil {
104117
return err
105118
}

0 commit comments

Comments
 (0)