(ctx context.Context, app string)
| 13 | ) |
| 14 | |
| 15 | func ContainerTypes(ctx context.Context, app string) error { |
| 16 | c, err := config.ScalingoClient(ctx) |
| 17 | if err != nil { |
| 18 | return errors.Wrapf(ctx, err, "fail to get Scalingo client to list container types") |
| 19 | } |
| 20 | |
| 21 | containerTypes, err := c.AppsContainerTypes(ctx, app) |
| 22 | if err != nil { |
| 23 | return errors.Wrapf(ctx, err, "fail to list the application container types") |
| 24 | } |
| 25 | |
| 26 | t := tablewriter.NewWriter(os.Stdout) |
| 27 | t.Header([]string{"Name", "Amount", "Size", "Command"}) |
| 28 | |
| 29 | hasAutoscaler := false |
| 30 | autoscalers, err := c.AutoscalersList(ctx, app) |
| 31 | if err != nil { |
| 32 | return errors.Wrapf(ctx, err, "fail to list the autoscalers") |
| 33 | } |
| 34 | |
| 35 | for _, containerType := range containerTypes { |
| 36 | name := containerType.Name |
| 37 | |
| 38 | for _, a := range autoscalers { |
| 39 | if a.ContainerType == containerType.Name { |
| 40 | hasAutoscaler = true |
| 41 | name += " (*)" |
| 42 | break |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | amount := strconv.Itoa(containerType.Amount) |
| 47 | if containerType.Command != "" { |
| 48 | t.Append([]string{name, amount, containerType.Size, "`" + containerType.Command + "`"}) |
| 49 | } else { |
| 50 | t.Append([]string{name, amount, containerType.Size, "-"}) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | t.Render() |
| 55 | |
| 56 | if hasAutoscaler { |
| 57 | fmt.Println(" (*) has an autoscaler defined") |
| 58 | } |
| 59 | |
| 60 | return nil |
| 61 | } |
no test coverage detected