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

Function Set

stacks/set.go:12–43  ·  view source on GitHub ↗
(ctx context.Context, app string, stack string)

Source from the content-addressed store, hash-verified

10)
11
12func Set(ctx context.Context, app string, stack string) error {
13 c, err := config.ScalingoClient(ctx)
14 if err != nil {
15 return errors.Wrapf(ctx, err, "fail to get Scalingo client")
16 }
17 stacks, err := c.StacksList(ctx)
18 if err != nil {
19 return errors.Wrapf(ctx, err, "fail to list available stacks")
20 }
21
22 var stackToSet scalingo.Stack
23 for _, apistack := range stacks {
24 if apistack.Name == stack || apistack.ID == stack {
25 stackToSet = apistack
26 break
27 }
28 }
29
30 if stackToSet.ID == "" {
31 return errors.Newf(ctx, "stack '%v' is unknown.", stack)
32 }
33
34 _, err = c.AppsSetStack(ctx, app, stackToSet.ID)
35 if err != nil {
36 return errors.Wrapf(ctx, err, "fail to set stack %v (%v)", stackToSet.Name, stackToSet.ID)
37 }
38
39 io.Statusf("Stack of %v has been set to %v (%v)\n", io.Bold(app), io.Bold(stackToSet.Name), stackToSet.ID)
40 io.Infof(io.Gray("Deployment cache of %v has been reset\n"), app)
41
42 return nil
43}

Callers 1

stacks.goFile · 0.92

Calls 5

ScalingoClientFunction · 0.92
StatusfFunction · 0.92
BoldFunction · 0.92
InfofFunction · 0.92
GrayFunction · 0.92

Tested by

no test coverage detected