Skip to content

Commit

Permalink
feat(resource): add CodeGuru Reviewer RepositoryAssociation support
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriela S. Soria <gsoria@oreilly.com>

CL-732 | add cloud control mapping for `RepositoryAssociation`

Signed-off-by: Gabriela S. Soria <gsoria@oreilly.com>
  • Loading branch information
gsoria authored and ekristen committed Sep 30, 2024
1 parent f4c02e9 commit ed78a91
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions resources/codegurureviewer-repository-associations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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,
mapCloudControl("AWS::CodeGuruReviewer::RepositoryAssociation"))
}

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
}

0 comments on commit ed78a91

Please sign in to comment.