| 25 | } |
| 26 | |
| 27 | func Get(ctx context.Context, appName, variableName string) (string, error) { |
| 28 | c, err := config.ScalingoClient(ctx) |
| 29 | if err != nil { |
| 30 | return "", errors.Wrapf(ctx, err, "fail to get Scalingo client to get an environment variable") |
| 31 | } |
| 32 | vars, err := c.VariablesListWithoutAlias(ctx, appName) |
| 33 | if err != nil { |
| 34 | return "", errors.Wrapf(ctx, err, "fail to list the environment variables") |
| 35 | } |
| 36 | |
| 37 | for _, v := range vars { |
| 38 | if v.Name == variableName { |
| 39 | return v.Value, nil |
| 40 | } |
| 41 | } |
| 42 | return "", errors.New(ctx, "environment variable not found") |
| 43 | } |