From b185389ca01c0c7d1d2082220d30ca0f5dae4ff5 Mon Sep 17 00:00:00 2001 From: "Gabriela S. Soria" Date: Tue, 24 Oct 2023 17:44:33 -0700 Subject: [PATCH 1/2] Add CodeGuru Reviewer RepositoryAssociation support Signed-off-by: Gabriela S. Soria --- ...odegurureviewer-repository-associations.go | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 resources/codegurureviewer-repository-associations.go diff --git a/resources/codegurureviewer-repository-associations.go b/resources/codegurureviewer-repository-associations.go new file mode 100644 index 000000000..d0dbb6c43 --- /dev/null +++ b/resources/codegurureviewer-repository-associations.go @@ -0,0 +1,71 @@ +package resources + +import ( + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/codegurureviewer" + "github.com/rebuy-de/aws-nuke/v2/pkg/types" +) + +type CodeGuruReviewerRepositoryAssociation struct { + svc *codegurureviewer.CodeGuruReviewer + AssociationArn *string + AssociationId *string + Name *string + Owner *string + ProviderType *string +} + +func init() { + register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations) +} + +func ListCodeGuruReviewerRepositoryAssociations(sess *session.Session) ([]Resource, error) { + svc := codegurureviewer.New(sess) + resources := []Resource{} + + params := &codegurureviewer.ListRepositoryAssociationsInput{} + + for { + resp, err := svc.ListRepositoryAssociations(params) + if err != nil { + return nil, err + } + + for _, association := range resp.RepositoryAssociationSummaries { + resources = append(resources, &CodeGuruReviewerRepositoryAssociation{ + svc: svc, + AssociationArn: association.AssociationArn, + AssociationId: association.AssociationId, + Name: association.Name, + Owner: association.Owner, + ProviderType: association.ProviderType, + }) + } + + if resp.NextToken == nil { + break + } + + params.NextToken = resp.NextToken + } + + return resources, nil +} + +func (f *CodeGuruReviewerRepositoryAssociation) Remove() error { + _, err := f.svc.DisassociateRepository(&codegurureviewer.DisassociateRepositoryInput{ + AssociationArn: f.AssociationArn, + }) + return err +} + +func (f *CodeGuruReviewerRepositoryAssociation) Properties() types.Properties { + properties := types.NewProperties() + properties. + Set("AssociationArn", f.AssociationArn) + properties.Set("AssociationId", f.AssociationId) + properties.Set("Name", f.Name) + properties.Set("Owner", f.Owner) + properties.Set("ProviderType", f.ProviderType) + return properties +} From 888f8d2a9d679d9c6f069e58424d2605e2a5805a Mon Sep 17 00:00:00 2001 From: "Gabriela S. Soria" Date: Tue, 31 Oct 2023 09:22:51 -0700 Subject: [PATCH 2/2] CL-732 | add cloud control mapping for `RepositoryAssociation` Signed-off-by: Gabriela S. Soria --- resources/codegurureviewer-repository-associations.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/codegurureviewer-repository-associations.go b/resources/codegurureviewer-repository-associations.go index d0dbb6c43..e630ad949 100644 --- a/resources/codegurureviewer-repository-associations.go +++ b/resources/codegurureviewer-repository-associations.go @@ -16,7 +16,8 @@ type CodeGuruReviewerRepositoryAssociation struct { } func init() { - register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations) + register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations, + mapCloudControl("AWS::CodeGuruReviewer::RepositoryAssociation")) } func ListCodeGuruReviewerRepositoryAssociations(sess *session.Session) ([]Resource, error) {