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

packer-sdc: return errors on duplicate tag/field #164

Merged
merged 1 commit into from Mar 7, 2023

Conversation

lbajolet-hashicorp
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp commented Feb 24, 2023

When generating the flattened structures for a HCL2-compatible config, we didn't prevent users from defining duplicate fields or tags, instead warning them.

The warning in itself did not prevent the resulting structures from being generated, leading into a situation where the first definition of the arg/tag would have precedence over the subsequent definitions, leading to shadowing their definitions.

To prevent this in the future, we immediately return an error when such a conflict is introduced, and signal to the user which attribute is problematic.

Related to: hashicorp/packer-plugin-alicloud#107
Related to: hashicorp/packer-plugin-alicloud#105

@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner February 24, 2023 15:05
@lbajolet-hashicorp lbajolet-hashicorp force-pushed the prevent_duplicate_tags_fields_hcl2 branch 2 times, most recently from 5b3b1c0 to 0cbe829 Compare February 24, 2023 15:11
When generating the flattened structures for a HCL2-compatible config,
we didn't prevent users from defining duplicate fields or tags, instead
warning them.

The warning in itself did not prevent the resulting structures from
being generated, leading into a situation where the first definition of
the arg/tag would have precedence over the subsequent definitions,
leading to shadowing their definitions.

To prevent this in the future, we immediately return an error when such
a conflict is introduced, and signal to the user which attribute is
problematic.
@nywilken nywilken added the bug Something isn't working label Mar 7, 2023
@nywilken nywilken force-pushed the prevent_duplicate_tags_fields_hcl2 branch from 0cbe829 to b1b7974 Compare March 7, 2023 21:00
Copy link
Member

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

Nice catch. This looks good. I rebased onto the latest main. I will merge once all goes green.

@nywilken
Copy link
Member

nywilken commented Mar 7, 2023

The failing windows test does not having anything to do with this change and is already fixed in a subsequent PR; merging.

@nywilken nywilken merged commit d160ce0 into main Mar 7, 2023
@nywilken nywilken deleted the prevent_duplicate_tags_fields_hcl2 branch March 7, 2023 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants