-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_instance.go
41 lines (32 loc) · 955 Bytes
/
service_instance.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
package requirements
import (
"code.cloudfoundry.org/cli/cf/api"
"code.cloudfoundry.org/cli/cf/models"
)
//go:generate counterfeiter . ServiceInstanceRequirement
type ServiceInstanceRequirement interface {
Requirement
GetServiceInstance() models.ServiceInstance
}
type serviceInstanceAPIRequirement struct {
name string
serviceRepo api.ServiceRepository
serviceInstance models.ServiceInstance
}
func NewServiceInstanceRequirement(name string, sR api.ServiceRepository) (req *serviceInstanceAPIRequirement) {
req = new(serviceInstanceAPIRequirement)
req.name = name
req.serviceRepo = sR
return
}
func (req *serviceInstanceAPIRequirement) Execute() error {
var apiErr error
req.serviceInstance, apiErr = req.serviceRepo.FindInstanceByName(req.name)
if apiErr != nil {
return apiErr
}
return nil
}
func (req *serviceInstanceAPIRequirement) GetServiceInstance() models.ServiceInstance {
return req.serviceInstance
}