(actor Actor, stagingSpaceGUIDs []string, runningSpaceGUIDs []string)
| 331 | } |
| 332 | |
| 333 | func getSecurityGroupSpaces(actor Actor, stagingSpaceGUIDs []string, runningSpaceGUIDs []string) ([]SecurityGroupSpace, ccv3.Warnings, error) { |
| 334 | var warnings ccv3.Warnings |
| 335 | associatedSpaceGuids := runningSpaceGUIDs |
| 336 | associatedSpaceGuids = append(associatedSpaceGuids, stagingSpaceGUIDs...) |
| 337 | |
| 338 | var securityGroupSpaces []SecurityGroupSpace |
| 339 | var spaces []resources.Space |
| 340 | var includes ccv3.IncludedResources |
| 341 | |
| 342 | if len(associatedSpaceGuids) > 0 { |
| 343 | ccv3Warnings, err := batcher.RequestByGUID(associatedSpaceGuids, func(guids []string) (ccv3.Warnings, error) { |
| 344 | batchSpaces, batchIncludes, newWarnings, err := actor.CloudControllerClient.GetSpaces(ccv3.Query{ |
| 345 | Key: ccv3.GUIDFilter, |
| 346 | Values: guids, |
| 347 | }, ccv3.Query{ |
| 348 | Key: ccv3.Include, |
| 349 | Values: []string{"organization"}, |
| 350 | }) |
| 351 | spaces = append(spaces, batchSpaces...) |
| 352 | includes.Organizations = append(includes.Organizations, batchIncludes.Organizations...) |
| 353 | return newWarnings, err |
| 354 | }) |
| 355 | warnings = ccv3Warnings |
| 356 | if err != nil { |
| 357 | return securityGroupSpaces, warnings, err |
| 358 | } |
| 359 | |
| 360 | orgsByGuid := lookuptable.OrgFromGUID(includes.Organizations) |
| 361 | spacesByGuid := lookuptable.SpaceFromGUID(spaces) |
| 362 | |
| 363 | for _, runningSpaceGUID := range runningSpaceGUIDs { |
| 364 | space := spacesByGuid[runningSpaceGUID] |
| 365 | orgGuid := space.Relationships[constant.RelationshipTypeOrganization].GUID |
| 366 | securityGroupSpaces = append(securityGroupSpaces, SecurityGroupSpace{ |
| 367 | SpaceName: space.Name, |
| 368 | OrgName: orgsByGuid[orgGuid].Name, |
| 369 | Lifecycle: "running", |
| 370 | }) |
| 371 | } |
| 372 | |
| 373 | for _, stagingSpaceGUID := range stagingSpaceGUIDs { |
| 374 | space := spacesByGuid[stagingSpaceGUID] |
| 375 | orgGuid := space.Relationships[constant.RelationshipTypeOrganization].GUID |
| 376 | securityGroupSpaces = append(securityGroupSpaces, SecurityGroupSpace{ |
| 377 | SpaceName: space.Name, |
| 378 | OrgName: orgsByGuid[orgGuid].Name, |
| 379 | Lifecycle: "staging", |
| 380 | }) |
| 381 | } |
| 382 | } |
| 383 | return securityGroupSpaces, warnings, nil |
| 384 | } |
| 385 | |
| 386 | func parsePath(path string) ([]byte, error) { |
| 387 | file, err := os.Open(path) |
no test coverage detected