forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
space.go
46 lines (36 loc) · 883 Bytes
/
space.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/spaces"
"code.cloudfoundry.org/cli/cf/models"
)
//go:generate counterfeiter . SpaceRequirement
type SpaceRequirement interface {
Requirement
SetSpaceName(string)
GetSpace() models.Space
}
type spaceAPIRequirement struct {
name string
spaceRepo spaces.SpaceRepository
space models.Space
}
func NewSpaceRequirement(name string, sR spaces.SpaceRepository) *spaceAPIRequirement {
req := &spaceAPIRequirement{}
req.name = name
req.spaceRepo = sR
return req
}
func (req *spaceAPIRequirement) SetSpaceName(name string) {
req.name = name
}
func (req *spaceAPIRequirement) Execute() error {
var apiErr error
req.space, apiErr = req.spaceRepo.FindByName(req.name)
if apiErr != nil {
return apiErr
}
return nil
}
func (req *spaceAPIRequirement) GetSpace() models.Space {
return req.space
}