forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
targeted_organization.go
39 lines (31 loc) · 1.05 KB
/
targeted_organization.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
32
33
34
35
36
37
38
39
package requirements
import (
"fmt"
"github.com/cloudfoundry/cli/cf"
"github.com/cloudfoundry/cli/cf/configuration/core_config"
. "github.com/cloudfoundry/cli/cf/i18n"
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/terminal"
)
type TargetedOrgRequirement interface {
Requirement
GetOrganizationFields() models.OrganizationFields
}
type targetedOrgApiRequirement struct {
ui terminal.UI
config core_config.Reader
}
func NewTargetedOrgRequirement(ui terminal.UI, config core_config.Reader) TargetedOrgRequirement {
return targetedOrgApiRequirement{ui, config}
}
func (req targetedOrgApiRequirement) Execute() (success bool) {
if !req.config.HasOrganization() {
message := fmt.Sprintf(T("No org targeted, use '{{.Command}}' to target an org.", map[string]interface{}{"Command": terminal.CommandColor(cf.Name() + " target -o ORG")}))
req.ui.Failed(message)
return false
}
return true
}
func (req targetedOrgApiRequirement) GetOrganizationFields() (org models.OrganizationFields) {
return req.config.OrganizationFields()
}