(securityGroupName string, orgName string, spaceName string, lifecycle constant.SecurityGroupLifecycle)
| 182 | } |
| 183 | |
| 184 | func (actor Actor) UnbindSecurityGroup(securityGroupName string, orgName string, spaceName string, lifecycle constant.SecurityGroupLifecycle) (Warnings, error) { |
| 185 | var allWarnings Warnings |
| 186 | |
| 187 | org, warnings, err := actor.GetOrganizationByName(orgName) |
| 188 | allWarnings = append(allWarnings, warnings...) |
| 189 | if err != nil { |
| 190 | return allWarnings, err |
| 191 | } |
| 192 | |
| 193 | space, warnings, err := actor.GetSpaceByNameAndOrganization(spaceName, org.GUID) |
| 194 | allWarnings = append(allWarnings, warnings...) |
| 195 | if err != nil { |
| 196 | return allWarnings, err |
| 197 | } |
| 198 | |
| 199 | securityGroup, warnings, err := actor.GetSecurityGroup(securityGroupName) |
| 200 | allWarnings = append(allWarnings, warnings...) |
| 201 | if err != nil { |
| 202 | return allWarnings, err |
| 203 | } |
| 204 | |
| 205 | var ccv3Warnings ccv3.Warnings |
| 206 | switch lifecycle { |
| 207 | case constant.SecurityGroupLifecycleRunning: |
| 208 | ccv3Warnings, err = actor.CloudControllerClient.UnbindSecurityGroupRunningSpace(securityGroup.GUID, space.GUID) |
| 209 | case constant.SecurityGroupLifecycleStaging: |
| 210 | ccv3Warnings, err = actor.CloudControllerClient.UnbindSecurityGroupStagingSpace(securityGroup.GUID, space.GUID) |
| 211 | default: |
| 212 | return allWarnings, actionerror.InvalidLifecycleError{Lifecycle: string(lifecycle)} |
| 213 | } |
| 214 | |
| 215 | allWarnings = append(allWarnings, ccv3Warnings...) |
| 216 | |
| 217 | if err != nil { |
| 218 | if _, isNotBoundError := err.(ccerror.SecurityGroupNotBound); isNotBoundError { |
| 219 | return allWarnings, actionerror.SecurityGroupNotBoundToSpaceError{ |
| 220 | Name: securityGroupName, |
| 221 | Space: spaceName, |
| 222 | Lifecycle: lifecycle, |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | return allWarnings, err |
| 228 | } |
| 229 | |
| 230 | func (actor Actor) GetGlobalStagingSecurityGroups() ([]resources.SecurityGroup, Warnings, error) { |
| 231 | stagingSecurityGroups, warnings, err := actor.CloudControllerClient.GetSecurityGroups(ccv3.Query{Key: ccv3.GloballyEnabledStaging, Values: []string{"true"}}) |
nothing calls this directly
no test coverage detected