AddOrReplaceEnvironment will update environment if it already exists or will add a new environment with the given environment name and details.
(env []string, newEnvName string, newEnvVal string)
| 13 | // AddOrReplaceEnvironment will update environment if it already exists or will add |
| 14 | // a new environment with the given environment name and details. |
| 15 | func AddOrReplaceEnvironment(env []string, newEnvName string, newEnvVal string) []string { |
| 16 | var found bool |
| 17 | for i, envPair := range env { |
| 18 | splitENV := strings.Split(envPair, "=") |
| 19 | if splitENV[0] == newEnvName { |
| 20 | env[i] = fmt.Sprintf("%s=%s", newEnvName, newEnvVal) |
| 21 | found = true |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | if !found { |
| 26 | env = append(env, fmt.Sprintf("%s=%s", newEnvName, newEnvVal)) |
| 27 | } |
| 28 | return env |
| 29 | } |
| 30 | |
| 31 | func CheckSpaceAndOrgTargetedCorrectly(command ...string) { |
| 32 | LoginCF() |