Skip to content
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

fix build_type key exists check #20671

Merged
merged 3 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions aws/resource_aws_codebuild_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,22 @@ func resourceAwsCodeBuildWebhookUpdate(d *schema.ResourceData, meta interface{})
var err error
filterGroups := expandWebhookFilterGroups(d)

var buildType *string = nil
if v, ok := d.GetOk("build_type"); ok {
buildType = aws.String(v.(string))
}

if len(filterGroups) >= 1 {
_, err = conn.UpdateWebhook(&codebuild.UpdateWebhookInput{
ProjectName: aws.String(d.Id()),
BuildType: aws.String(d.Get("build_type").(string)),
BuildType: buildType,
FilterGroups: filterGroups,
RotateSecret: aws.Bool(false),
})
} else {
_, err = conn.UpdateWebhook(&codebuild.UpdateWebhookInput{
ProjectName: aws.String(d.Id()),
BuildType: aws.String(d.Get("build_type").(string)),
BuildType: buildType,
BranchFilter: aws.String(d.Get("branch_filter").(string)),
RotateSecret: aws.Bool(false),
})
Expand Down
7 changes: 7 additions & 0 deletions aws/resource_aws_codebuild_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ func TestAccAWSCodeBuildWebhook_BuildType(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "build_type", "BUILD"),
),
},
{
Config: testAccAWSCodeBuildWebhookConfig_GitHub(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSCodeBuildWebhookExists(resourceName, &webhook),
),
ExpectNonEmptyPlan: true,
},
{
Config: testAccAWSCodeBuildWebhookConfig_BuildType(rName, "BUILD_BATCH"),
Check: resource.ComposeTestCheckFunc(
Expand Down