-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Add override_artifact_name flag to aws_codebuild_project #7824
Conversation
ff80436
to
6046c1e
Compare
I need this feature to help support my work. What is required to help get this merged? |
any update as to when this will be merged? |
any chance this can be reviewed?? |
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.
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))) |
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.
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)) |
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.
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))
}
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.
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
?
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.
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. 👍
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.
We always recommend running the acceptance testing for the whole resource to tease out issues like these 😄
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.
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
…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) ```
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! |
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! |
See issue #5908
Changes proposed in this pull request:
Add
override_artifact_name
toaws_codebuild_project
resource.Output from acceptance testing: