-
Notifications
You must be signed in to change notification settings - Fork 928
/
targeted_organization.go
40 lines (31 loc) · 1.04 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
40
package requirements
import (
"errors"
"fmt"
"code.cloudfoundry.org/cli/cf"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
. "code.cloudfoundry.org/cli/cf/i18n"
"code.cloudfoundry.org/cli/cf/models"
"code.cloudfoundry.org/cli/cf/terminal"
)
//go:generate counterfeiter . TargetedOrgRequirement
type TargetedOrgRequirement interface {
Requirement
GetOrganizationFields() models.OrganizationFields
}
type targetedOrgAPIRequirement struct {
config coreconfig.Reader
}
func NewTargetedOrgRequirement(config coreconfig.Reader) TargetedOrgRequirement {
return targetedOrgAPIRequirement{config}
}
func (req targetedOrgAPIRequirement) Execute() error {
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")}))
return errors.New(message)
}
return nil
}
func (req targetedOrgAPIRequirement) GetOrganizationFields() (org models.OrganizationFields) {
return req.config.OrganizationFields()
}