forked from rebuy-de/aws-nuke
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
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 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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. 😸
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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