(ctx context.Context)
| 11 | ) |
| 12 | |
| 13 | func AddonsAddAutoComplete(ctx context.Context) error { |
| 14 | client, err := config.ScalingoClient(ctx) |
| 15 | if err != nil { |
| 16 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 17 | } |
| 18 | resources, err := client.AddonProvidersList(ctx) |
| 19 | if len(os.Args) > 1 && err == nil { |
| 20 | lastArg := os.Args[len(os.Args)-2] |
| 21 | isAddonNameSet := false |
| 22 | |
| 23 | for _, resource := range resources { |
| 24 | if lastArg == resource.ID { |
| 25 | isAddonNameSet = true |
| 26 | break |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | if isAddonNameSet { |
| 31 | plans, err := client.AddonProviderPlansList(ctx, lastArg, scalingo.AddonProviderPlansListOpts{}) |
| 32 | |
| 33 | if err == nil { |
| 34 | for _, plan := range plans { |
| 35 | fmt.Println(plan.Name) |
| 36 | } |
| 37 | } |
| 38 | } else { |
| 39 | for _, resource := range resources { |
| 40 | fmt.Println(resource.ID) |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return nil |
| 46 | } |
no test coverage detected