Skip to content

Commit b185389

Browse files
committed
Add CodeGuru Reviewer RepositoryAssociation support
Signed-off-by: Gabriela S. Soria <[email protected]>
1 parent c2ae6d7 commit b185389

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws/session"
5+
"github.com/aws/aws-sdk-go/service/codegurureviewer"
6+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
7+
)
8+
9+
type CodeGuruReviewerRepositoryAssociation struct {
10+
svc *codegurureviewer.CodeGuruReviewer
11+
AssociationArn *string
12+
AssociationId *string
13+
Name *string
14+
Owner *string
15+
ProviderType *string
16+
}
17+
18+
func init() {
19+
register("CodeGuruReviewerRepositoryAssociation", ListCodeGuruReviewerRepositoryAssociations)
20+
}
21+
22+
func ListCodeGuruReviewerRepositoryAssociations(sess *session.Session) ([]Resource, error) {
23+
svc := codegurureviewer.New(sess)
24+
resources := []Resource{}
25+
26+
params := &codegurureviewer.ListRepositoryAssociationsInput{}
27+
28+
for {
29+
resp, err := svc.ListRepositoryAssociations(params)
30+
if err != nil {
31+
return nil, err
32+
}
33+
34+
for _, association := range resp.RepositoryAssociationSummaries {
35+
resources = append(resources, &CodeGuruReviewerRepositoryAssociation{
36+
svc: svc,
37+
AssociationArn: association.AssociationArn,
38+
AssociationId: association.AssociationId,
39+
Name: association.Name,
40+
Owner: association.Owner,
41+
ProviderType: association.ProviderType,
42+
})
43+
}
44+
45+
if resp.NextToken == nil {
46+
break
47+
}
48+
49+
params.NextToken = resp.NextToken
50+
}
51+
52+
return resources, nil
53+
}
54+
55+
func (f *CodeGuruReviewerRepositoryAssociation) Remove() error {
56+
_, err := f.svc.DisassociateRepository(&codegurureviewer.DisassociateRepositoryInput{
57+
AssociationArn: f.AssociationArn,
58+
})
59+
return err
60+
}
61+
62+
func (f *CodeGuruReviewerRepositoryAssociation) Properties() types.Properties {
63+
properties := types.NewProperties()
64+
properties.
65+
Set("AssociationArn", f.AssociationArn)
66+
properties.Set("AssociationId", f.AssociationId)
67+
properties.Set("Name", f.Name)
68+
properties.Set("Owner", f.Owner)
69+
properties.Set("ProviderType", f.ProviderType)
70+
return properties
71+
}

0 commit comments

Comments
 (0)