forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organization.go
44 lines (36 loc) · 893 Bytes
/
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
41
42
43
44
package requirements
import (
"cf"
"cf/api"
"cf/net"
"cf/terminal"
)
type OrganizationRequirement interface {
Requirement
GetOrganization() cf.Organization
}
type organizationApiRequirement struct {
name string
ui terminal.UI
orgRepo api.OrganizationRepository
org cf.Organization
}
func newOrganizationRequirement(name string, ui terminal.UI, sR api.OrganizationRepository) (req *organizationApiRequirement) {
req = new(organizationApiRequirement)
req.name = name
req.ui = ui
req.orgRepo = sR
return
}
func (req *organizationApiRequirement) Execute() (success bool) {
var apiResponse net.ApiResponse
req.org, apiResponse = req.orgRepo.FindByName(req.name)
if apiResponse.IsNotSuccessful() {
req.ui.Failed(apiResponse.Message)
return false
}
return true
}
func (req *organizationApiRequirement) GetOrganization() cf.Organization {
return req.org
}