forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_endpoint.go
31 lines (27 loc) · 953 Bytes
/
api_endpoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package requirements
import (
"fmt"
"github.com/cloudfoundry/cli/cf"
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/terminal"
)
type ApiEndpointRequirement struct {
ui terminal.UI
config configuration.Reader
}
func NewApiEndpointRequirement(ui terminal.UI, config configuration.Reader) ApiEndpointRequirement {
return ApiEndpointRequirement{ui, config}
}
func (req ApiEndpointRequirement) Execute() (success bool) {
if req.config.ApiEndpoint() == "" {
loginTip := terminal.CommandColor(fmt.Sprintf(T("{{.CFName}} login", map[string]interface{}{"CFName": cf.Name()})))
apiTip := terminal.CommandColor(fmt.Sprintf(T("{{.CFName}} api", map[string]interface{}{"CFName": cf.Name()})))
req.ui.Say(T("No API endpoint targeted. Use '{{.LoginTip}}' or '{{.APITip}}' to target an endpoint.",
map[string]interface{}{
"LoginTip": loginTip,
"APITip": apiTip,
}))
return false
}
return true
}