-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option --ipv4 #5599
Merged
+96
−25
Merged
Add option --ipv4 #5599
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ type createOptions struct { | |
driverOpts opts.MapOpts | ||
labels opts.ListOpts | ||
internal bool | ||
ipv4 *bool | ||
ipv6 *bool | ||
attachable bool | ||
ingress bool | ||
|
@@ -42,7 +43,7 @@ type ipamOptions struct { | |
} | ||
|
||
func newCreateCommand(dockerCLI command.Cli) *cobra.Command { | ||
var ipv6 bool | ||
var ipv4, ipv6 bool | ||
options := createOptions{ | ||
driverOpts: *opts.NewMapOpts(nil, nil), | ||
labels: opts.NewListOpts(opts.ValidateLabel), | ||
|
@@ -59,6 +60,9 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command { | |
RunE: func(cmd *cobra.Command, args []string) error { | ||
options.name = args[0] | ||
|
||
if cmd.Flag("ipv4").Changed { | ||
options.ipv4 = &ipv4 | ||
} | ||
if cmd.Flag("ipv6").Changed { | ||
options.ipv6 = &ipv6 | ||
} | ||
|
@@ -73,7 +77,8 @@ 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(&ipv6, "ipv6", false, "Enable or disable IPv6 networking") | ||
flags.BoolVar(&ipv4, "ipv4", true, "Enable or disable IPv4 address assignment") | ||
flags.BoolVar(&ipv6, "ipv6", false, "Enable or disable IPv6 address assignment") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 for the revised help text. |
||
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") | ||
|
@@ -113,6 +118,7 @@ func runCreate(ctx context.Context, apiClient client.NetworkAPIClient, output io | |
Options: options.driverOpts.GetAll(), | ||
IPAM: ipamCfg, | ||
Internal: options.internal, | ||
EnableIPv4: options.ipv4, | ||
EnableIPv6: options.ipv6, | ||
Attachable: options.attachable, | ||
Ingress: options.ingress, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we should force this to
true
on the CLI side.The
EnableIPv4
is*bool
on the API side, so we could just keep it as missing/null
if user haven't passed this option.For example if in future we'd need to distinguish between "user explicitly doesn't want ipv4" or "user doesn't care" on the daemon side.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, I just wrote a blurb below about "defaults".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just above, lines 63-65 (copied from the IPv6 setting), the pointer in the API request is only set if the CLI flag is
Changed
... so I think it's ok?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, I missed that!