forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain.go
46 lines (38 loc) · 1.07 KB
/
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
45
46
package requirements
import (
"github.com/cloudfoundry/cli/cf/api"
"github.com/cloudfoundry/cli/cf/configuration/core_config"
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/terminal"
)
type DomainRequirement interface {
Requirement
GetDomain() models.DomainFields
}
type domainApiRequirement struct {
name string
ui terminal.UI
config core_config.Reader
domainRepo api.DomainRepository
domain models.DomainFields
}
func NewDomainRequirement(name string, ui terminal.UI, config core_config.Reader, domainRepo api.DomainRepository) (req *domainApiRequirement) {
req = new(domainApiRequirement)
req.name = name
req.ui = ui
req.config = config
req.domainRepo = domainRepo
return
}
func (req *domainApiRequirement) Execute() bool {
var apiErr error
req.domain, apiErr = req.domainRepo.FindByNameInOrg(req.name, req.config.OrganizationFields().Guid)
if apiErr != nil {
req.ui.Failed(apiErr.Error())
return false
}
return true
}
func (req *domainApiRequirement) GetDomain() models.DomainFields {
return req.domain
}