forked from HuaweiTech/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
targeted_organization.go
38 lines (31 loc) · 979 Bytes
/
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
package requirements
import (
"fmt"
"github.com/cloudfoundry/cli/cf"
"github.com/cloudfoundry/cli/cf/configuration"
"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 configuration.Reader
}
func NewTargetedOrgRequirement(ui terminal.UI, config configuration.Reader) TargetedOrgRequirement {
return targetedOrgApiRequirement{ui, config}
}
func (req targetedOrgApiRequirement) Execute() (success bool) {
if !req.config.HasOrganization() {
message := fmt.Sprintf("No org targeted, use '%s' to target an org.",
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()
}