Skip to content

Commit 12f072b

Browse files
committed
Add support for codebuild source credentials
Signed-off-by: Gabriela S. Soria <[email protected]>
1 parent fd2fcaf commit 12f072b

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 CodeBuildSourceCredential struct {
10+
svc *codebuild.CodeBuild
11+
Arn *string
12+
AuthType *string
13+
ServerType *string
14+
}
15+
16+
func init() {
17+
register("CodeBuildSourceCredential", ListCodeBuildSourceCredential)
18+
}
19+
20+
func ListCodeBuildSourceCredential(sess *session.Session) ([]Resource, error) {
21+
svc := codebuild.New(sess)
22+
resources := []Resource{}
23+
24+
params := &codebuild.ListSourceCredentialsInput{}
25+
26+
resp, err := svc.ListSourceCredentials(params)
27+
if err != nil {
28+
return nil, err
29+
}
30+
31+
if resp == nil {
32+
return nil, nil
33+
}
34+
35+
for _, credential := range resp.SourceCredentialsInfos {
36+
resources = append(resources, &CodeBuildSourceCredential{
37+
svc: svc,
38+
Arn: credential.Arn,
39+
})
40+
}
41+
42+
return resources, nil
43+
}
44+
45+
func (f *CodeBuildSourceCredential) Remove() error {
46+
_, err := f.svc.DeleteSourceCredentials(&codebuild.DeleteSourceCredentialsInput{Arn: f.Arn})
47+
return err
48+
}
49+
50+
func (f *CodeBuildSourceCredential) Properties() types.Properties {
51+
properties := types.NewProperties()
52+
properties.Set("Arn", f.Arn)
53+
properties.Set("AuthType", f.AuthType)
54+
properties.Set("ServerType", f.ServerType)
55+
56+
return properties
57+
}

0 commit comments

Comments
 (0)