forked from cloudfoundry-community/cloudfoundry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
organization.go
46 lines (36 loc) · 1016 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
45
46
package requirements
import (
"code.cloudfoundry.org/cli/cf/api/organizations"
"code.cloudfoundry.org/cli/cf/models"
)
//go:generate counterfeiter . OrganizationRequirement
type OrganizationRequirement interface {
Requirement
SetOrganizationName(string)
GetOrganization() models.Organization
}
type organizationAPIRequirement struct {
name string
orgRepo organizations.OrganizationRepository
org models.Organization
}
func NewOrganizationRequirement(name string, sR organizations.OrganizationRepository) *organizationAPIRequirement {
req := &organizationAPIRequirement{}
req.name = name
req.orgRepo = sR
return req
}
func (req *organizationAPIRequirement) Execute() error {
var apiErr error
req.org, apiErr = req.orgRepo.FindByName(req.name)
if apiErr != nil {
return apiErr
}
return nil
}
func (req *organizationAPIRequirement) SetOrganizationName(name string) {
req.name = name
}
func (req *organizationAPIRequirement) GetOrganization() models.Organization {
return req.org
}