-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain.go
44 lines (35 loc) · 1010 Bytes
/
domain.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 (
"github.com/cloudfoundry/cli/cf/api"
"github.com/cloudfoundry/cli/cf/configuration/coreconfig"
"github.com/cloudfoundry/cli/cf/models"
)
//go:generate counterfeiter . DomainRequirement
type DomainRequirement interface {
Requirement
GetDomain() models.DomainFields
}
type domainAPIRequirement struct {
name string
config coreconfig.Reader
domainRepo api.DomainRepository
domain models.DomainFields
}
func NewDomainRequirement(name string, config coreconfig.Reader, domainRepo api.DomainRepository) (req *domainAPIRequirement) {
req = new(domainAPIRequirement)
req.name = name
req.config = config
req.domainRepo = domainRepo
return
}
func (req *domainAPIRequirement) Execute() error {
var apiErr error
req.domain, apiErr = req.domainRepo.FindByNameInOrg(req.name, req.config.OrganizationFields().GUID)
if apiErr != nil {
return apiErr
}
return nil
}
func (req *domainAPIRequirement) GetDomain() models.DomainFields {
return req.domain
}