getEnvironment gets the environments.
(ctx context.Context, id string)
| 12 | |
| 13 | // getEnvironment gets the environments. |
| 14 | func (ctl *controller) getEnvironment(ctx context.Context, id string) (*v1pb.EnvironmentSetting_Environment, error) { |
| 15 | resp, err := ctl.settingServiceClient.GetSetting(ctx, |
| 16 | connect.NewRequest(&v1pb.GetSettingRequest{ |
| 17 | Name: "settings/" + v1pb.Setting_ENVIRONMENT.String(), |
| 18 | })) |
| 19 | if err != nil { |
| 20 | return nil, err |
| 21 | } |
| 22 | for _, environment := range resp.Msg.Value.GetEnvironment().GetEnvironments() { |
| 23 | if environment.Id == id { |
| 24 | return environment, nil |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | return nil, errors.Errorf("environment %q not found", id) |
| 29 | } |
| 30 | |
| 31 | // createEnvironment creates a new environment. |
| 32 | // The created environment will be appended to the existing environments. |