Skip to content

Commit fd2fcaf

Browse files
committed
Add support for codebuild report group
Signed-off-by: Gabriela S. Soria <[email protected]>
1 parent 08d196c commit fd2fcaf

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws/session"
5+
"github.com/aws/aws-sdk-go/service/codebuild"
6+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
7+
)
8+
9+
type CodeBuildReportGroup struct {
10+
svc *codebuild.CodeBuild
11+
Arn *string
12+
}
13+
14+
func init() {
15+
register("CodeBuildReportGroup", ListCodeBuildReportGroup)
16+
}
17+
18+
func ListCodeBuildReportGroup(sess *session.Session) ([]Resource, error) {
19+
svc := codebuild.New(sess)
20+
resources := []Resource{}
21+
22+
params := &codebuild.ListReportGroupsInput{}
23+
24+
for {
25+
resp, err := svc.ListReportGroups(params)
26+
if err != nil {
27+
return nil, err
28+
}
29+
30+
for _, reportGroup := range resp.ReportGroups {
31+
resources = append(resources, &CodeBuildReportGroup{
32+
svc: svc,
33+
Arn: reportGroup,
34+
})
35+
}
36+
37+
if resp.NextToken == nil {
38+
break
39+
}
40+
41+
params.NextToken = resp.NextToken
42+
}
43+
44+
return resources, nil
45+
}
46+
47+
func (f *CodeBuildReportGroup) Remove() error {
48+
_, err := f.svc.DeleteReportGroup(&codebuild.DeleteReportGroupInput{
49+
Arn: f.Arn,
50+
})
51+
52+
return err
53+
}
54+
55+
func (f *CodeBuildReportGroup) Properties() types.Properties {
56+
properties := types.NewProperties()
57+
properties.
58+
Set("Arn", f.Arn)
59+
return properties
60+
}

0 commit comments

Comments
 (0)