()
| 210 | } |
| 211 | |
| 212 | func (cmd *LoginCommand) determineAPIEndpoint() (v7action.TargetSettings, error) { |
| 213 | endpoint := cmd.APIEndpoint |
| 214 | skipSSLValidation := cmd.SkipSSLValidation |
| 215 | |
| 216 | configTarget := cmd.Config.Target() |
| 217 | |
| 218 | if endpoint == "" && configTarget != "" { |
| 219 | endpoint = configTarget |
| 220 | skipSSLValidation = cmd.Config.SkipSSLValidation() || cmd.SkipSSLValidation |
| 221 | } |
| 222 | |
| 223 | if len(endpoint) > 0 { |
| 224 | cmd.UI.DisplayTextWithFlavor("API endpoint: {{.APIEndpoint}}", map[string]interface{}{ |
| 225 | "APIEndpoint": endpoint, |
| 226 | }) |
| 227 | } else { |
| 228 | userInput, err := cmd.UI.DisplayTextPrompt("API endpoint") |
| 229 | if err != nil { |
| 230 | return v7action.TargetSettings{}, err |
| 231 | } |
| 232 | endpoint = userInput |
| 233 | } |
| 234 | |
| 235 | strippedEndpoint := strings.TrimRight(endpoint, "/") |
| 236 | parsedURL, err := url.Parse(strippedEndpoint) |
| 237 | if err != nil { |
| 238 | return v7action.TargetSettings{}, err |
| 239 | } |
| 240 | if parsedURL.Scheme == "" { |
| 241 | parsedURL.Scheme = "https" |
| 242 | } |
| 243 | |
| 244 | return v7action.TargetSettings{URL: parsedURL.String(), SkipSSLValidation: skipSSLValidation}, nil |
| 245 | } |
| 246 | |
| 247 | func (cmd *LoginCommand) targetAPI(settings v7action.TargetSettings) error { |
| 248 | warnings, err := cmd.Actor.SetTarget(settings) |
no test coverage detected