Skip to content

Commit f34717f

Browse files
Adding webhook support.
1 parent ec3fa04 commit f34717f

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
File renamed without changes.

resources/codepipeline-webhooks.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws/session"
5+
"github.com/aws/aws-sdk-go/service/codepipeline"
6+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
7+
)
8+
9+
type CodePipelineWebhook struct {
10+
svc *codepipeline.CodePipeline
11+
name *string
12+
}
13+
14+
func init() {
15+
register("CodePipelineWebhook", ListCodePipelineWebhooks)
16+
}
17+
18+
func ListCodePipelineWebhooks(sess *session.Session) ([]Resource, error) {
19+
svc := codepipeline.New(sess)
20+
resources := []Resource{}
21+
22+
params := &codepipeline.ListWebhooksInput{}
23+
24+
for {
25+
resp, err := svc.ListWebhooks(params)
26+
if err != nil {
27+
return nil, err
28+
}
29+
30+
for _, webHooks := range resp.Webhooks {
31+
resources = append(resources, &CodePipelineWebhook{
32+
svc: svc,
33+
name: webHooks.Definition.Name,
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 *CodePipelineWebhook) Remove() error {
48+
_, err := f.svc.DeleteWebhook(&codepipeline.DeleteWebhookInput{
49+
Name: f.name,
50+
})
51+
52+
return err
53+
}
54+
55+
func (f *CodePipelineWebhook) Properties() types.Properties {
56+
properties := types.NewProperties()
57+
properties.Set("Name", f.name)
58+
return properties
59+
}
60+
61+
func (f *CodePipelineWebhook) String() string {
62+
return *f.name
63+
}

0 commit comments

Comments
 (0)