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

have metadata item fail on create if the key is already present #3063

Conversation

danawillow
Copy link
Contributor

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)

compute: updated `google_compute_project_metadata_item` to fail on create if its key is already present in the project metadata. 

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 61 insertions(+), 71 deletions(-))
Terraform Beta: Diff ( 3 files changed, 61 insertions(+), 72 deletions(-))

@danawillow danawillow force-pushed the tf-5514-project-metadata-item branch from 7e038dd to 4d4d817 Compare January 31, 2020 23:53
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 2 files changed, 60 insertions(+), 70 deletions(-))
Terraform Beta: Diff ( 3 files changed, 60 insertions(+), 71 deletions(-))

@@ -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)
Copy link
Member

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)

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 61 insertions(+), 77 deletions(-))
Terraform Beta: Diff ( 2 files changed, 60 insertions(+), 77 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 3 files changed, 78 insertions(+), 60 deletions(-))
Terraform Beta: Diff ( 2 files changed, 77 insertions(+), 60 deletions(-))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_compute_project_metadata_item overwrites existing key/value
4 participants