mirror of https://github.com/docker/cli.git
Merge pull request #31714 from aboch/cingr
Allow user to replace ingress network
This commit is contained in:
commit
24faf9edaf
|
@ -24,6 +24,7 @@ type createOptions struct {
|
||||||
internal bool
|
internal bool
|
||||||
ipv6 bool
|
ipv6 bool
|
||||||
attachable bool
|
attachable bool
|
||||||
|
ingress bool
|
||||||
|
|
||||||
ipamDriver string
|
ipamDriver string
|
||||||
ipamSubnet []string
|
ipamSubnet []string
|
||||||
|
@ -59,6 +60,8 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags.BoolVar(&opts.ipv6, "ipv6", false, "Enable IPv6 networking")
|
flags.BoolVar(&opts.ipv6, "ipv6", false, "Enable IPv6 networking")
|
||||||
flags.BoolVar(&opts.attachable, "attachable", false, "Enable manual container attachment")
|
flags.BoolVar(&opts.attachable, "attachable", false, "Enable manual container attachment")
|
||||||
flags.SetAnnotation("attachable", "version", []string{"1.25"})
|
flags.SetAnnotation("attachable", "version", []string{"1.25"})
|
||||||
|
flags.BoolVar(&opts.ingress, "ingress", false, "Create swarm routing-mesh network")
|
||||||
|
flags.SetAnnotation("ingress", "version", []string{"1.29"})
|
||||||
|
|
||||||
flags.StringVar(&opts.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
|
flags.StringVar(&opts.ipamDriver, "ipam-driver", "default", "IP Address Management Driver")
|
||||||
flags.StringSliceVar(&opts.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
|
flags.StringSliceVar(&opts.ipamSubnet, "subnet", []string{}, "Subnet in CIDR format that represents a network segment")
|
||||||
|
@ -92,6 +95,7 @@ func runCreate(dockerCli *command.DockerCli, opts createOptions) error {
|
||||||
Internal: opts.internal,
|
Internal: opts.internal,
|
||||||
EnableIPv6: opts.ipv6,
|
EnableIPv6: opts.ipv6,
|
||||||
Attachable: opts.attachable,
|
Attachable: opts.attachable,
|
||||||
|
Ingress: opts.ingress,
|
||||||
Labels: runconfigopts.ConvertKVStringsToMap(opts.labels.GetAll()),
|
Labels: runconfigopts.ConvertKVStringsToMap(opts.labels.GetAll()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,22 @@ func newRemoveCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ingressWarning = "WARNING! Before removing the routing-mesh network, " +
|
||||||
|
"make sure all the nodes in your swarm run the same docker engine version. " +
|
||||||
|
"Otherwise, removal may not be effective and functionality of newly create " +
|
||||||
|
"ingress networks will be impaired.\nAre you sure you want to continue?"
|
||||||
|
|
||||||
func runRemove(dockerCli *command.DockerCli, networks []string) error {
|
func runRemove(dockerCli *command.DockerCli, networks []string) error {
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
status := 0
|
status := 0
|
||||||
|
|
||||||
for _, name := range networks {
|
for _, name := range networks {
|
||||||
|
if nw, _, err := client.NetworkInspectWithRaw(ctx, name, false); err == nil &&
|
||||||
|
nw.Ingress &&
|
||||||
|
!command.PromptForConfirmation(dockerCli.In(), dockerCli.Out(), ingressWarning) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err := client.NetworkRemove(ctx, name); err != nil {
|
if err := client.NetworkRemove(ctx, name); err != nil {
|
||||||
fmt.Fprintf(dockerCli.Err(), "%s\n", err)
|
fmt.Fprintf(dockerCli.Err(), "%s\n", err)
|
||||||
status = 1
|
status = 1
|
||||||
|
|
Loading…
Reference in New Issue