| 150 | } |
| 151 | |
| 152 | func 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 | |
| 174 | Your available container ` |
| 175 | if len(containerTypes) > 1 { |
| 176 | errMessage += "types are" |
| 177 | } else { |
| 178 | errMessage += "type is" |
| 179 | } |
| 180 | errMessage += ": " + containerTypesName + `. |
| 181 | |
| 182 | Example of usage: |
| 183 | scalingo --app my-app scale web:2 worker:1 |
| 184 | scalingo --app my-app scale web:1:XL |
| 185 | scalingo --app my-app scale web:+1 worker:-1 |
| 186 | |
| 187 | Use 'scalingo scale --help' for more information` |
| 188 | return errors.New(ctx, errMessage) |
| 189 | } |
| 190 | |
| 191 | func autoscaleDisableMessage(typesWithAutoscaler []string) string { |
| 192 | if len(typesWithAutoscaler) <= 0 { |