(envName string, operatorEndpoint string, disallowPrompt bool, printToStdout bool)
| 1146 | } |
| 1147 | |
| 1148 | func updateCLIEnv(envName string, operatorEndpoint string, disallowPrompt bool, printToStdout bool) error { |
| 1149 | prevEnv, err := readEnv(envName) |
| 1150 | if err != nil { |
| 1151 | return err |
| 1152 | } |
| 1153 | |
| 1154 | newEnvironment := cliconfig.Environment{ |
| 1155 | Name: envName, |
| 1156 | OperatorEndpoint: operatorEndpoint, |
| 1157 | } |
| 1158 | |
| 1159 | shouldWriteEnv := false |
| 1160 | envWasUpdated := false |
| 1161 | if prevEnv == nil { |
| 1162 | shouldWriteEnv = true |
| 1163 | if printToStdout { |
| 1164 | fmt.Println() |
| 1165 | } |
| 1166 | } else if prevEnv.OperatorEndpoint != operatorEndpoint { |
| 1167 | envWasUpdated = true |
| 1168 | if printToStdout { |
| 1169 | if disallowPrompt { |
| 1170 | shouldWriteEnv = true |
| 1171 | fmt.Println() |
| 1172 | } else { |
| 1173 | shouldWriteEnv = prompt.YesOrNo(fmt.Sprintf("\nfound an existing environment named \"%s\"; would you like to overwrite it to connect to this cluster?", envName), "", "") |
| 1174 | } |
| 1175 | } else { |
| 1176 | shouldWriteEnv = true |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | if shouldWriteEnv { |
| 1181 | err := addEnvToCLIConfig(newEnvironment, true) |
| 1182 | if err != nil { |
| 1183 | return err |
| 1184 | } |
| 1185 | |
| 1186 | if printToStdout { |
| 1187 | if envWasUpdated { |
| 1188 | fmt.Printf(console.Bold("the environment named \"%s\" has been updated to point to this cluster (and was set as the default environment)\n"), envName) |
| 1189 | } else { |
| 1190 | fmt.Printf(console.Bold("an environment named \"%s\" has been configured to point to this cluster (and was set as the default environment)\n"), envName) |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | return nil |
| 1196 | } |
| 1197 | |
| 1198 | func cmdDebug(awsClient *awslib.Client, accessConfig *clusterconfig.AccessConfig) { |
| 1199 | // note: if modifying this string, also change it in files.IgnoreCortexDebug() |
no test coverage detected