forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
targeted_space.go
34 lines (26 loc) · 980 Bytes
/
targeted_space.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
package requirements
import (
"fmt"
"errors"
"code.cloudfoundry.org/cli/cf"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
. "code.cloudfoundry.org/cli/cf/i18n"
"code.cloudfoundry.org/cli/cf/terminal"
)
type TargetedSpaceRequirement struct {
config coreconfig.Reader
}
func NewTargetedSpaceRequirement(config coreconfig.Reader) TargetedSpaceRequirement {
return TargetedSpaceRequirement{config}
}
func (req TargetedSpaceRequirement) Execute() error {
if !req.config.HasOrganization() {
message := fmt.Sprintf(T("No org and space targeted, use '{{.Command}}' to target an org and space", map[string]interface{}{"Command": terminal.CommandColor(cf.Name + " target -o ORG -s SPACE")}))
return errors.New(message)
}
if !req.config.HasSpace() {
message := fmt.Sprintf(T("No space targeted, use '{{.Command}}' to target a space.", map[string]interface{}{"Command": terminal.CommandColor("cf target -s")}))
return errors.New(message)
}
return nil
}