Skip to content

Commit 2fa8aec

Browse files
committed
Disable Identity from sweeper
1 parent 09909b6 commit 2fa8aec

7 files changed

+0
-551
lines changed

oci/identity_compartment_test.go

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import (
77
"fmt"
88
"regexp"
99
"testing"
10-
"time"
1110

1211
"github.com/hashicorp/terraform/helper/resource"
13-
"github.com/hashicorp/terraform/helper/schema"
1412
"github.com/hashicorp/terraform/terraform"
1513
"github.com/oracle/oci-go-sdk/common"
1614
oci_identity "github.com/oracle/oci-go-sdk/identity"
@@ -246,81 +244,3 @@ func testAccCheckIdentityCompartmentDestroy(s *terraform.State) error {
246244

247245
return nil
248246
}
249-
250-
func init() {
251-
if DependencyGraph == nil {
252-
initDependencyGraph()
253-
}
254-
resource.AddTestSweepers("IdentityCompartment", &resource.Sweeper{
255-
Name: "IdentityCompartment",
256-
Dependencies: DependencyGraph["compartment"],
257-
F: sweepIdentityCompartmentResource,
258-
})
259-
}
260-
261-
func sweepIdentityCompartmentResource(compartment string) error {
262-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
263-
compartmentIds, err := getCompartmentIds(compartment)
264-
if err != nil {
265-
return err
266-
}
267-
for _, compartmentId := range compartmentIds {
268-
if ok := SweeperDefaultResourceId[compartmentId]; !ok {
269-
deleteCompartmentRequest := oci_identity.DeleteCompartmentRequest{}
270-
271-
deleteCompartmentRequest.CompartmentId = &compartmentId
272-
273-
deleteCompartmentRequest.RequestMetadata.RetryPolicy = getRetryPolicy(true, "identity")
274-
_, error := identityClient.DeleteCompartment(context.Background(), deleteCompartmentRequest)
275-
if error != nil {
276-
fmt.Printf("Error deleting Compartment %s %s, It is possible that the resource is already deleted. Please verify manually \n", compartmentId, error)
277-
continue
278-
}
279-
waitTillCondition(testAccProvider, &compartmentId, compartmentSweepWaitCondition, time.Duration(3*time.Minute),
280-
compartmentSweepResponseFetchOperation, "identity", true)
281-
}
282-
}
283-
return nil
284-
}
285-
286-
func getCompartmentIds(compartment string) ([]string, error) {
287-
ids := getResourceIdsToSweep(compartment, "CompartmentId")
288-
if ids != nil {
289-
return ids, nil
290-
}
291-
var resourceIds []string
292-
compartmentId := compartment
293-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
294-
295-
listCompartmentsRequest := oci_identity.ListCompartmentsRequest{}
296-
listCompartmentsRequest.CompartmentId = &compartmentId
297-
listCompartmentsResponse, err := identityClient.ListCompartments(context.Background(), listCompartmentsRequest)
298-
299-
if err != nil {
300-
return resourceIds, fmt.Errorf("Error getting Compartment list for compartment id : %s , %s \n", compartmentId, err)
301-
}
302-
for _, compartment := range listCompartmentsResponse.Items {
303-
id := *compartment.Id
304-
resourceIds = append(resourceIds, id)
305-
addResourceIdToSweeperResourceIdMap(compartmentId, "CompartmentId", id)
306-
}
307-
return resourceIds, nil
308-
}
309-
310-
func compartmentSweepWaitCondition(response common.OCIOperationResponse) bool {
311-
// Only stop if the resource is available beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
312-
if compartmentResponse, ok := response.Response.(oci_identity.GetCompartmentResponse); ok {
313-
return compartmentResponse.LifecycleState != oci_identity.CompartmentLifecycleStateDeleted
314-
}
315-
return false
316-
}
317-
318-
func compartmentSweepResponseFetchOperation(client *OracleClients, resourceId *string, retryPolicy *common.RetryPolicy) error {
319-
_, err := client.identityClient.GetCompartment(context.Background(), oci_identity.GetCompartmentRequest{
320-
CompartmentId: resourceId,
321-
RequestMetadata: common.RequestMetadata{
322-
RetryPolicy: retryPolicy,
323-
},
324-
})
325-
return err
326-
}

oci/identity_dynamic_group_test.go

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import (
77
"fmt"
88
"regexp"
99
"testing"
10-
"time"
1110

1211
"github.com/hashicorp/terraform/helper/resource"
13-
"github.com/hashicorp/terraform/helper/schema"
1412
"github.com/hashicorp/terraform/terraform"
1513
"github.com/oracle/oci-go-sdk/common"
1614
oci_identity "github.com/oracle/oci-go-sdk/identity"
@@ -217,81 +215,3 @@ func testAccCheckIdentityDynamicGroupDestroy(s *terraform.State) error {
217215

218216
return nil
219217
}
220-
221-
func init() {
222-
if DependencyGraph == nil {
223-
initDependencyGraph()
224-
}
225-
resource.AddTestSweepers("IdentityDynamicGroup", &resource.Sweeper{
226-
Name: "IdentityDynamicGroup",
227-
Dependencies: DependencyGraph["dynamicGroup"],
228-
F: sweepIdentityDynamicGroupResource,
229-
})
230-
}
231-
232-
func sweepIdentityDynamicGroupResource(compartment string) error {
233-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
234-
dynamicGroupIds, err := getDynamicGroupIds(compartment)
235-
if err != nil {
236-
return err
237-
}
238-
for _, dynamicGroupId := range dynamicGroupIds {
239-
if ok := SweeperDefaultResourceId[dynamicGroupId]; !ok {
240-
deleteDynamicGroupRequest := oci_identity.DeleteDynamicGroupRequest{}
241-
242-
deleteDynamicGroupRequest.DynamicGroupId = &dynamicGroupId
243-
244-
deleteDynamicGroupRequest.RequestMetadata.RetryPolicy = getRetryPolicy(true, "identity")
245-
_, error := identityClient.DeleteDynamicGroup(context.Background(), deleteDynamicGroupRequest)
246-
if error != nil {
247-
fmt.Printf("Error deleting DynamicGroup %s %s, It is possible that the resource is already deleted. Please verify manually \n", dynamicGroupId, error)
248-
continue
249-
}
250-
waitTillCondition(testAccProvider, &dynamicGroupId, dynamicGroupSweepWaitCondition, time.Duration(3*time.Minute),
251-
dynamicGroupSweepResponseFetchOperation, "identity", true)
252-
}
253-
}
254-
return nil
255-
}
256-
257-
func getDynamicGroupIds(compartment string) ([]string, error) {
258-
ids := getResourceIdsToSweep(compartment, "DynamicGroupId")
259-
if ids != nil {
260-
return ids, nil
261-
}
262-
var resourceIds []string
263-
compartmentId := compartment
264-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
265-
266-
listDynamicGroupsRequest := oci_identity.ListDynamicGroupsRequest{}
267-
listDynamicGroupsRequest.CompartmentId = &compartmentId
268-
listDynamicGroupsResponse, err := identityClient.ListDynamicGroups(context.Background(), listDynamicGroupsRequest)
269-
270-
if err != nil {
271-
return resourceIds, fmt.Errorf("Error getting DynamicGroup list for compartment id : %s , %s \n", compartmentId, err)
272-
}
273-
for _, dynamicGroup := range listDynamicGroupsResponse.Items {
274-
id := *dynamicGroup.Id
275-
resourceIds = append(resourceIds, id)
276-
addResourceIdToSweeperResourceIdMap(compartmentId, "DynamicGroupId", id)
277-
}
278-
return resourceIds, nil
279-
}
280-
281-
func dynamicGroupSweepWaitCondition(response common.OCIOperationResponse) bool {
282-
// Only stop if the resource is available beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
283-
if dynamicGroupResponse, ok := response.Response.(oci_identity.GetDynamicGroupResponse); ok {
284-
return dynamicGroupResponse.LifecycleState != oci_identity.DynamicGroupLifecycleStateDeleted
285-
}
286-
return false
287-
}
288-
289-
func dynamicGroupSweepResponseFetchOperation(client *OracleClients, resourceId *string, retryPolicy *common.RetryPolicy) error {
290-
_, err := client.identityClient.GetDynamicGroup(context.Background(), oci_identity.GetDynamicGroupRequest{
291-
DynamicGroupId: resourceId,
292-
RequestMetadata: common.RequestMetadata{
293-
RetryPolicy: retryPolicy,
294-
},
295-
})
296-
return err
297-
}

oci/identity_group_test.go

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import (
66
"context"
77
"fmt"
88
"testing"
9-
"time"
109

1110
"github.com/hashicorp/terraform/helper/resource"
12-
"github.com/hashicorp/terraform/helper/schema"
1311
"github.com/hashicorp/terraform/terraform"
1412
"github.com/oracle/oci-go-sdk/common"
1513
oci_identity "github.com/oracle/oci-go-sdk/identity"
@@ -228,81 +226,3 @@ func testAccCheckIdentityGroupDestroy(s *terraform.State) error {
228226

229227
return nil
230228
}
231-
232-
func init() {
233-
if DependencyGraph == nil {
234-
initDependencyGraph()
235-
}
236-
resource.AddTestSweepers("IdentityGroup", &resource.Sweeper{
237-
Name: "IdentityGroup",
238-
Dependencies: DependencyGraph["group"],
239-
F: sweepIdentityGroupResource,
240-
})
241-
}
242-
243-
func sweepIdentityGroupResource(compartment string) error {
244-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
245-
groupIds, err := getGroupIds(compartment)
246-
if err != nil {
247-
return err
248-
}
249-
for _, groupId := range groupIds {
250-
if ok := SweeperDefaultResourceId[groupId]; !ok {
251-
deleteGroupRequest := oci_identity.DeleteGroupRequest{}
252-
253-
deleteGroupRequest.GroupId = &groupId
254-
255-
deleteGroupRequest.RequestMetadata.RetryPolicy = getRetryPolicy(true, "identity")
256-
_, error := identityClient.DeleteGroup(context.Background(), deleteGroupRequest)
257-
if error != nil {
258-
fmt.Printf("Error deleting Group %s %s, It is possible that the resource is already deleted. Please verify manually \n", groupId, error)
259-
continue
260-
}
261-
waitTillCondition(testAccProvider, &groupId, groupSweepWaitCondition, time.Duration(3*time.Minute),
262-
groupSweepResponseFetchOperation, "identity", true)
263-
}
264-
}
265-
return nil
266-
}
267-
268-
func getGroupIds(compartment string) ([]string, error) {
269-
ids := getResourceIdsToSweep(compartment, "GroupId")
270-
if ids != nil {
271-
return ids, nil
272-
}
273-
var resourceIds []string
274-
compartmentId := compartment
275-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
276-
277-
listGroupsRequest := oci_identity.ListGroupsRequest{}
278-
listGroupsRequest.CompartmentId = &compartmentId
279-
listGroupsResponse, err := identityClient.ListGroups(context.Background(), listGroupsRequest)
280-
281-
if err != nil {
282-
return resourceIds, fmt.Errorf("Error getting Group list for compartment id : %s , %s \n", compartmentId, err)
283-
}
284-
for _, group := range listGroupsResponse.Items {
285-
id := *group.Id
286-
resourceIds = append(resourceIds, id)
287-
addResourceIdToSweeperResourceIdMap(compartmentId, "GroupId", id)
288-
}
289-
return resourceIds, nil
290-
}
291-
292-
func groupSweepWaitCondition(response common.OCIOperationResponse) bool {
293-
// Only stop if the resource is available beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
294-
if groupResponse, ok := response.Response.(oci_identity.GetGroupResponse); ok {
295-
return groupResponse.LifecycleState != oci_identity.GroupLifecycleStateDeleted
296-
}
297-
return false
298-
}
299-
300-
func groupSweepResponseFetchOperation(client *OracleClients, resourceId *string, retryPolicy *common.RetryPolicy) error {
301-
_, err := client.identityClient.GetGroup(context.Background(), oci_identity.GetGroupRequest{
302-
GroupId: resourceId,
303-
RequestMetadata: common.RequestMetadata{
304-
RetryPolicy: retryPolicy,
305-
},
306-
})
307-
return err
308-
}

oci/identity_policy_test.go

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import (
66
"context"
77
"fmt"
88
"testing"
9-
"time"
109

1110
"github.com/hashicorp/terraform/helper/resource"
12-
"github.com/hashicorp/terraform/helper/schema"
1311
"github.com/hashicorp/terraform/terraform"
1412
"github.com/oracle/oci-go-sdk/common"
1513
oci_identity "github.com/oracle/oci-go-sdk/identity"
@@ -215,81 +213,3 @@ func testAccCheckIdentityPolicyDestroy(s *terraform.State) error {
215213

216214
return nil
217215
}
218-
219-
func init() {
220-
if DependencyGraph == nil {
221-
initDependencyGraph()
222-
}
223-
resource.AddTestSweepers("IdentityPolicy", &resource.Sweeper{
224-
Name: "IdentityPolicy",
225-
Dependencies: DependencyGraph["policy"],
226-
F: sweepIdentityPolicyResource,
227-
})
228-
}
229-
230-
func sweepIdentityPolicyResource(compartment string) error {
231-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
232-
policyIds, err := getPolicyIds(compartment)
233-
if err != nil {
234-
return err
235-
}
236-
for _, policyId := range policyIds {
237-
if ok := SweeperDefaultResourceId[policyId]; !ok {
238-
deletePolicyRequest := oci_identity.DeletePolicyRequest{}
239-
240-
deletePolicyRequest.PolicyId = &policyId
241-
242-
deletePolicyRequest.RequestMetadata.RetryPolicy = getRetryPolicy(true, "identity")
243-
_, error := identityClient.DeletePolicy(context.Background(), deletePolicyRequest)
244-
if error != nil {
245-
fmt.Printf("Error deleting Policy %s %s, It is possible that the resource is already deleted. Please verify manually \n", policyId, error)
246-
continue
247-
}
248-
waitTillCondition(testAccProvider, &policyId, policySweepWaitCondition, time.Duration(3*time.Minute),
249-
policySweepResponseFetchOperation, "identity", true)
250-
}
251-
}
252-
return nil
253-
}
254-
255-
func getPolicyIds(compartment string) ([]string, error) {
256-
ids := getResourceIdsToSweep(compartment, "PolicyId")
257-
if ids != nil {
258-
return ids, nil
259-
}
260-
var resourceIds []string
261-
compartmentId := compartment
262-
identityClient := GetTestClients(&schema.ResourceData{}).identityClient
263-
264-
listPoliciesRequest := oci_identity.ListPoliciesRequest{}
265-
listPoliciesRequest.CompartmentId = &compartmentId
266-
listPoliciesResponse, err := identityClient.ListPolicies(context.Background(), listPoliciesRequest)
267-
268-
if err != nil {
269-
return resourceIds, fmt.Errorf("Error getting Policy list for compartment id : %s , %s \n", compartmentId, err)
270-
}
271-
for _, policy := range listPoliciesResponse.Items {
272-
id := *policy.Id
273-
resourceIds = append(resourceIds, id)
274-
addResourceIdToSweeperResourceIdMap(compartmentId, "PolicyId", id)
275-
}
276-
return resourceIds, nil
277-
}
278-
279-
func policySweepWaitCondition(response common.OCIOperationResponse) bool {
280-
// Only stop if the resource is available beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
281-
if policyResponse, ok := response.Response.(oci_identity.GetPolicyResponse); ok {
282-
return policyResponse.LifecycleState != oci_identity.PolicyLifecycleStateDeleted
283-
}
284-
return false
285-
}
286-
287-
func policySweepResponseFetchOperation(client *OracleClients, resourceId *string, retryPolicy *common.RetryPolicy) error {
288-
_, err := client.identityClient.GetPolicy(context.Background(), oci_identity.GetPolicyRequest{
289-
PolicyId: resourceId,
290-
RequestMetadata: common.RequestMetadata{
291-
RetryPolicy: retryPolicy,
292-
},
293-
})
294-
return err
295-
}

0 commit comments

Comments
 (0)