MCPcopy
hub / github.com/cortexlabs/cortex / promptForExistingEnvName

Function promptForExistingEnvName

cli/cmd/lib_cli_config.go:126–157  ·  view source on GitHub ↗
(promptMsg string)

Source from the content-addressed store, hash-verified

124}
125
126func promptForExistingEnvName(promptMsg string) string {
127 configuredEnvNames, err := listConfiguredEnvNames()
128 if err != nil {
129 exit.Error(err)
130 }
131
132 fmt.Printf("your currently configured environments are: %s\n\n", strings.Join(configuredEnvNames, ", "))
133
134 envNameContainer := &struct {
135 EnvironmentName string
136 }{}
137
138 err = cr.ReadPrompt(envNameContainer, &cr.PromptValidation{
139 PromptItemValidations: []*cr.PromptItemValidation{
140 {
141 StructField: "EnvironmentName",
142 PromptOpts: &prompt.Options{
143 Prompt: promptMsg,
144 },
145 StringValidation: &cr.StringValidation{
146 Required: true,
147 AllowedValues: configuredEnvNames,
148 },
149 },
150 },
151 })
152 if err != nil {
153 exit.Error(err)
154 }
155
156 return envNameContainer.EnvironmentName
157}
158
159func promptEnv(env *cliconfig.Environment, defaults cliconfig.Environment) error {
160 if env.OperatorEndpoint == "" {

Callers 1

env.goFile · 0.85

Calls 2

ErrorFunction · 0.92
listConfiguredEnvNamesFunction · 0.85

Tested by

no test coverage detected