-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resource/aws_codebuild_report_group: Add delete_reports argument and …
…service package refactoring (#17338) Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccAWSCodeBuildReportGroup_disappears (10.64s) --- PASS: TestAccAWSCodeBuildReportGroup_deleteReports (13.91s) --- PASS: TestAccAWSCodeBuildReportGroup_basic (14.42s) --- PASS: TestAccAWSCodeBuildReportGroup_tags (30.94s) --- PASS: TestAccAWSCodeBuildReportGroup_export_s3 (46.32s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccAWSCodeBuildReportGroup_disappears (14.58s) --- PASS: TestAccAWSCodeBuildReportGroup_basic (19.24s) --- PASS: TestAccAWSCodeBuildReportGroup_deleteReports (19.27s) --- PASS: TestAccAWSCodeBuildReportGroup_tags (44.22s) --- PASS: TestAccAWSCodeBuildReportGroup_export_s3 (50.66s) ```
- Loading branch information
Showing
7 changed files
with
230 additions
and
41 deletions.
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.