mirror of https://github.com/docker/cli.git
network create: make --ipv6 optional
The API field `EnableIPv6` was marked as optional in our Swagger docs, and its default value in the Go client came from that field being a bool, thus defaulting to its zero value. That's not the case anymore. This field is now a `*bool` as to let daemon's config define the default value. IPv6 can still be enabled / disabled by explicitly specifying the `--ipv6` flag when doing `docker network create`. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
parent
0ed8a7e310
commit
db2672e685
|
@ -23,7 +23,7 @@ type createOptions struct {
|
|||
driverOpts opts.MapOpts
|
||||
labels opts.ListOpts
|
||||
internal bool
|
||||
ipv6 bool
|
||||
ipv6 *bool
|
||||
attachable bool
|
||||
ingress bool
|
||||
configOnly bool
|
||||
|
@ -38,6 +38,7 @@ type createOptions struct {
|
|||
}
|
||||
|
||||
func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
||||
var ipv6 bool
|
||||
options := createOptions{
|
||||
driverOpts: *opts.NewMapOpts(nil, nil),
|
||||
labels: opts.NewListOpts(opts.ValidateLabel),
|
||||
|
@ -51,6 +52,11 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
|||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
options.name = args[0]
|
||||
|
||||
if cmd.Flag("ipv6").Changed {
|
||||
options.ipv6 = &ipv6
|
||||
}
|
||||
|
||||
return runCreate(cmd.Context(), dockerCli, options)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
|
@ -61,7 +67,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
|
|||
flags.VarP(&options.driverOpts, "opt", "o", "Set driver specific options")
|
||||
flags.Var(&options.labels, "label", "Set metadata on a network")
|
||||
flags.BoolVar(&options.internal, "internal", false, "Restrict external access to the network")
|
||||
flags.BoolVar(&options.ipv6, "ipv6", false, "Enable IPv6 networking")
|
||||
flags.BoolVar(&ipv6, "ipv6", false, "Enable or disable IPv6 networking")
|
||||
flags.BoolVar(&options.attachable, "attachable", false, "Enable manual container attachment")
|
||||
flags.SetAnnotation("attachable", "version", []string{"1.25"})
|
||||
flags.BoolVar(&options.ingress, "ingress", false, "Create swarm routing-mesh network")
|
||||
|
@ -107,7 +113,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options createOptions
|
|||
Options: options.ipamOpt.GetAll(),
|
||||
},
|
||||
Internal: options.internal,
|
||||
EnableIPv6: &options.ipv6,
|
||||
EnableIPv6: options.ipv6,
|
||||
Attachable: options.attachable,
|
||||
Ingress: options.ingress,
|
||||
Scope: options.scope,
|
||||
|
|
|
@ -18,7 +18,7 @@ Create a network
|
|||
| `--ip-range` | `stringSlice` | | Allocate container ip from a sub-range |
|
||||
| `--ipam-driver` | `string` | `default` | IP Address Management Driver |
|
||||
| `--ipam-opt` | `map` | `map[]` | Set IPAM driver specific options |
|
||||
| `--ipv6` | | | Enable IPv6 networking |
|
||||
| `--ipv6` | | | Enable or disable IPv6 networking |
|
||||
| `--label` | `list` | | Set metadata on a network |
|
||||
| `-o`, `--opt` | `map` | `map[]` | Set driver specific options |
|
||||
| `--scope` | `string` | | Control the network's scope |
|
||||
|
@ -170,7 +170,7 @@ flags used for the docker0 bridge:
|
|||
| `--gateway` | - | IPv4 or IPv6 Gateway for the master subnet |
|
||||
| `--ip-range` | `--fixed-cidr` | Allocate IPs from a range |
|
||||
| `--internal` | - | Restrict external access to the network |
|
||||
| `--ipv6` | `--ipv6` | Enable IPv6 networking |
|
||||
| `--ipv6` | `--ipv6` | Enable or disable IPv6 networking |
|
||||
| `--subnet` | `--bip` | Subnet for network |
|
||||
|
||||
For example, let's use `-o` or `--opt` options to specify an IP address binding
|
||||
|
|
Loading…
Reference in New Issue