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

Method setAPI

command/v7/api_command.go:53–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51}
52
53func (cmd *APICommand) setAPI() error {
54 cmd.UI.DisplayTextWithFlavor("Setting API endpoint to {{.Endpoint}}...", map[string]interface{}{
55 "Endpoint": cmd.OptionalArgs.URL,
56 })
57
58 apiURL := cmd.processURL(cmd.OptionalArgs.URL)
59
60 _, err := cmd.Actor.SetTarget(v7action.TargetSettings{
61 URL: apiURL,
62 SkipSSLValidation: cmd.SkipSSLValidation,
63 DialTimeout: cmd.Config.DialTimeout(),
64 })
65 if err != nil {
66 return err
67 }
68
69 if strings.HasPrefix(apiURL, "http:") {
70 cmd.UI.DisplayText("Warning: Insecure http API endpoint detected: secure https API endpoints are recommended")
71 }
72
73 cmd.UI.DisplayOK()
74 return cmd.displayTarget()
75}
76
77func (cmd *APICommand) processURL(apiURL string) string {
78 if !strings.HasPrefix(apiURL, "http") {

Callers 1

ExecuteMethod · 0.95

Calls 7

processURLMethod · 0.95
displayTargetMethod · 0.95
DisplayTextWithFlavorMethod · 0.65
SetTargetMethod · 0.65
DialTimeoutMethod · 0.65
DisplayTextMethod · 0.65
DisplayOKMethod · 0.65

Tested by

no test coverage detected