()
| 51 | } |
| 52 | |
| 53 | func (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 | |
| 77 | func (cmd *APICommand) processURL(apiURL string) string { |
| 78 | if !strings.HasPrefix(apiURL, "http") { |
no test coverage detected