MCPcopy
hub / github.com/cloudfoundry/cli / scaleProcess

Method scaleProcess

command/v7/scale_command.go:91–137  ·  view source on GitHub ↗
(appGUID string, username string)

Source from the content-addressed store, hash-verified

89}
90
91func (cmd ScaleCommand) scaleProcess(appGUID string, username string) (bool, error) {
92 cmd.UI.DisplayTextWithFlavor("Scaling app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{
93 "AppName": cmd.RequiredArgs.AppName,
94 "OrgName": cmd.Config.TargetedOrganization().Name,
95 "SpaceName": cmd.Config.TargetedSpace().Name,
96 "Username": username,
97 })
98 cmd.UI.DisplayNewline()
99
100 shouldRestart := cmd.shouldRestart()
101 if shouldRestart && !cmd.Force {
102 shouldScale, err := cmd.UI.DisplayBoolPrompt(
103 false,
104 "This will cause the app to restart. Are you sure you want to scale {{.AppName}}?",
105 map[string]interface{}{"AppName": cmd.RequiredArgs.AppName})
106 if err != nil {
107 return false, err
108 }
109
110 if !shouldScale {
111 cmd.UI.DisplayText("Scaling cancelled")
112 return false, nil
113 }
114 cmd.UI.DisplayNewline()
115 }
116
117 warnings, err := cmd.Actor.ScaleProcessByApplication(appGUID, resources.Process{
118 Type: cmd.ProcessType,
119 Instances: cmd.Instances.NullInt,
120 MemoryInMB: cmd.MemoryLimit.NullUint64,
121 DiskInMB: cmd.DiskLimit.NullUint64,
122 LogRateLimitInBPS: types.NullInt(cmd.LogRateLimit),
123 })
124 cmd.UI.DisplayWarnings(warnings)
125 if err != nil {
126 return false, err
127 }
128
129 if shouldRestart {
130 err := cmd.restartApplication(appGUID, username)
131 if err != nil {
132 return false, err
133 }
134 }
135
136 return true, nil
137}
138
139func (cmd ScaleCommand) restartApplication(appGUID string, username string) error {
140 cmd.UI.DisplayTextWithFlavor("Stopping app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{

Callers 1

ExecuteMethod · 0.95

Calls 11

shouldRestartMethod · 0.95
restartApplicationMethod · 0.95
NullIntStruct · 0.92
DisplayTextWithFlavorMethod · 0.65
TargetedOrganizationMethod · 0.65
TargetedSpaceMethod · 0.65
DisplayNewlineMethod · 0.65
DisplayBoolPromptMethod · 0.65
DisplayTextMethod · 0.65
DisplayWarningsMethod · 0.65

Tested by

no test coverage detected