MCPcopy Create free account
hub / github.com/Scalingo/cli / formatContainerTypesError

Function formatContainerTypesError

apps/scale.go:152–189  ·  view source on GitHub ↗
(ctx context.Context, c *scalingo.Client, app string, requestFailedError *http.RequestFailedError)

Source from the content-addressed store, hash-verified

150}
151
152func formatContainerTypesError(ctx context.Context, c *scalingo.Client, app string, requestFailedError *http.RequestFailedError) error {
153 containerTypes, err := c.AppsContainerTypes(ctx, app)
154 if err != nil {
155 debug.Println("Failed to get container types: " + err.Error())
156 return requestFailedError
157 }
158
159 if len(containerTypes) == 0 {
160 return errors.New(ctx, "You have no container type yet.\nPlease refer to the documentation to deploy your application.")
161 }
162
163 var containerTypesName string
164 for _, containerType := range containerTypes {
165 if containerTypesName == "" {
166 containerTypesName = "'" + containerType.Name + "'"
167 continue
168 }
169 containerTypesName = containerTypesName + ", '" + containerType.Name + "'"
170 }
171
172 errMessage := requestFailedError.APIError.Error() + `
173
174Your available container `
175 if len(containerTypes) > 1 {
176 errMessage += "types are"
177 } else {
178 errMessage += "type is"
179 }
180 errMessage += ": " + containerTypesName + `.
181
182Example of usage:
183scalingo --app my-app scale web:2 worker:1
184scalingo --app my-app scale web:1:XL
185scalingo --app my-app scale web:+1 worker:-1
186
187Use 'scalingo scale --help' for more information`
188 return errors.New(ctx, errMessage)
189}
190
191func autoscaleDisableMessage(typesWithAutoscaler []string) string {
192 if len(typesWithAutoscaler) <= 0 {

Callers 1

ScaleFunction · 0.85

Calls 1

ErrorMethod · 0.80

Tested by

no test coverage detected