Skip to content

Commit

Permalink
Merge branch 'master' into update-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
arxdsilva committed Jun 13, 2017
2 parents 39775d8 + 01a7bba commit ea60508
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/cmds.json
Expand Up @@ -256,8 +256,8 @@
"desc": "Creates a new machine template.\n\nTemplates can be used with the [[docker-node-add]] command running it with\nthe [[template=<template name>]] parameter. Templates can contain a list of\nparameters that will be sent to the IaaS provider.\n\nMinimum # of arguments: 3\n"
},
"app-update": {
"usage": "tsuru app-update [-a/--app appname] [--description/-d description] [--plan/-p plan name] [--router/-r router name] [--pool/-o pool] [--team-owner/-t team owner] [--tag/-g tag]...",
"desc": "Updates an app, changing its description, tags, plan or pool information.\n\nThe [[--description]] parameter sets a description for your app.\n\nThe [[--plan]] parameter changes the plan of your app.\n\nThe [[--router]] parameter changes the router of your app.\n\nThe [[--pool]] parameter changes the pool of your app.\n\nThe [[--team-owner]] parameter sets owner team for an application.\n\nThe [[--tag]] parameter sets a tag for your app. You can set\nmultiple [[--tag]] parameters.\n\nFlags:\n \n -a, --app (= \"\")\n The name of the app.\n -d, --description (= \"\")\n App description\n -g, --tag (= [])\n App tag\n -o, --pool (= \"\")\n App pool\n -p, --plan (= \"\")\n App plan\n -r, --router (= \"\")\n App router\n -t, --team-owner (= \"\")\n App team owner\n \n"
"usage": "tsuru app-update [-a/--app appname] [--description/-d description] [--plan/-p plan name] [--router/-r router name] [--pool/-o pool] [--team-owner/-t team owner] [-i/--image-reset] [--tag/-g tag]...",
"desc": "Updates an app, changing its description, tags, plan or pool information.\n\nThe [[--description]] parameter sets a description for your app.\n\nThe [[--plan]] parameter changes the plan of your app.\n\nThe [[--router]] parameter changes the router of your app.\n\nThe [[--pool]] parameter changes the pool of your app.\n\nThe [[--team-owner]] parameter sets owner team for an application.\n\nThe [[--tag]] parameter sets a tag for your app. You can set\nmultiple [[--tag]] parameters.\n\nFlags:\n \n -a, --app (= \"\")\n The name of the app.\n -d, --description (= \"\")\n App description\n -g, --tag (= [])\n App tag\n -i, --image-reset (= false)\n Forces next deploy to build app image\n -o, --pool (= \"\")\n App pool\n -p, --plan (= \"\")\n App plan\n -r, --router (= \"\")\n App router\n -t, --team-owner (= \"\")\n App team owner\n \n"
},
"role-dissociate": {
"usage": "tsuru role-dissociate <role-name> <user-email> [<context-value>]",
Expand Down
8 changes: 7 additions & 1 deletion tsuru/client/apps.go
Expand Up @@ -14,6 +14,7 @@ import (
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -168,6 +169,7 @@ type AppUpdate struct {
router string
pool string
teamOwner string
imageReset bool
tags cmd.StringSliceFlag
fs *gnuflag.FlagSet
cmd.GuessingCommand
Expand All @@ -177,7 +179,7 @@ type AppUpdate struct {
func (c *AppUpdate) Info() *cmd.Info {
return &cmd.Info{
Name: "app-update",
Usage: "app-update [-a/--app appname] [--description/-d description] [--plan/-p plan name] [--router/-r router name] [--pool/-o pool] [--team-owner/-t team owner] [--platform/-f platform] [--tag/-g tag]...",
Usage: "app-update [-a/--app appname] [--description/-d description] [--plan/-p plan name] [--router/-r router name] [--pool/-o pool] [--team-owner/-t team owner] [--platform/-f platform] [-i/--image-reset] [--tag/-g tag]...",
Desc: `Updates an app, changing its description, tags, plan or pool information.
The [[--description]] parameter sets a description for your app.
Expand Down Expand Up @@ -205,6 +207,7 @@ func (c *AppUpdate) Flags() *gnuflag.FlagSet {
teamOwnerMessage := "App team owner"
tagMessage := "App tag"
platformMsg := "App platform"
imgReset := "Forces next deploy to build app image from scratch"
flagSet.StringVar(&c.description, "description", "", descriptionMessage)
flagSet.StringVar(&c.description, "d", "", descriptionMessage)
flagSet.StringVar(&c.plan, "plan", "", planMessage)
Expand All @@ -215,6 +218,8 @@ func (c *AppUpdate) Flags() *gnuflag.FlagSet {
flagSet.StringVar(&c.router, "r", "", routerMessage)
flagSet.StringVar(&c.pool, "o", "", poolMessage)
flagSet.StringVar(&c.pool, "pool", "", poolMessage)
flagSet.BoolVar(&c.imageReset, "i", false, imgReset)
flagSet.BoolVar(&c.imageReset, "image-reset", false, imgReset)
flagSet.StringVar(&c.teamOwner, "t", "", teamOwnerMessage)
flagSet.StringVar(&c.teamOwner, "team-owner", "", teamOwnerMessage)
flagSet.Var(&c.tags, "g", tagMessage)
Expand Down Expand Up @@ -244,6 +249,7 @@ func (c *AppUpdate) Run(context *cmd.Context, client *cmd.Client) error {
v.Set("pool", c.pool)
v.Set("teamOwner", c.teamOwner)
v.Set("platform", c.platform)
v.Set("imageReset", strconv.FormatBool(c.imageReset))
for _, tag := range c.tags {
v.Add("tag", tag)
}
Expand Down
25 changes: 25 additions & 0 deletions tsuru/client/apps_test.go
Expand Up @@ -435,6 +435,31 @@ func (s *S) TestAppUpdate(c *check.C) {
c.Assert(stdout.String(), check.Equals, expected)
}

func (s *S) TestAppUpdateImageReset(c *check.C) {
var stdout, stderr bytes.Buffer
expected := fmt.Sprintf("App %q has been updated!\n", "img")
context := cmd.Context{
Stdout: &stdout,
Stderr: &stderr,
}
trans := &cmdtest.ConditionalTransport{
Transport: cmdtest.Transport{Status: http.StatusOK},
CondFunc: func(req *http.Request) bool {
url := strings.HasSuffix(req.URL.Path, "/apps/img")
method := req.Method == "PUT"
imageReset := req.FormValue("imageReset") == "true"
req.ParseForm()
return url && method && imageReset
},
}
client := cmd.NewClient(&http.Client{Transport: trans}, nil, manager)
command := AppUpdate{}
command.Flags().Parse(true, []string{"-a", "img", "-i"})
err := command.Run(&context, client)
c.Assert(err, check.IsNil)
c.Assert(stdout.String(), check.Equals, expected)
}

func (s *S) TestAppUpdateWithoutTags(c *check.C) {
var stdout, stderr bytes.Buffer
expected := fmt.Sprintf("App %q has been updated!\n", "ble")
Expand Down

0 comments on commit ea60508

Please sign in to comment.