Merge pull request #5664 from akerouanton/gw-priority
run, create, connect: add support for gw-priority
This commit is contained in:
@ -858,7 +858,9 @@ func parseNetworkAttachmentOpt(ep opts.NetworkAttachmentOpts) (*networktypes.End
|
||||
}
|
||||
}
|
||||
|
||||
epConfig := &networktypes.EndpointSettings{}
|
||||
epConfig := &networktypes.EndpointSettings{
|
||||
GwPriority: ep.GwPriority,
|
||||
}
|
||||
epConfig.Aliases = append(epConfig.Aliases, ep.Aliases...)
|
||||
if len(ep.DriverOpts) > 0 {
|
||||
epConfig.DriverOpts = make(map[string]string)
|
||||
|
||||
@ -23,6 +23,7 @@ type connectOptions struct {
|
||||
aliases []string
|
||||
linklocalips []string
|
||||
driverOpts []string
|
||||
gwPriority int
|
||||
}
|
||||
|
||||
func newConnectCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
@ -55,6 +56,7 @@ func newConnectCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
flags.StringSliceVar(&options.aliases, "alias", []string{}, "Add network-scoped alias for the container")
|
||||
flags.StringSliceVar(&options.linklocalips, "link-local-ip", []string{}, "Add a link-local address for the container")
|
||||
flags.StringSliceVar(&options.driverOpts, "driver-opt", []string{}, "driver options for the network")
|
||||
flags.IntVar(&options.gwPriority, "gw-priority", 0, "Highest gw-priority provides the default gateway. Accepts positive and negative values.")
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -73,6 +75,7 @@ func runConnect(ctx context.Context, apiClient client.NetworkAPIClient, options
|
||||
Links: options.links.GetAll(),
|
||||
Aliases: options.aliases,
|
||||
DriverOpts: driverOpts,
|
||||
GwPriority: options.gwPriority,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ func TestNetworkConnectWithFlags(t *testing.T) {
|
||||
"driveropt1": "optval1,optval2",
|
||||
"driveropt2": "optval4",
|
||||
},
|
||||
GwPriority: 100,
|
||||
}
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
networkConnectFunc: func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
|
||||
@ -76,6 +77,7 @@ func TestNetworkConnectWithFlags(t *testing.T) {
|
||||
{"ip6", "fdef:f401:8da0:1234::5678"},
|
||||
{"link", "otherctr"},
|
||||
{"link-local-ip", "169.254.42.42"},
|
||||
{"gw-priority", "100"},
|
||||
} {
|
||||
err := cmd.Flags().Set(opt.name, opt.value)
|
||||
assert.Check(t, err)
|
||||
|
||||
Reference in New Issue
Block a user