forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
targeted_space.go
33 lines (27 loc) · 1003 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
package requirements
import (
"fmt"
"github.com/cloudfoundry/cli/cf"
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/terminal"
)
type TargetedSpaceRequirement struct {
ui terminal.UI
config configuration.Reader
}
func NewTargetedSpaceRequirement(ui terminal.UI, config configuration.Reader) TargetedSpaceRequirement {
return TargetedSpaceRequirement{ui, config}
}
func (req TargetedSpaceRequirement) Execute() (success bool) {
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")}))
req.ui.Failed(message)
return false
}
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")}))
req.ui.Failed(message)
return false
}
return true
}