MCPcopy
hub / github.com/cloudfoundry/cli / determineAPIEndpoint

Method determineAPIEndpoint

command/v7/login_command.go:212–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

210}
211
212func (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
247func (cmd *LoginCommand) targetAPI(settings v7action.TargetSettings) error {
248 warnings, err := cmd.Actor.SetTarget(settings)

Callers 1

ExecuteMethod · 0.95

Calls 6

TargetMethod · 0.65
SkipSSLValidationMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
DisplayTextPromptMethod · 0.65
ParseMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected