This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 724
Add codebuild support #1125
Closed
Closed
Add codebuild support #1125
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
de0c8ca
Add support for codebuild builds
gsoria ce0b29b
Add support for codebuild build batches
gsoria 1caa1a6
Add support for codebuild report group
gsoria 944c7f3
Add support for codebuild source credentials
gsoria b00ca39
Remove unnecessary validation
gsoria 63095bd
Merge branch 'main' into add-codebuild-support
gsoria f9e0300
Add a comment regarding endpoint not paginated
gsoria c69a770
Merge branch 'main' into add-codebuild-support
sstoops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type CodeBuildBuildBatch struct { | ||
svc *codebuild.CodeBuild | ||
Id *string | ||
} | ||
|
||
func init() { | ||
register("CodeBuildBuildBatch", ListCodeBuildBuildBatch) | ||
} | ||
|
||
func ListCodeBuildBuildBatch(sess *session.Session) ([]Resource, error) { | ||
svc := codebuild.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &codebuild.ListBuildBatchesInput{} | ||
|
||
for { | ||
resp, err := svc.ListBuildBatches(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, batch := range resp.Ids { | ||
resources = append(resources, &CodeBuildBuildBatch{ | ||
svc: svc, | ||
Id: batch, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *CodeBuildBuildBatch) Remove() error { | ||
_, err := f.svc.DeleteBuildBatch(&codebuild.DeleteBuildBatchInput{ | ||
Id: f.Id, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *CodeBuildBuildBatch) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties. | ||
Set("Id", f.Id) | ||
return properties | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type CodeBuildBuild struct { | ||
svc *codebuild.CodeBuild | ||
Id *string | ||
} | ||
|
||
func init() { | ||
register("CodeBuildBuild", ListCodeBuildBuild) | ||
} | ||
|
||
func ListCodeBuildBuild(sess *session.Session) ([]Resource, error) { | ||
svc := codebuild.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &codebuild.ListBuildsInput{} | ||
|
||
for { | ||
resp, err := svc.ListBuilds(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, build := range resp.Ids { | ||
resources = append(resources, &CodeBuildBuild{ | ||
svc: svc, | ||
Id: build, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *CodeBuildBuild) Remove() error { | ||
_, err := f.svc.BatchDeleteBuilds(&codebuild.BatchDeleteBuildsInput{ | ||
Ids: []*string{f.Id}, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *CodeBuildBuild) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties. | ||
Set("Id", f.Id) | ||
return properties | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type CodeBuildReportGroup struct { | ||
svc *codebuild.CodeBuild | ||
Arn *string | ||
} | ||
|
||
func init() { | ||
register("CodeBuildReportGroup", ListCodeBuildReportGroup) | ||
} | ||
|
||
func ListCodeBuildReportGroup(sess *session.Session) ([]Resource, error) { | ||
svc := codebuild.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &codebuild.ListReportGroupsInput{} | ||
|
||
for { | ||
resp, err := svc.ListReportGroups(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, reportGroup := range resp.ReportGroups { | ||
resources = append(resources, &CodeBuildReportGroup{ | ||
svc: svc, | ||
Arn: reportGroup, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *CodeBuildReportGroup) Remove() error { | ||
_, err := f.svc.DeleteReportGroup(&codebuild.DeleteReportGroupInput{ | ||
Arn: f.Arn, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *CodeBuildReportGroup) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties. | ||
Set("Arn", f.Arn) | ||
return properties | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
"github.com/rebuy-de/aws-nuke/v2/pkg/types" | ||
) | ||
|
||
type CodeBuildSourceCredential struct { | ||
svc *codebuild.CodeBuild | ||
Arn *string | ||
AuthType *string | ||
ServerType *string | ||
} | ||
|
||
func init() { | ||
register("CodeBuildSourceCredential", ListCodeBuildSourceCredential) | ||
} | ||
|
||
func ListCodeBuildSourceCredential(sess *session.Session) ([]Resource, error) { | ||
svc := codebuild.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &codebuild.ListSourceCredentialsInput{} | ||
|
||
//This endpoint[1] is not paginated, `SourceCredentialsInfo` doesn't have a `NextToken` field. | ||
//[1] https://docs.aws.amazon.com/sdk-for-go/api/service/codebuild/#SourceCredentialsInfo | ||
resp, err := svc.ListSourceCredentials(params) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, credential := range resp.SourceCredentialsInfos { | ||
resources = append(resources, &CodeBuildSourceCredential{ | ||
svc: svc, | ||
Arn: credential.Arn, | ||
}) | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *CodeBuildSourceCredential) Remove() error { | ||
_, err := f.svc.DeleteSourceCredentials(&codebuild.DeleteSourceCredentialsInput{Arn: f.Arn}) | ||
return err | ||
} | ||
|
||
func (f *CodeBuildSourceCredential) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("Arn", f.Arn) | ||
properties.Set("AuthType", f.AuthType) | ||
properties.Set("ServerType", f.ServerType) | ||
|
||
return properties | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no pagination here required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjoernhaeuser this endpoint is not paginated, SourceCredentialsInfo doesn't have a
NextToken
field.