Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeGuru Reviewer RepositoryAssociation support #18

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions resources/codegurureviewer-repository-associations.go
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify the CC API association here to override? I think the following is the syntax, but I wouldn't blindly accept this suggestion if I were you. 😸

Suggested change
register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations)
register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations,
mapCloudControl("AWS::CodeGuruReviewer::RepositoryAssociation"))

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this! The cloud control resource doesn't work, do you think we should include the association anyways?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. If I remember correctly, the association essentially tells AWS Nuke to use the module instead of the CC API if both happen to be specified in someone's configuration.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Addressed in 888f8d2

}

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
}
Loading