diff --git a/docs/resources.md b/docs/resources.md index b92f8452..18049314 100644 --- a/docs/resources.md +++ b/docs/resources.md @@ -53,7 +53,7 @@ type ExampleResource struct { ID *string } -func (r *ExampleResource) Remove() error { +func (r *ExampleResource) Remove(_ context.Context) error { // remove the resource, an error will put the resource in failed state // resources in failed state are retried a number of times return nil diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 8574a511..ce535848 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -46,7 +46,7 @@ func TestConfigBlocklist(t *testing.T) { } func TestLoadExampleConfig(t *testing.T) { - config, err := Load("test-fixtures/example.yaml") + config, err := Load("testdata/example.yaml") if err != nil { t.Fatal(err) } @@ -199,7 +199,7 @@ func TestResolveDeprecations(t *testing.T) { } func TestConfigValidation(t *testing.T) { - config, err := Load("test-fixtures/example.yaml") + config, err := Load("testdata/example.yaml") if err != nil { t.Fatal(err) } @@ -232,7 +232,7 @@ func TestConfigValidation(t *testing.T) { } func TestDeprecatedConfigKeys(t *testing.T) { - config, err := Load("test-fixtures/deprecated-keys-config.yaml") + config, err := Load("testdata/deprecated-keys-config.yaml") if err != nil { t.Fatal(err) } @@ -243,7 +243,7 @@ func TestDeprecatedConfigKeys(t *testing.T) { } func TestFilterMerge(t *testing.T) { - config, err := Load("test-fixtures/example.yaml") + config, err := Load("testdata/example.yaml") if err != nil { t.Fatal(err) } @@ -281,7 +281,7 @@ func TestFilterMerge(t *testing.T) { } func TestGetCustomRegion(t *testing.T) { - config, err := Load("test-fixtures/example.yaml") + config, err := Load("testdata/example.yaml") if err != nil { t.Fatal(err) } diff --git a/pkg/config/testdata/example.yaml b/pkg/config/testdata/example.yaml index 1c758d2b..777250c4 100644 --- a/pkg/config/testdata/example.yaml +++ b/pkg/config/testdata/example.yaml @@ -1,7 +1,21 @@ --- -tenant-blocklist: +regions: + - "eu-west-1" + - stratoscale + +account-blocklist: - 1234567890 +endpoints: + - region: stratoscale + tls_insecure_skip_verify: true + services: + - service: ec2 + url: https://stratoscale.cloud.internal/api/v2/aws/ec2 + - service: s3 + url: https://stratoscale.cloud.internal:1060 + tls_insecure_skip_verify: true + resource-types: targets: - DynamoDBTable @@ -10,7 +24,7 @@ resource-types: excludes: - IAMRole -tenants: +accounts: 555133742: presets: - "terraform" @@ -28,4 +42,4 @@ presets: filters: S3Bucket: - type: glob - value: "my-statebucket-*" + value: "my-statebucket-*" \ No newline at end of file diff --git a/pkg/nuke/nuke.go b/pkg/nuke/nuke.go index 98c44571..ad3498f4 100644 --- a/pkg/nuke/nuke.go +++ b/pkg/nuke/nuke.go @@ -21,7 +21,7 @@ type Parameters struct { } type Nuke struct { - sdknuke.Nuke + *sdknuke.Nuke Parameters Parameters Config *config.Nuke Account awsutil.Account @@ -47,11 +47,7 @@ func (n *Nuke) Prompt() error { func New(params Parameters, config *config.Nuke, filters filter.Filters, account awsutil.Account) *Nuke { n := Nuke{ - Nuke: sdknuke.Nuke{ - Parameters: params.Parameters, - FeatureFlags: &featureflag.FeatureFlags{}, - Filters: filters, - }, + Nuke: sdknuke.New(params.Parameters, filters), Parameters: params, Config: config, Account: account, diff --git a/resources/cloudcontrol_test.go b/resources/cloudcontrol_test.go index 9fec4b66..8c24797c 100644 --- a/resources/cloudcontrol_test.go +++ b/resources/cloudcontrol_test.go @@ -1,12 +1,10 @@ package resources import ( - "context" - "testing" "github.com/sirupsen/logrus" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" ) func TestCloudControlParseProperties(t *testing.T) { @@ -15,20 +13,29 @@ func TestCloudControlParseProperties(t *testing.T) { cases := []struct { name string payload string - want string + want []string }{ { name: "ActualEC2VPC", payload: `{"VpcId":"vpc-456","InstanceTenancy":"default","CidrBlockAssociations":["vpc-cidr-assoc-1234", "vpc-cidr-assoc-5678"],"CidrBlock":"10.10.0.0/16","Tags":[{"Value":"Kubernetes VPC","Key":"Name"}]}`, - want: `[CidrBlock: "10.10.0.0/16", CidrBlockAssociations.["vpc-cidr-assoc-1234"]: "true", CidrBlockAssociations.["vpc-cidr-assoc-5678"]: "true", InstanceTenancy: "default", Tags.["Name"]: "Kubernetes VPC", VpcId: "vpc-456"]`, + want: []string{ + `CidrBlock: "10.10.0.0/16"`, + `Tags.["Name"]: "Kubernetes VPC"`, + `VpcId: "vpc-456"`, + `InstanceTenancy: "default"`, + `CidrBlockAssociations.["vpc-cidr-assoc-1234"]: "true"`, + `CidrBlockAssociations.["vpc-cidr-assoc-5678"]: "true"`, + }, }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { result, err := cloudControlParseProperties(tc.payload) - require.NoError(t, err) - require.Equal(t, tc.want, result.String()) + assert.NoError(t, err) + for _, w := range tc.want { + assert.Contains(t, result.String(), w) + } }) } } diff --git a/resources/cloudformation-stack_test.go b/resources/cloudformation-stack_test.go index b3269e74..8825c682 100644 --- a/resources/cloudformation-stack_test.go +++ b/resources/cloudformation-stack_test.go @@ -2,16 +2,18 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" + "github.com/gotidy/ptr" "github.com/stretchr/testify/assert" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/cloudformation" + "github.com/ekristen/libnuke/pkg/featureflag" + "github.com/ekristen/aws-nuke/mocks/mock_cloudformationiface" ) @@ -27,8 +29,11 @@ func TestCloudformationStack_Remove_StackAlreadyDeleted(t *testing.T) { stack: &cloudformation.Stack{ StackName: aws.String("foobar"), }, + featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), })).Return(&cloudformation.DescribeStacksOutput{ @@ -39,7 +44,7 @@ func TestCloudformationStack_Remove_StackAlreadyDeleted(t *testing.T) { }, }, nil) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) } @@ -54,14 +59,16 @@ func TestCloudformationStack_Remove_StackDoesNotExist(t *testing.T) { svc: mockCloudformation, stack: &cloudformation.Stack{ StackName: aws.String("foobar"), - }, + }, featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), })).Return(nil, awserr.New("ValidationFailed", "Stack with id foobar does not exist", nil)) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) } @@ -77,8 +84,11 @@ func TestCloudformationStack_Remove_DeleteFailed(t *testing.T) { stack: &cloudformation.Stack{ StackName: aws.String("foobar"), }, + featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + gomock.InOrder( mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), @@ -114,7 +124,7 @@ func TestCloudformationStack_Remove_DeleteFailed(t *testing.T) { })).Return(nil), ) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) } @@ -131,8 +141,11 @@ func TestCloudformationStack_Remove_DeleteInProgress(t *testing.T) { stack: &cloudformation.Stack{ StackName: aws.String("foobar"), }, + featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + gomock.InOrder( mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), @@ -149,7 +162,7 @@ func TestCloudformationStack_Remove_DeleteInProgress(t *testing.T) { })).Return(nil), ) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) } @@ -178,8 +191,11 @@ func TestCloudformationStack_Remove_Stack_InCompletedStatus(t *testing.T) { stack: &cloudformation.Stack{ StackName: aws.String("foobar"), }, + featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + gomock.InOrder( mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), @@ -200,7 +216,7 @@ func TestCloudformationStack_Remove_Stack_InCompletedStatus(t *testing.T) { })).Return(nil), ) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) }) } @@ -225,8 +241,11 @@ func TestCloudformationStack_Remove_Stack_CreateInProgress(t *testing.T) { stack: &cloudformation.Stack{ StackName: aws.String("foobar"), }, + featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + gomock.InOrder( mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), @@ -251,7 +270,7 @@ func TestCloudformationStack_Remove_Stack_CreateInProgress(t *testing.T) { })).Return(nil), ) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) }) } @@ -277,8 +296,11 @@ func TestCloudformationStack_Remove_Stack_UpdateInProgress(t *testing.T) { stack: &cloudformation.Stack{ StackName: aws.String("foobar"), }, + featureFlags: &featureflag.FeatureFlags{}, } + stack.featureFlags.New("DisableDeletionProtection_CloudformationStack", ptr.Bool(true), ptr.Bool(true)) + gomock.InOrder( mockCloudformation.EXPECT().DescribeStacks(gomock.Eq(&cloudformation.DescribeStacksInput{ StackName: aws.String("foobar"), @@ -303,7 +325,7 @@ func TestCloudformationStack_Remove_Stack_UpdateInProgress(t *testing.T) { })).Return(nil), ) - err := stack.Remove() + err := stack.Remove(context.TODO()) a.Nil(err) }) } diff --git a/resources/cloudformation-stackset_test.go b/resources/cloudformation-stackset_test.go index 90538ad9..f07e5798 100644 --- a/resources/cloudformation-stackset_test.go +++ b/resources/cloudformation-stackset_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -74,7 +73,7 @@ func TestCloudformationStackSet_Remove(t *testing.T) { StackSetName: aws.String("foobar"), })).Return(&cloudformation.DeleteStackSetOutput{}, nil) - err := stackSet.Remove() + err := stackSet.Remove(context.TODO()) a.Nil(err) } @@ -149,7 +148,7 @@ func TestCloudformationStackSet_Remove_MultipleAccounts(t *testing.T) { StackSetName: aws.String("foobar"), })).Return(&cloudformation.DeleteStackSetOutput{}, nil) - err := stackSet.Remove() + err := stackSet.Remove(context.TODO()) a.Nil(err) } @@ -196,6 +195,6 @@ func TestCloudformationStackSet_Remove_DeleteStackInstanceFailed(t *testing.T) { }, }, nil) - err := stackSet.Remove() + err := stackSet.Remove(context.TODO()) a.EqualError(err, "unable to delete stackSet=foobar operationId=o1 status=FAILED") } diff --git a/resources/cloudformation-type_test.go b/resources/cloudformation-type_test.go index a302b30f..67b6ded0 100644 --- a/resources/cloudformation-type_test.go +++ b/resources/cloudformation-type_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -63,7 +62,6 @@ func TestCloudformationType_Remove(t *testing.T) { Arn: aws.String("foobar"), }) - err := cfnType.Remove() + err := cfnType.Remove(context.TODO()) a.Nil(err) - } diff --git a/resources/iam-group-policies_mock_test.go b/resources/iam-group-policies_mock_test.go index 961e84ac..eee966a7 100644 --- a/resources/iam-group-policies_mock_test.go +++ b/resources/iam-group-policies_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -32,6 +31,6 @@ func Test_Mock_IAMGroupPolicy_Remove(t *testing.T) { GroupName: aws.String(iamGroupPolicy.groupName), })).Return(&iam.DeleteGroupPolicyOutput{}, nil) - err := iamGroupPolicy.Remove() + err := iamGroupPolicy.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-group-policy-attachments_mock_test.go b/resources/iam-group-policy-attachments_mock_test.go index a767439a..145344a2 100644 --- a/resources/iam-group-policy-attachments_mock_test.go +++ b/resources/iam-group-policy-attachments_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -33,6 +32,6 @@ func Test_Mock_IAMGroupPolicyAttachment_Remove(t *testing.T) { GroupName: aws.String(iamGroupPolicyAttachment.groupName), })).Return(&iam.DetachGroupPolicyOutput{}, nil) - err := iamGroupPolicyAttachment.Remove() + err := iamGroupPolicyAttachment.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-groups_mock_test.go b/resources/iam-groups_mock_test.go index 634c4471..83a2b362 100644 --- a/resources/iam-groups_mock_test.go +++ b/resources/iam-groups_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -30,6 +29,6 @@ func Test_Mock_IAMGroup_Remove(t *testing.T) { GroupName: aws.String(iamGroup.name), })).Return(&iam.DeleteGroupOutput{}, nil) - err := iamGroup.Remove() + err := iamGroup.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-instance-profile-role_mock_test.go b/resources/iam-instance-profile-role_mock_test.go index e24a3970..897f993a 100644 --- a/resources/iam-instance-profile-role_mock_test.go +++ b/resources/iam-instance-profile-role_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -36,6 +35,6 @@ func Test_Mock_IAMInstanceProfileRole_Remove(t *testing.T) { InstanceProfileName: iamInstanceProfileRole.profile.InstanceProfileName, })).Return(&iam.RemoveRoleFromInstanceProfileOutput{}, nil) - err := iamInstanceProfileRole.Remove() + err := iamInstanceProfileRole.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-instance-profiles_mock_test.go b/resources/iam-instance-profiles_mock_test.go index 12474890..263f36d1 100644 --- a/resources/iam-instance-profiles_mock_test.go +++ b/resources/iam-instance-profiles_mock_test.go @@ -30,6 +30,6 @@ func Test_Mock_IAMInstanceProfile_Remove(t *testing.T) { InstanceProfileName: aws.String(iamInstanceProfile.name), })).Return(&iam.DeleteInstanceProfileOutput{}, nil) - err := iamInstanceProfile.Remove() + err := iamInstanceProfile.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-login-profiles_mock_test.go b/resources/iam-login-profiles_mock_test.go index 8285b6bf..db6d0161 100644 --- a/resources/iam-login-profiles_mock_test.go +++ b/resources/iam-login-profiles_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -30,6 +29,6 @@ func Test_Mock_IAMLoginProfile_Remove(t *testing.T) { UserName: aws.String(iamLoginProfile.name), })).Return(&iam.DeleteLoginProfileOutput{}, nil) - err := iamLoginProfile.Remove() + err := iamLoginProfile.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-open-id-connect-provider_mock_test.go b/resources/iam-open-id-connect-provider_mock_test.go index f49cd49a..5ffff0bb 100644 --- a/resources/iam-open-id-connect-provider_mock_test.go +++ b/resources/iam-open-id-connect-provider_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -30,6 +29,6 @@ func Test_Mock_IAMOpenIDConnectProvider_Remove(t *testing.T) { OpenIDConnectProviderArn: aws.String(iamOpenIDConnectProvider.arn), })).Return(&iam.DeleteOpenIDConnectProviderOutput{}, nil) - err := iamOpenIDConnectProvider.Remove() + err := iamOpenIDConnectProvider.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-policies_mock_test.go b/resources/iam-policies_mock_test.go index 89592017..dee908b5 100644 --- a/resources/iam-policies_mock_test.go +++ b/resources/iam-policies_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -43,7 +42,7 @@ func Test_Mock_IAMPolicy_Remove(t *testing.T) { PolicyArn: aws.String(iamPolicy.arn), })).Return(&iam.DeletePolicyOutput{}, nil) - err := iamPolicy.Remove() + err := iamPolicy.Remove(context.TODO()) a.Nil(err) } @@ -94,6 +93,6 @@ func Test_Mock_IAMPolicy_WithVersions_Remove(t *testing.T) { PolicyArn: aws.String(iamPolicy.arn), })).Return(&iam.DeletePolicyOutput{}, nil) - err := iamPolicy.Remove() + err := iamPolicy.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-role-policy-attachments_mock_test.go b/resources/iam-role-policy-attachments_mock_test.go index c6e5e9c7..ecba6f42 100644 --- a/resources/iam-role-policy-attachments_mock_test.go +++ b/resources/iam-role-policy-attachments_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -35,6 +34,6 @@ func Test_Mock_IAMRolePolicyAttachment_Remove(t *testing.T) { PolicyArn: aws.String(iamRolePolicyAttachment.policyArn), })).Return(&iam.DetachRolePolicyOutput{}, nil) - err := iamRolePolicyAttachment.Remove() + err := iamRolePolicyAttachment.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-role-policy_mock_test.go b/resources/iam-role-policy_mock_test.go index d939ca5b..d0c55d89 100644 --- a/resources/iam-role-policy_mock_test.go +++ b/resources/iam-role-policy_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -34,6 +33,6 @@ func Test_Mock_IAMRolePolicy_Remove(t *testing.T) { PolicyName: aws.String(iamRolePolicy.policyName), })).Return(&iam.DeleteRolePolicyOutput{}, nil) - err := iamRolePolicy.Remove() + err := iamRolePolicy.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-roles_mock_test.go b/resources/iam-roles_mock_test.go index 1ffd3564..9a69e647 100644 --- a/resources/iam-roles_mock_test.go +++ b/resources/iam-roles_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -32,6 +31,6 @@ func Test_Mock_IAMRole_Remove(t *testing.T) { RoleName: aws.String(iamRole.name), })).Return(&iam.DeleteRoleOutput{}, nil) - err := iamRole.Remove() + err := iamRole.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-saml-provider_mock_test.go b/resources/iam-saml-provider_mock_test.go index 4795d092..f4853c3e 100644 --- a/resources/iam-saml-provider_mock_test.go +++ b/resources/iam-saml-provider_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -29,6 +28,6 @@ func Test_Mock_IAMSAMLProvider_Remove(t *testing.T) { SAMLProviderArn: &iamSAMLProvider.arn, })).Return(&iam.DeleteSAMLProviderOutput{}, nil) - err := iamSAMLProvider.Remove() + err := iamSAMLProvider.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-server-certificate_mock_test.go b/resources/iam-server-certificate_mock_test.go index 8cb1b327..ae35a6cb 100644 --- a/resources/iam-server-certificate_mock_test.go +++ b/resources/iam-server-certificate_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -29,6 +28,6 @@ func Test_Mock_IAMServerCertificate_Remove(t *testing.T) { ServerCertificateName: &iamServerCertificate.name, })).Return(&iam.DeleteServerCertificateOutput{}, nil) - err := iamServerCertificate.Remove() + err := iamServerCertificate.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-service-specific-credentials_mock_test.go b/resources/iam-service-specific-credentials_mock_test.go index 519d996c..83276c84 100644 --- a/resources/iam-service-specific-credentials_mock_test.go +++ b/resources/iam-service-specific-credentials_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -34,6 +33,6 @@ func Test_Mock_IAMServiceSpecificCredential_Remove(t *testing.T) { ServiceSpecificCredentialId: aws.String(iamServiceSpecificCredential.id), })).Return(&iam.DeleteServiceSpecificCredentialOutput{}, nil) - err := iamServiceSpecificCredential.Remove() + err := iamServiceSpecificCredential.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-signing-certificate_mock_test.go b/resources/iam-signing-certificate_mock_test.go index 143da446..d5c7595a 100644 --- a/resources/iam-signing-certificate_mock_test.go +++ b/resources/iam-signing-certificate_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -33,6 +32,6 @@ func Test_Mock_IAMSigningCertificate_Remove(t *testing.T) { CertificateId: iamSigningCertificate.certificateId, })).Return(&iam.DeleteSigningCertificateOutput{}, nil) - err := iamSigningCertificate.Remove() + err := iamSigningCertificate.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-user-access-key_mock_test.go b/resources/iam-user-access-key_mock_test.go index 6b225df5..659e01d5 100644 --- a/resources/iam-user-access-key_mock_test.go +++ b/resources/iam-user-access-key_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -33,6 +32,6 @@ func Test_Mock_IAMUserAccessKey_Remove(t *testing.T) { UserName: aws.String(iamUserAccessKey.userName), })).Return(&iam.DeleteAccessKeyOutput{}, nil) - err := iamUserAccessKey.Remove() + err := iamUserAccessKey.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-user-group-attachments_mock_test.go b/resources/iam-user-group-attachments_mock_test.go index 94f18678..06e7d592 100644 --- a/resources/iam-user-group-attachments_mock_test.go +++ b/resources/iam-user-group-attachments_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -32,6 +31,6 @@ func Test_Mock_IAMUserGroup_Remove(t *testing.T) { GroupName: aws.String(iamUserGroup.groupName), })).Return(&iam.RemoveUserFromGroupOutput{}, nil) - err := iamUserGroup.Remove() + err := iamUserGroup.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-user-policy-attachment_mock_test.go b/resources/iam-user-policy-attachment_mock_test.go index 4e663a64..c4014005 100644 --- a/resources/iam-user-policy-attachment_mock_test.go +++ b/resources/iam-user-policy-attachment_mock_test.go @@ -33,6 +33,6 @@ func Test_Mock_IAMUserPolicyAttachment_Remove(t *testing.T) { PolicyArn: aws.String(iamUserPolicyAttachment.policyArn), })).Return(&iam.DetachUserPolicyOutput{}, nil) - err := iamUserPolicyAttachment.Remove() + err := iamUserPolicyAttachment.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-user-policy_mock_test.go b/resources/iam-user-policy_mock_test.go index 53f2b4dc..302ebbe3 100644 --- a/resources/iam-user-policy_mock_test.go +++ b/resources/iam-user-policy_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -32,6 +31,6 @@ func Test_Mock_IAMUserPolicy_Remove(t *testing.T) { PolicyName: aws.String(iamUserPolicy.policyName), })).Return(&iam.DeleteUserPolicyOutput{}, nil) - err := iamUserPolicy.Remove() + err := iamUserPolicy.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-user-ssh-keys_mock_test.go b/resources/iam-user-ssh-keys_mock_test.go index 7d69ea08..4af5b6ea 100644 --- a/resources/iam-user-ssh-keys_mock_test.go +++ b/resources/iam-user-ssh-keys_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -32,6 +31,6 @@ func Test_Mock_IAMUserSSHKeys_Remove(t *testing.T) { SSHPublicKeyId: aws.String(iamUserSSHKey.sshKeyID), })).Return(&iam.DeleteSSHPublicKeyOutput{}, nil) - err := iamUserSSHKey.Remove() + err := iamUserSSHKey.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-users_mock_test.go b/resources/iam-users_mock_test.go index e2bf6fa0..6652c9bf 100644 --- a/resources/iam-users_mock_test.go +++ b/resources/iam-users_mock_test.go @@ -30,6 +30,6 @@ func Test_Mock_IAMUser_Remove(t *testing.T) { UserName: aws.String(iamUser.name), })).Return(&iam.DeleteUserOutput{}, nil) - err := iamUser.Remove() + err := iamUser.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/iam-users_test.go b/resources/iam-users_test.go index e966a754..d159851c 100644 --- a/resources/iam-users_test.go +++ b/resources/iam-users_test.go @@ -4,7 +4,6 @@ package resources import ( "context" - "errors" "testing" @@ -40,7 +39,7 @@ func Test_IAMUser_Remove(t *testing.T) { tags: createInput.Tags, } - removeError := iamUser.Remove() + removeError := iamUser.Remove(context.TODO()) assert.NoError(t, removeError) _, err = svc.GetUser(&iam.GetUserInput{ diff --git a/resources/iam-virtual-mfa-devices_mock_test.go b/resources/iam-virtual-mfa-devices_mock_test.go index 65ff5bcc..a7797f23 100644 --- a/resources/iam-virtual-mfa-devices_mock_test.go +++ b/resources/iam-virtual-mfa-devices_mock_test.go @@ -2,7 +2,6 @@ package resources import ( "context" - "testing" "github.com/golang/mock/gomock" @@ -36,6 +35,6 @@ func Test_Mock_IAMVirtualMFADevice_Remove(t *testing.T) { SerialNumber: aws.String(iamVirtualMFADevice.serialNumber), })).Return(&iam.DeleteVirtualMFADeviceOutput{}, nil) - err := iamVirtualMFADevice.Remove() + err := iamVirtualMFADevice.Remove(context.TODO()) a.Nil(err) } diff --git a/resources/kms-keys_test.go b/resources/kms-keys_test.go index c0efe8e0..b26f83c0 100644 --- a/resources/kms-keys_test.go +++ b/resources/kms-keys_test.go @@ -4,17 +4,18 @@ package resources import ( "context" - "fmt" + "testing" + + "github.com/gotidy/ptr" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/kms" "github.com/aws/aws-sdk-go/service/sts" - "github.com/gotidy/ptr" - "github.com/pkg/errors" - "github.com/stretchr/testify/assert" - "testing" ) func Test_KMSKey_Remove(t *testing.T) { @@ -53,7 +54,7 @@ func Test_KMSKey_Remove(t *testing.T) { id: *out.KeyMetadata.KeyId, } - removeError := kmsKey.Remove() + removeError := kmsKey.Remove(context.TODO()) assert.NoError(t, removeError) _, err = svc.DescribeKey(&kms.DescribeKeyInput{