-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r/codebuild_report_group - Allow deleting reports for report group delete #17338
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ebc8b81
add waiter for codebuild report group
DrFaust92 3efb242
add sweeper
DrFaust92 4bb9f91
changelog
DrFaust92 ab7e6d2
add support for deleting reports
DrFaust92 83bfc12
docs
DrFaust92 ebcd0cc
move more logic into finder
DrFaust92 ef5cf69
fix import and exists checks
DrFaust92 df9eb7b
Apply suggestions from code review
bflad faa1c50
Update aws/resource_aws_codebuild_report_group_test.go
bflad 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,3 @@ | ||
```release-note:enhancement | ||
resource/aws_codebuild_report_group: Add `delete_reports` argument | ||
``` |
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,32 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
) | ||
|
||
// ReportGroupByArn returns the Report Group corresponding to the specified Arn. | ||
func ReportGroupByArn(conn *codebuild.CodeBuild, arn string) (*codebuild.ReportGroup, error) { | ||
|
||
output, err := conn.BatchGetReportGroups(&codebuild.BatchGetReportGroupsInput{ | ||
ReportGroupArns: aws.StringSlice([]string{arn}), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if output == nil { | ||
return nil, nil | ||
} | ||
|
||
if len(output.ReportGroups) == 0 { | ||
return nil, nil | ||
} | ||
|
||
reportGroup := output.ReportGroups[0] | ||
if reportGroup == nil { | ||
return nil, nil | ||
} | ||
|
||
return reportGroup, nil | ||
} |
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,29 @@ | ||
package waiter | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/terraform-providers/terraform-provider-aws/aws/internal/service/codebuild/finder" | ||
) | ||
|
||
const ( | ||
ReportGroupStatusUnknown = "Unknown" | ||
ReportGroupStatusNotFound = "NotFound" | ||
) | ||
|
||
// ReportGroupStatus fetches the Report Group and its Status | ||
func ReportGroupStatus(conn *codebuild.CodeBuild, arn string) resource.StateRefreshFunc { | ||
return func() (interface{}, string, error) { | ||
output, err := finder.ReportGroupByArn(conn, arn) | ||
if err != nil { | ||
return nil, ReportGroupStatusUnknown, err | ||
} | ||
|
||
if output == nil { | ||
return nil, ReportGroupStatusNotFound, nil | ||
} | ||
|
||
return output, aws.StringValue(output.Status), nil | ||
} | ||
} |
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,31 @@ | ||
package waiter | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/service/codebuild" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
const ( | ||
// Maximum amount of time to wait for an Operation to return Deleted | ||
ReportGroupDeleteTimeout = 2 * time.Minute | ||
) | ||
|
||
// ReportGroupDeleted waits for an ReportGroup to return Deleted | ||
func ReportGroupDeleted(conn *codebuild.CodeBuild, arn string) (*codebuild.ReportGroup, error) { | ||
stateConf := &resource.StateChangeConf{ | ||
Pending: []string{codebuild.ReportGroupStatusTypeDeleting}, | ||
Target: []string{}, | ||
Refresh: ReportGroupStatus(conn, arn), | ||
Timeout: ReportGroupDeleteTimeout, | ||
} | ||
|
||
outputRaw, err := stateConf.WaitForState() | ||
|
||
if output, ok := outputRaw.(*codebuild.ReportGroup); ok { | ||
return output, err | ||
} | ||
|
||
return nil, err | ||
} |
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
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
Oops, something went wrong.
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.
Nice!