Skip to content

Commit

Permalink
client: substitutes flag --enable for --disable
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur authored and arxdsilva committed Aug 17, 2017
1 parent 9486b06 commit 922b607
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions tsuru/client/deploy.go
Expand Up @@ -649,26 +649,26 @@ func (c *AppDeployRebuild) Run(context *cmd.Context, client *cmd.Client) error {

type AppDeployRollbackUpdate struct {
cmd.GuessingCommand
image string
reason string
enable bool
fs *gnuflag.FlagSet
image string
reason string
disable bool
fs *gnuflag.FlagSet
}

func (c *AppDeployRollbackUpdate) Info() *cmd.Info {
desc := `Locks an existing image of an app. You can list images with "tsuru app-deploy-list -a <appName>"
::
The [-e/--enable] flag enables or disables a rollback to an image, by default if not parsed it enables a rollback to an image, otherwise it'll disable it.
The [-i/--image] flag is the name of an app image.
The [-d/--disable] flag enables or disables a rollback to an image, by default if not parsed it enables a rollback to an image, otherwise it'll disable it.
The [-r/--reason] flag lets the user tell why this action was needed.
`
return &cmd.Info{
Name: "app-deploy-rollback-update",
Usage: "app-deploy-rollback-update [-a/--app appName] [-i/--image imageName] [-e/--enable] [-r/--reason message]",
Usage: "app-deploy-rollback-update [-a/--app appName] [-i/--image imageName] [-d/--disable] [-r/--reason reason]",
Desc: desc,
MinArgs: 0,
MaxArgs: 0,
Expand All @@ -684,9 +684,9 @@ func (c *AppDeployRollbackUpdate) Flags() *gnuflag.FlagSet {
reason := "A message describing this rollback"
c.fs.StringVar(&c.reason, "reason", "", reason)
c.fs.StringVar(&c.reason, "r", "", reason)
enable := "Enables or disables the rollback on a specific image version"
c.fs.BoolVar(&c.enable, "enable", false, enable)
c.fs.BoolVar(&c.enable, "e", false, enable)
disable := "Enables or disables the rollback on a specific image version"
c.fs.BoolVar(&c.disable, "disable", false, disable)
c.fs.BoolVar(&c.disable, "d", false, disable)
}
return c.fs
}
Expand All @@ -704,7 +704,7 @@ func (c *AppDeployRollbackUpdate) Run(context *cmd.Context, client *cmd.Client)
v.Set("image", c.image)
v.Set("reason", c.reason)
v.Set("origin", "rollback")
v.Set("enable", strconv.FormatBool(!c.enable))
v.Set("disable", strconv.FormatBool(c.disable))
request, err := http.NewRequest(http.MethodPut, u, strings.NewReader(v.Encode()))
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions tsuru/client/deploy_test.go
Expand Up @@ -513,8 +513,8 @@ func (s *S) TestAppDeployRollbackUpdate(c *check.C) {
called = true
method := req.Method == http.MethodPut
path := strings.HasSuffix(req.URL.Path, "/apps/zilean/deploy/rollback/update")
enable := req.FormValue("enable") == "true"
image := req.FormValue("image") == "caitlyn"
enable := req.FormValue("disable") == "false"
reason := req.FormValue("reason") == "DEMACIA"
rollback := req.FormValue("origin") == "rollback"
return method && path && image && rollback && reason && enable
Expand Down Expand Up @@ -549,15 +549,15 @@ func (s *S) TestAppDeployRollbackUpdateDisabling(c *check.C) {
method := req.Method == http.MethodPut
path := strings.HasSuffix(req.URL.Path, "/apps/xayah/deploy/rollback/update")
image := req.FormValue("image") == "rakan"
enable := req.FormValue("enable") == "false"
enable := req.FormValue("disable") == "true"
reason := req.FormValue("reason") == "vastayan"
rollback := req.FormValue("origin") == "rollback"
return method && path && image && rollback && reason && enable
},
}
client := cmd.NewClient(&http.Client{Transport: trans}, nil, manager)
command := AppDeployRollbackUpdate{}
command.Flags().Parse(true, []string{"--app", "xayah", "-i", "rakan", "-r", "vastayan", "-e"})
command.Flags().Parse(true, []string{"--app", "xayah", "-i", "rakan", "-r", "vastayan", "-d"})
err = command.Run(&context, client)
c.Assert(err, check.IsNil)
c.Assert(called, check.Equals, true)
Expand Down

0 comments on commit 922b607

Please sign in to comment.