Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 522bf3c

Browse files
committed
fip with name
1 parent a94e549 commit 522bf3c

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

api/client/fip.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,39 @@ func (cli *DockerCli) CmdFipLs(args ...string) error {
188188
return err
189189
}
190190
w := tabwriter.NewWriter(cli.out, 20, 1, 3, ' ', 0)
191-
fmt.Fprintf(w, "Floating IP\tContainer\tService\n")
191+
fmt.Fprintf(w, "Floating IP\tName\tContainer\tService\n")
192192
for _, fip := range fips {
193-
fmt.Fprintf(w, "%s\t%s\t%s\n", fip["fip"], fip["container"], fip["service"])
193+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", fip["fip"], fip["name"], fip["container"], fip["service"])
194194
}
195195

196196
w.Flush()
197197
return nil
198198
}
199199

200+
func (cli *DockerCli) CmdFipName(args ...string) error {
201+
cmd := Cli.Subcmd("fip name", []string{"FIP [NAME]"}, "Set a name for a floating IP", false)
202+
//force := cmd.Bool([]string{"f", "-force"}, false, "Force the container to disconnect from a floating IP")
203+
cmd.Require(flag.Min, 1)
204+
cmd.Require(flag.Max, 2)
205+
if err := cmd.ParseFlags(args, true); err != nil {
206+
return err
207+
}
208+
209+
err := cli.client.FipName(context.Background(), cmd.Arg(0), cmd.Arg(1))
210+
if err != nil {
211+
return err
212+
}
213+
return nil
214+
}
215+
200216
func fipUsage() string {
201217
fipCommands := [][]string{
202218
{"allocate", "Allocate a or some IPs"},
203219
{"attach", "Attach floating IP to container"},
204220
{"detach", "Detach floating IP from conainer"},
205221
{"ls", "List all floating IPs"},
206222
{"release", "Release a floating IP"},
223+
{"name", "Name a floating IP"},
207224
}
208225

209226
help := "Commands:\n"

vendor/src/github.com/docker/engine-api/client/fip.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@ func (cli *Client) FipList(ctx context.Context, options types.NetworkListOptions
7676
ensureReaderClosed(resp)
7777
return fips, err
7878
}
79+
80+
func (cli *Client) FipName(ctx context.Context, ip, name string) error {
81+
var v = url.Values{}
82+
v.Set("ip", ip)
83+
v.Set("name", name)
84+
resp, err := cli.post(ctx, "/fips/name", v, nil, nil)
85+
if err != nil {
86+
return err
87+
}
88+
ensureReaderClosed(resp)
89+
return nil
90+
}

vendor/src/github.com/docker/engine-api/client/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type APIClient interface {
9191
FipAttach(ctx context.Context, ip, container string) error
9292
FipDetach(ctx context.Context, container string) (string, error)
9393
FipList(ctx context.Context, opts types.NetworkListOptions) ([]map[string]string, error)
94+
FipName(ctx context.Context, ip, name string) error
9495

9596
SgCreate(ctx context.Context, name string, data io.Reader) error
9697
SgRm(ctx context.Context, name string) error

0 commit comments

Comments
 (0)