MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / PromptForEnvironmentV1

Function PromptForEnvironmentV1

pkg/cmd/tenant/variables/update/update.go:424–447  ·  view source on GitHub ↗
(opts *UpdateOptions, variables *variables.TenantVariables)

Source from the content-addressed store, hash-verified

422}
423
424func PromptForEnvironmentV1(opts *UpdateOptions, variables *variables.TenantVariables) error {
425 if len(opts.Environments.Value) == 0 {
426 var environmentSelections []*selectors.SelectOption[string]
427 environmentMap, err := getEnvironmentMap(opts.GetAllEnvironmentsCallback)
428 if err != nil {
429 return err
430 }
431
432 for _, p := range variables.ProjectVariables {
433 if strings.EqualFold(p.ProjectName, opts.Project.Value) {
434 for k, _ := range p.Variables {
435 environmentSelections = append(environmentSelections, selectors.NewSelectOption[string](environmentMap[k], environmentMap[k]))
436 }
437 }
438 }
439
440 selectedEnvironment, err := selectors.SelectOptions(opts.Ask, "You have not specified an environment", func() []*selectors.SelectOption[string] { return environmentSelections })
441 if err != nil {
442 return err
443 }
444 opts.Environments.Value = append(opts.Environments.Value, selectedEnvironment.Value)
445 }
446 return nil
447}
448
449func PromptForEnvironments(opts *UpdateOptions) error {
450 if len(opts.Environments.Value) == 0 {

Callers 1

PromptMissingV1Function · 0.85

Calls 2

SelectOptionsFunction · 0.92
getEnvironmentMapFunction · 0.70

Tested by

no test coverage detected