-
Notifications
You must be signed in to change notification settings - Fork 3
/
refs.go
40 lines (37 loc) · 1.27 KB
/
refs.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
package refs
import (
"github.com/deis/steward-framework/k8s/data"
)
// GetDependenciesForServiceInstance fetches the entire reference tree for inst
func GetDependenciesForServiceInstance(
inst *data.ServiceInstance,
getServiceBroker ServiceBrokerGetterFunc,
getServiceClass ServiceClassGetterFunc,
) (*data.ServiceBroker, *data.ServiceClass, error) {
sClass, err := getServiceClass(inst.Spec.ServiceClassRef)
if err != nil {
return nil, nil, err
}
serviceBroker, err := getServiceBroker(sClass.ServiceBrokerRef)
if err != nil {
return nil, nil, err
}
return serviceBroker, sClass, nil
}
// GetDependenciesForServiceBinding fetches the entire reference tree for service binding
func GetDependenciesForServiceBinding(
serviceBinding *data.ServiceBinding,
getServiceBroker ServiceBrokerGetterFunc,
getServiceClass ServiceClassGetterFunc,
getServiceInstance ServiceInstanceGetterFunc,
) (*data.ServiceBroker, *data.ServiceClass, *data.ServiceInstance, error) {
inst, err := getServiceInstance(serviceBinding.Spec.ServiceInstanceRef)
if err != nil {
return nil, nil, nil, err
}
serviceBroker, sClass, err := GetDependenciesForServiceInstance(inst, getServiceBroker, getServiceClass)
if err != nil {
return nil, nil, nil, err
}
return serviceBroker, sClass, inst, nil
}