Skip to content

Commit 54c1ff9

Browse files
committed
Add support for codebuild builds
Signed-off-by: Gabriela S. Soria <[email protected]>
1 parent 91e2670 commit 54c1ff9

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

resources/codebuild-builds.go

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 CodeBuildBuild struct {
10+
svc *codebuild.CodeBuild
11+
Id *string
12+
}
13+
14+
func init() {
15+
register("CodeBuildBuild", ListCodeBuildBuild)
16+
}
17+
18+
func ListCodeBuildBuild(sess *session.Session) ([]Resource, error) {
19+
svc := codebuild.New(sess)
20+
resources := []Resource{}
21+
22+
params := &codebuild.ListBuildsInput{}
23+
24+
for {
25+
resp, err := svc.ListBuilds(params)
26+
if err != nil {
27+
return nil, err
28+
}
29+
30+
for _, build := range resp.Ids {
31+
resources = append(resources, &CodeBuildBuild{
32+
svc: svc,
33+
Id: build,
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 *CodeBuildBuild) Remove() error {
48+
_, err := f.svc.BatchDeleteBuilds(&codebuild.BatchDeleteBuildsInput{
49+
Ids: []*string{f.Id},
50+
})
51+
52+
return err
53+
}
54+
55+
func (f *CodeBuildBuild) Properties() types.Properties {
56+
properties := types.NewProperties()
57+
properties.
58+
Set("Id", f.Id)
59+
return properties
60+
}

0 commit comments

Comments
 (0)