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

Function Delete

env/edit.go:62–92  ·  view source on GitHub ↗
(ctx context.Context, app string, varNames []string)

Source from the content-addressed store, hash-verified

60}
61
62func Delete(ctx context.Context, app string, varNames []string) error {
63 c, err := config.ScalingoClient(ctx)
64 if err != nil {
65 return errors.Wrapf(ctx, err, "get Scalingo client")
66 }
67 vars, err := c.VariablesList(ctx, app)
68 if err != nil {
69 return errors.Wrapf(ctx, err, "list variables before deletion")
70 }
71
72 var varsToUnset scalingo.Variables
73
74 for _, varName := range varNames {
75 v, ok := vars.Contains(varName)
76 if !ok {
77 return errors.Newf(ctx, "%s variable does not exist", varName)
78 }
79 varsToUnset = append(varsToUnset, v)
80 }
81
82 for _, v := range varsToUnset {
83 err := c.VariableUnset(ctx, app, v.ID)
84 if err != nil {
85 return errors.Wrapf(ctx, err, "unset variable %s", v.Name)
86 }
87 fmt.Printf("%s has been unset.\n", v.Name)
88 }
89 fmt.Println("\nRestart your containers to apply these environment changes on your application:")
90 fmt.Printf("scalingo --app %s restart\n", app)
91 return nil
92}
93
94func isEnvEditValid(edit string) error {
95 if !strings.Contains(edit, "=") {

Callers 1

env.goFile · 0.92

Calls 1

ScalingoClientFunction · 0.92

Tested by

no test coverage detected