(offeringName, brokerName, orgName string)
| 25 | type offeringDetails struct{ offeringName, brokerName string } |
| 26 | |
| 27 | func (actor *Actor) GetServiceAccess(offeringName, brokerName, orgName string) ([]ServicePlanAccess, Warnings, error) { |
| 28 | var orgGUID string |
| 29 | var allWarnings Warnings |
| 30 | if orgName != "" { |
| 31 | org, orgWarnings, err := actor.GetOrganizationByName(orgName) |
| 32 | if err != nil { |
| 33 | return nil, orgWarnings, err |
| 34 | } |
| 35 | allWarnings = append(allWarnings, orgWarnings...) |
| 36 | |
| 37 | orgGUID = org.GUID |
| 38 | } |
| 39 | |
| 40 | plansQuery := buildPlansFilterForGet(offeringName, brokerName, orgGUID) |
| 41 | |
| 42 | offerings, offeringsWarnings, err := actor.getServiceOfferings(offeringName, brokerName) |
| 43 | allWarnings = append(allWarnings, offeringsWarnings...) |
| 44 | if err != nil { |
| 45 | return nil, allWarnings, err |
| 46 | } |
| 47 | |
| 48 | plans, plansWarnings, err := actor.CloudControllerClient.GetServicePlansWithSpaceAndOrganization(plansQuery...) |
| 49 | allWarnings = append(allWarnings, plansWarnings...) |
| 50 | if err != nil { |
| 51 | return nil, allWarnings, err |
| 52 | } |
| 53 | |
| 54 | var result []ServicePlanAccess |
| 55 | for _, plan := range plans { |
| 56 | if offering, ok := offerings[plan.ServiceOfferingGUID]; ok { |
| 57 | visibilityDetails, warnings, err := actor.getServicePlanVisibilityDetails(ServicePlanWithSpaceAndOrganization(plan)) |
| 58 | allWarnings = append(allWarnings, warnings...) |
| 59 | if err != nil { |
| 60 | return nil, allWarnings, err |
| 61 | } |
| 62 | |
| 63 | result = append(result, ServicePlanAccess{ |
| 64 | ServicePlanName: plan.Name, |
| 65 | VisibilityType: plan.VisibilityType, |
| 66 | VisibilityDetails: visibilityDetails, |
| 67 | ServiceOfferingName: offering.offeringName, |
| 68 | BrokerName: offering.brokerName, |
| 69 | }) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | sort.Slice(result, func(i, j int) bool { |
| 74 | if result[i].BrokerName != result[j].BrokerName { |
| 75 | return result[i].BrokerName < result[j].BrokerName |
| 76 | } |
| 77 | if result[i].ServiceOfferingName != result[j].ServiceOfferingName { |
| 78 | return result[i].ServiceOfferingName < result[j].ServiceOfferingName |
| 79 | } |
| 80 | return result[i].ServicePlanName < result[j].ServicePlanName |
| 81 | }) |
| 82 | |
| 83 | return result, allWarnings, err |
| 84 | } |
nothing calls this directly
no test coverage detected