Skip to content

Commit

Permalink
Merge pull request #102 from Scalingo/vertical_scaling
Browse files Browse the repository at this point in the history
Integrate vertical scaling in 'scalingo scale' command
  • Loading branch information
Soulou committed Apr 15, 2015
2 parents a1103d1 + 417057d commit af060af
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Changelog
=========

### v1.0.0-beta2 - ToBeReleased
### v1.0.0-rc1 - ToBeReleased

* Fix domain-add issue. (error about domain.crt file) - Fixed #98
* Correctly handle db-tunnel when alias is given as argument - Fixed #93
* [Feature] Modify size of containers with `scalingo scale` - #102
* [Bugfix] Fix ssh-agent error when no private key is available - Fixed #100
* [Bugfix] Fix domain-add issue. (error about domain.crt file) - Fixed #98
* [Bugfix] Correctly handle db-tunnel when alias is given as argument - Fixed #93

### v1.0.0-beta1 - 08/03/2015

Expand Down
1 change: 1 addition & 0 deletions api/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Container struct {
Name string `json:"name"`
Amount int `json:"amount"`
Command string `json:"command"`
Size string `json:"size"`
}

type AppsScaleParams struct {
Expand Down
6 changes: 3 additions & 3 deletions apps/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ func Ps(app string) error {
}

t := tablewriter.NewWriter(os.Stdout)
t.SetHeader([]string{"Name", "Amount", "Command"})
t.SetHeader([]string{"Name", "Amount", "Size", "Command"})

for _, ct := range processes {
amount := fmt.Sprintf("%d", ct.Amount)
if ct.Command != "" {
t.Append([]string{ct.Name, amount, "`" + ct.Command + "`"})
t.Append([]string{ct.Name, amount, ct.Size, "`" + ct.Command + "`"})
} else {
t.Append([]string{ct.Name, amount, "-"})
t.Append([]string{ct.Name, amount, ct.Size, "-"})
}
}

Expand Down
13 changes: 9 additions & 4 deletions apps/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ type ScaleRes struct {
}

func Scale(app string, sync bool, types []string) error {
var size string
scaleParams := &api.AppsScaleParams{}

for _, t := range types {
splitT := strings.Split(t, ":")
if len(splitT) != 2 {
return errgo.Newf("%s is invalid, format is <type>:<amount>", t)
if len(splitT) != 2 && len(splitT) != 3 {
return errgo.Newf("%s is invalid, format is <type>:<amount>[:<size>]", t)
}
typeName, typeAmount := splitT[0], splitT[1]
if len(splitT) == 3 {
size = splitT[2]
}

amount, err := strconv.ParseInt(typeAmount, 10, 32)
if err != nil {
return errgo.Newf("%s in %s should be an integer", typeAmount, t)
}
scaleParams.Containers = append(scaleParams.Containers, api.Container{Name: typeName, Amount: int(amount)})
scaleParams.Containers = append(scaleParams.Containers, api.Container{Name: typeName, Amount: int(amount), Size: size})
}

res, err := api.AppsScale(app, scaleParams)
Expand All @@ -46,7 +51,7 @@ func Scale(app string, sync bool, types []string) error {

fmt.Printf("You application is being scaled to:\n")
for _, ct := range scaleRes.Containers {
fmt.Println(io.Indent(fmt.Sprintf("%s: %d", ct.Name, ct.Amount), 2))
fmt.Println(io.Indent(fmt.Sprintf("%s: %d - %s", ct.Name, ct.Amount, ct.Size), 2))
}

if !sync {
Expand Down
3 changes: 2 additions & 1 deletion cmd/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var (
Description: `Scale your application processes.
Example
'scalingo --app my-app scale web:2 worker:1'
'scalingo --app my-app scale web:1 worker:0'`,
'scalingo --app my-app scale web:1 worker:0'
'scalingo --app my-app scale web:1:XL'`,
Action: func(c *cli.Context) {
currentApp := appdetect.CurrentApp(c)
if len(c.Args()) == 0 {
Expand Down

0 comments on commit af060af

Please sign in to comment.