(spaceGUID string, omitApps bool)
| 28 | } |
| 29 | |
| 30 | func (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 |
nothing calls this directly
no test coverage detected