-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(resource): add CodeGuru Reviewer RepositoryAssociation support
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
Showing
1 changed file
with
72 additions
and
0 deletions.
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,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 | ||
} |