MCPcopy Index your code
hub / github.com/cloudfoundry/cli / GetServiceInstancesForSpace

Method GetServiceInstancesForSpace

actor/v7action/service_instance_list.go:30–89  ·  view source on GitHub ↗
(spaceGUID string, omitApps bool)

Source from the content-addressed store, hash-verified

28}
29
30func (actor Actor) GetServiceInstancesForSpace(spaceGUID string, omitApps bool) ([]ServiceInstance, Warnings, error) {
31 var (
32 instances []resources.ServiceInstance
33 bindings []resources.ServiceCredentialBinding
34 included ccv3.IncludedResources
35 )
36
37 warnings, err := railway.Sequentially(
38 func() (warnings ccv3.Warnings, err error) {
39 instances, included, warnings, err = actor.CloudControllerClient.GetServiceInstances(
40 ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}},
41 ccv3.Query{Key: ccv3.FieldsServicePlan, Values: []string{"guid", "name", "relationships.service_offering"}},
42 ccv3.Query{Key: ccv3.FieldsServicePlanServiceOffering, Values: []string{"guid", "name", "relationships.service_broker"}},
43 ccv3.Query{Key: ccv3.FieldsServicePlanServiceOfferingServiceBroker, Values: []string{"guid", "name"}},
44 ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.NameOrder}},
45 ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}},
46 )
47 return
48 },
49 func() (warnings ccv3.Warnings, err error) {
50 if !omitApps {
51 return batcher.RequestByGUID(
52 extract.UniqueList("GUID", instances),
53 func(guids []string) (ccv3.Warnings, error) {
54 batch, warnings, err := actor.CloudControllerClient.GetServiceCredentialBindings(
55 ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: guids},
56 ccv3.Query{Key: ccv3.Include, Values: []string{"app"}},
57 )
58 bindings = append(bindings, batch...)
59 return warnings, err
60 },
61 )
62 }
63 return
64 },
65 )
66 if err != nil {
67 return nil, Warnings(warnings), err
68 }
69
70 planDetailsFromPlanGUIDLookup := buildPlanDetailsLookup(included)
71 boundAppsNamesFromInstanceGUIDLookup := buildBoundAppsLookup(bindings, spaceGUID)
72
73 result := make([]ServiceInstance, len(instances))
74 for i, instance := range instances {
75 names := planDetailsFromPlanGUIDLookup[instance.ServicePlanGUID]
76 result[i] = ServiceInstance{
77 Name: instance.Name,
78 Type: instance.Type,
79 UpgradeAvailable: instance.UpgradeAvailable,
80 ServicePlanName: names.plan,
81 ServiceOfferingName: names.offering,
82 ServiceBrokerName: names.broker,
83 BoundApps: boundAppsNamesFromInstanceGUIDLookup[instance.GUID],
84 LastOperation: lastOperation(instance.LastOperation),
85 }
86 }
87

Callers

nothing calls this directly

Implementers 1

FakeActorcommand/v7/v7fakes/fake_actor.go

Calls 9

SequentiallyFunction · 0.92
RequestByGUIDFunction · 0.92
UniqueListFunction · 0.92
buildPlanDetailsLookupFunction · 0.85
buildBoundAppsLookupFunction · 0.85
WarningsTypeAlias · 0.70
lastOperationFunction · 0.70
GetServiceInstancesMethod · 0.65

Tested by

no test coverage detected