forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
domain.go
44 lines (36 loc) · 853 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 (
"cf"
"cf/api"
"cf/net"
"cf/terminal"
)
type DomainRequirement interface {
Requirement
GetDomain() cf.Domain
}
type domainApiRequirement struct {
name string
ui terminal.UI
domainRepo api.DomainRepository
domain cf.Domain
}
func newDomainRequirement(name string, ui terminal.UI, domainRepo api.DomainRepository) (req *domainApiRequirement) {
req = new(domainApiRequirement)
req.name = name
req.ui = ui
req.domainRepo = domainRepo
return
}
func (req *domainApiRequirement) Execute() bool {
var apiResponse net.ApiResponse
req.domain, apiResponse = req.domainRepo.FindByNameInCurrentSpace(req.name)
if apiResponse.IsNotSuccessful() {
req.ui.Failed(apiResponse.Message)
return false
}
return true
}
func (req *domainApiRequirement) GetDomain() cf.Domain {
return req.domain
}