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

Add override_artifact_name flag to aws_codebuild_project #7824

Conversation

jckuester
Copy link
Contributor

@jckuester jckuester commented Mar 6, 2019

See issue #5908

Changes proposed in this pull request:

Add override_artifact_name to aws_codebuild_project resource.

Output from acceptance testing:

make testacc TESTARGS='-run=TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName*' 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName* -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName
=== PAUSE TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName
=== CONT  TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName
--- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (57.42s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	57.476s

@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/codebuild Issues and PRs that pertain to the codebuild service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Mar 6, 2019
@jckuester jckuester force-pushed the feature/codebuild_project_override_artifact_flag branch from ff80436 to 6046c1e Compare March 20, 2019 11:52
@megafatsquirrel
Copy link

I need this feature to help support my work. What is required to help get this merged?

@brijshah
Copy link

any update as to when this will be merged?

@aeschright aeschright requested a review from a team June 26, 2019 00:53
@brijshah
Copy link

any chance this can be reviewed??

@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 31, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this, @jckuester. I think the panics I was running into below were because the override_artifact_name schema was missing from the secondary_artifacts schema. Once I added that and fixed up some of the testing expectations, this was good to get in.

--- PASS: TestAccAWSCodeBuildProject_Artifacts_EncryptionDisabled (37.77s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (54.22s)
--- PASS: TestAccAWSCodeBuildProject_BadgeEnabled (34.33s)
--- PASS: TestAccAWSCodeBuildProject_basic (34.57s)
--- PASS: TestAccAWSCodeBuildProject_BuildTimeout (43.07s)
--- PASS: TestAccAWSCodeBuildProject_Cache (80.46s)
--- PASS: TestAccAWSCodeBuildProject_Description (33.25s)
--- PASS: TestAccAWSCodeBuildProject_EncryptionKey (53.10s)
--- PASS: TestAccAWSCodeBuildProject_Environment_Certificate (39.82s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable (57.67s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Type (43.02s)
--- PASS: TestAccAWSCodeBuildProject_Environment_RegistryCredential (44.04s)
--- PASS: TestAccAWSCodeBuildProject_importBasic (35.40s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_CloudWatchLogs (53.99s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_S3Logs (82.81s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts (37.50s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_CodeCommit (23.82s)
--- PASS: TestAccAWSCodeBuildProject_Source_Auth (34.42s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitCloneDepth (42.88s)
--- PASS: TestAccAWSCodeBuildProject_Source_InsecureSSL (42.26s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_Bitbucket (42.80s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub (42.99s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise (43.17s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_Bitbucket (23.70s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodeCommit (23.30s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodePipeline (23.01s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_GitHubEnterprise (33.67s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSource (30.90s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSourceInvalid (12.53s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_S3 (39.34s)
--- PASS: TestAccAWSCodeBuildProject_Tags (38.73s)
--- PASS: TestAccAWSCodeBuildProject_VpcConfig (59.73s)
--- PASS: TestAccAWSCodeBuildProject_WindowsContainer (29.99s)

@@ -1064,6 +1076,7 @@ func resourceAwsCodeBuildProjectArtifactsHash(v interface{}) int {
m := v.(map[string]interface{})

buf.WriteString(fmt.Sprintf("%s-", m["type"].(string)))
buf.WriteString(fmt.Sprintf("%t-", m["override_artifact_name"].(bool)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent panics like the below, found with other acceptance tests:

panic: interface conversion: interface {} is nil, not bool

goroutine 3492 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsCodeBuildProjectArtifactsHash(0x58d8340, 0xc0044ac210, 0xc011f4dbd8)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_codebuild_project.go:1366 +0x39a

This needed a nil check:

	if v, ok := m["override_artifact_name"]; ok {
		buf.WriteString(fmt.Sprintf("%t-", v.(bool)))
	}

@@ -565,6 +570,8 @@ func expandProjectArtifactData(data map[string]interface{}) codebuild.ProjectArt
projectArtifacts.EncryptionDisabled = aws.Bool(data["encryption_disabled"].(bool))
}

projectArtifacts.OverrideArtifactName = aws.Bool(data["override_artifact_name"].(bool))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent panics like the below, found with other acceptance tests:

panic: interface conversion: interface {} is nil, not bool

goroutine 8222 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.expandProjectArtifactData(0xc00ec050b0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_codebuild_project.go:676 +0xa0e
github.com/terraform-providers/terraform-provider-aws/aws.expandProjectSecondaryArtifacts(0xc00045b180, 0x0, 0xc000e26a99, 0xc00beabd20)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_codebuild_project.go:649 +0x14e
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsCodeBuildProjectCreate(0xc00045b180, 0x53bf4a0, 0xc00bbf8480, 0x2, 0xada4560)
	/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws-deux/aws/resource_aws_codebuild_project.go:554 +0x16e

This needed a nil check:

	if v, ok := data["override_artifact_name"]; ok {
		projectArtifacts.OverrideArtifactName = aws.Bool(v.(bool))
	}

Copy link
Contributor Author

@jckuester jckuester Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing @bflad. Just wondering for the future: my assumption was that override_artifact_name has a default value and therefore cannot be nil?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there were two separate configuration block schemas (artifacts which had override_artifact_name declared and secondary_artifacts which did not have override_artifact_name declared), you're correct that the Default meant that the map key was always present when working with artifacts, but it was the secondary_artifacts map that did not have the override_artifact_name key since it was not declared in the schema. 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always recommend running the acceptance testing for the whole resource to tease out issues like these 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. I just realized that updates for secondary_artifacts are not working correctly yet, so I added some more tests to cover this and tried to provide a fix: #9652

@bflad bflad added this to the v2.22.0 milestone Jul 31, 2019
@bflad bflad merged commit 6046c1e into hashicorp:master Jul 31, 2019
bflad added a commit that referenced this pull request Jul 31, 2019
…fact_name schema, prevent panics, and use ImportStateVerify testing instead of TypeSet value testing

The Terraform Provider SDK in 0.12 does not make it easy to determine the correct TypeSet hash value for state attributes. Also fixes the long broken TestAccAWSCodeBuildProject_VpcConfig test.

Reference: #7824

Output from acceptance testing:

```
--- PASS: TestAccAWSCodeBuildProject_Artifacts_EncryptionDisabled (37.77s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (54.22s)
--- PASS: TestAccAWSCodeBuildProject_BadgeEnabled (34.33s)
--- PASS: TestAccAWSCodeBuildProject_basic (34.57s)
--- PASS: TestAccAWSCodeBuildProject_BuildTimeout (43.07s)
--- PASS: TestAccAWSCodeBuildProject_Cache (80.46s)
--- PASS: TestAccAWSCodeBuildProject_Description (33.25s)
--- PASS: TestAccAWSCodeBuildProject_EncryptionKey (53.10s)
--- PASS: TestAccAWSCodeBuildProject_Environment_Certificate (39.82s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable (57.67s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Type (43.02s)
--- PASS: TestAccAWSCodeBuildProject_Environment_RegistryCredential (44.04s)
--- PASS: TestAccAWSCodeBuildProject_importBasic (35.40s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_CloudWatchLogs (53.99s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_S3Logs (82.81s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts (37.50s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_CodeCommit (23.82s)
--- PASS: TestAccAWSCodeBuildProject_Source_Auth (34.42s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitCloneDepth (42.88s)
--- PASS: TestAccAWSCodeBuildProject_Source_InsecureSSL (42.26s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_Bitbucket (42.80s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub (42.99s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise (43.17s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_Bitbucket (23.70s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodeCommit (23.30s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodePipeline (23.01s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_GitHubEnterprise (33.67s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSource (30.90s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSourceInvalid (12.53s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_S3 (39.34s)
--- PASS: TestAccAWSCodeBuildProject_Tags (38.73s)
--- PASS: TestAccAWSCodeBuildProject_VpcConfig (59.73s)
--- PASS: TestAccAWSCodeBuildProject_WindowsContainer (29.99s)
```
bflad added a commit that referenced this pull request Jul 31, 2019
@jckuester jckuester deleted the feature/codebuild_project_override_artifact_flag branch July 31, 2019 17:56
@ghost
Copy link

ghost commented Aug 1, 2019

This has been released in version 2.22.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 2, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/codebuild Issues and PRs that pertain to the codebuild service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants