(c flags.FlagContext)
| 77 | var bytesInAMegabyte int64 = 1024 * 1024 |
| 78 | |
| 79 | func (cmd *Scale) Execute(c flags.FlagContext) error { |
| 80 | currentApp := cmd.appReq.GetApplication() |
| 81 | if !anyFlagsSet(c) { |
| 82 | cmd.ui.Say(T("Showing current scale of app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...", |
| 83 | map[string]interface{}{ |
| 84 | "AppName": terminal.EntityNameColor(currentApp.Name), |
| 85 | "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name), |
| 86 | "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name), |
| 87 | "CurrentUser": terminal.EntityNameColor(cmd.config.Username()), |
| 88 | })) |
| 89 | cmd.ui.Ok() |
| 90 | cmd.ui.Say("") |
| 91 | |
| 92 | cmd.ui.Say("%s %s", terminal.HeaderColor(T("memory:")), formatters.ByteSize(currentApp.Memory*bytesInAMegabyte)) |
| 93 | cmd.ui.Say("%s %s", terminal.HeaderColor(T("disk:")), formatters.ByteSize(currentApp.DiskQuota*bytesInAMegabyte)) |
| 94 | cmd.ui.Say("%s %d", terminal.HeaderColor(T("instances:")), currentApp.InstanceCount) |
| 95 | |
| 96 | return nil |
| 97 | } |
| 98 | |
| 99 | params := models.AppParams{} |
| 100 | shouldRestart := false |
| 101 | |
| 102 | if c.String("m") != "" { |
| 103 | memory, err := formatters.ToMegabytes(c.String("m")) |
| 104 | if err != nil { |
| 105 | return errors.New(T("Invalid memory limit: {{.Memory}}\n{{.ErrorDescription}}", |
| 106 | map[string]interface{}{ |
| 107 | "Memory": c.String("m"), |
| 108 | "ErrorDescription": err, |
| 109 | })) |
| 110 | } |
| 111 | params.Memory = &memory |
| 112 | shouldRestart = true |
| 113 | } |
| 114 | |
| 115 | if c.String("k") != "" { |
| 116 | diskQuota, err := formatters.ToMegabytes(c.String("k")) |
| 117 | if err != nil { |
| 118 | return errors.New(T("Invalid disk quota: {{.DiskQuota}}\n{{.ErrorDescription}}", |
| 119 | map[string]interface{}{ |
| 120 | "DiskQuota": c.String("k"), |
| 121 | "ErrorDescription": err, |
| 122 | })) |
| 123 | } |
| 124 | params.DiskQuota = &diskQuota |
| 125 | shouldRestart = true |
| 126 | } |
| 127 | |
| 128 | if c.IsSet("i") { |
| 129 | instances := c.Int("i") |
| 130 | params.InstanceCount = &instances |
| 131 | } |
| 132 | |
| 133 | if shouldRestart && !cmd.confirmRestart(c, currentApp.Name) { |
| 134 | return nil |
| 135 | } |
| 136 |
nothing calls this directly
no test coverage detected