MCPcopy Index your code
hub / github.com/cortexlabs/cortex / renameEnv

Function renameEnv

cli/cmd/lib_cli_config.go:302–334  ·  view source on GitHub ↗
(oldEnvName string, newEnvName string)

Source from the content-addressed store, hash-verified

300}
301
302func renameEnv(oldEnvName string, newEnvName string) error {
303 cliConfig, err := readCLIConfig()
304 if err != nil {
305 return err
306 }
307
308 renamedEnv := false
309
310 for _, env := range cliConfig.Environments {
311 if env.Name == newEnvName {
312 return cliconfig.ErrorEnvironmentAlreadyConfigured(newEnvName)
313 }
314
315 if env.Name == oldEnvName {
316 env.Name = newEnvName
317 renamedEnv = true
318 }
319 }
320
321 if !renamedEnv {
322 return cliconfig.ErrorEnvironmentNotConfigured(oldEnvName)
323 }
324
325 if cliConfig.DefaultEnvironment != nil && *cliConfig.DefaultEnvironment == oldEnvName {
326 cliConfig.DefaultEnvironment = &newEnvName
327 }
328
329 if err := writeCLIConfig(cliConfig); err != nil {
330 return err
331 }
332
333 return nil
334}
335
336func readTelemetryConfig() (bool, error) {
337 cliConfig, err := readCLIConfig()

Callers 1

env.goFile · 0.85

Calls 4

readCLIConfigFunction · 0.85
writeCLIConfigFunction · 0.85

Tested by

no test coverage detected