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

Function handleRegionDisabledError

apps/create.go:52–78  ·  view source on GitHub ↗
(ctx context.Context, appName string, c *scalingo.Client)

Source from the content-addressed store, hash-verified

50}
51
52func handleRegionDisabledError(ctx context.Context, appName string, c *scalingo.Client) error {
53 regions, rerr := c.RegionsList(ctx)
54 if rerr != nil {
55 return errors.Wrapf(ctx, rerr, "region is disabled, failed to list available regions")
56 }
57 if len(regions) <= 1 {
58 return errors.New(ctx, "region is disabled and there is no other available region")
59 }
60 firstRegion := regions[0]
61 if firstRegion.Name == config.C.ScalingoRegion {
62 firstRegion = regions[1]
63 }
64
65 fmt.Printf("Application creation has been disabled on the currently used region: %v\n\n", config.C.ScalingoRegion)
66 fmt.Printf("Either configure your CLI to use another default region, then create your application:\n")
67 fmt.Printf(" scalingo config --region %s\n scalingo create %s\n", firstRegion.Name, appName)
68 fmt.Printf("\nOr use the region flag to specify the region explicitly for this command:\n")
69 fmt.Printf(" scalingo --region %s create %s\n", firstRegion.Name, appName)
70 fmt.Printf("\nList of available regions:\n")
71 for _, region := range regions {
72 if region.Name == config.C.ScalingoRegion {
73 continue
74 }
75 fmt.Printf("- %v (%v)\n", region.Name, region.DisplayName)
76 }
77 return nil
78}

Callers 1

CreateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected