-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
have metadata item fail on create if the key is already present #3063
have metadata item fail on create if the key is already present #3063
Conversation
7e038dd
to
4d4d817
Compare
@@ -56,7 +56,7 @@ func resourceComputeProjectMetadataItemCreate(d *schema.ResourceData, meta inter | |||
key := d.Get("key").(string) | |||
val := d.Get("value").(string) | |||
|
|||
err = updateComputeCommonInstanceMetadata(config, projectID, key, &val, int(d.Timeout(schema.TimeoutCreate).Minutes())) | |||
err = updateComputeCommonInstanceMetadata(config, projectID, key, &val, int(d.Timeout(schema.TimeoutCreate).Minutes()), true) |
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.
nit: You can "name" the values provided to the function by creating a type instead of using raw bools.
type metadataPresentBehavior bool
const (
failIfPresent metadataPresentBehavior = true
expectPresent metadataPresentBehavior = false
)
The behaviour of the function ends up being a little easier to read from the callsite, instead of needing to check the param names.
updateComputeCommonInstanceMetadata(config, projectID, key, &val, int(d.Timeout(schema.TimeoutCreate).Minutes()), failIfPresent)
…leCloudPlatform#3063) * have metadata item fail on create if the key is already present * name booleans * compile
Fixes hashicorp/terraform-provider-google#5514.
Also cleaned up tests a bit while I was here.
Release Note Template for Downstream PRs (will be copied)