(c flags.FlagContext)
| 52 | } |
| 53 | |
| 54 | func (cmd API) Execute(c flags.FlagContext) error { |
| 55 | if c.Bool("unset") { |
| 56 | cmd.ui.Say(T("Unsetting api endpoint...")) |
| 57 | cmd.config.SetAPIEndpoint("") |
| 58 | |
| 59 | cmd.ui.Ok() |
| 60 | cmd.ui.Say(T("\nNo api endpoint set.")) |
| 61 | |
| 62 | } else if len(c.Args()) == 0 { |
| 63 | if cmd.config.APIEndpoint() == "" { |
| 64 | cmd.ui.Say(T("No api endpoint set. Use '{{.Name}}' to set an endpoint", |
| 65 | map[string]interface{}{"Name": terminal.CommandColor(cf.Name + " api")})) |
| 66 | } else { |
| 67 | cmd.ui.Say(T("API endpoint: {{.APIEndpoint}} (API version: {{.APIVersion}})", |
| 68 | map[string]interface{}{"APIEndpoint": terminal.EntityNameColor(cmd.config.APIEndpoint()), |
| 69 | "APIVersion": terminal.EntityNameColor(cmd.config.APIVersion())})) |
| 70 | } |
| 71 | } else { |
| 72 | endpoint := c.Args()[0] |
| 73 | |
| 74 | cmd.ui.Say(T("Setting api endpoint to {{.Endpoint}}...", |
| 75 | map[string]interface{}{"Endpoint": terminal.EntityNameColor(endpoint)})) |
| 76 | err := cmd.setAPIEndpoint(endpoint, c.Bool("skip-ssl-validation"), cmd.MetaData().Name) |
| 77 | if err != nil { |
| 78 | return err |
| 79 | } |
| 80 | cmd.ui.Ok() |
| 81 | |
| 82 | cmd.ui.Say("") |
| 83 | cmd.ui.ShowConfiguration(cmd.config) |
| 84 | } |
| 85 | return nil |
| 86 | } |
| 87 | |
| 88 | func (cmd API) setAPIEndpoint(endpoint string, skipSSL bool, cmdName string) error { |
| 89 | if strings.HasSuffix(endpoint, "/") { |
nothing calls this directly
no test coverage detected