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

generate: remove additional handling of numeric values #702

Merged
merged 2 commits into from
May 14, 2024

Conversation

jacobbednarz
Copy link
Member

@jacobbednarz jacobbednarz commented May 14, 2024

In previous versions of our schema converter, we needed to handle the scenario
where a key inside of a map would contain a numeric value.

Note: This is only required for TypeMaps because it is the wild west and you
lose most of the validation with the Terraform internals when using maps.

resource "..." "..." {
  foo = {
    bar1 = "baz"
  }
}

While numeric characters in attribute keys are permitted in HCL, they must be
quoted. Inadvertently, it looks like this was also being applied to the
attribute values. While a good measure, this isn't as important as we have
better measures to detect the value type and infer it appropriately.

This commit removes the additional handling and instead relies on the explicit
.(type) check instead which covers the key and value.

In previous versions of our schema converter, we needed to handle the scenario
where a key inside of a map would contain a numeric value.

Note: This is only required for `TypeMap`s because it is the wild west and you
lose most of the validation with the Terraform internals when using maps.

```
resource "..." "..." {
  foo = {
    bar1 = "baz"
  }
}
```

While numeric characters in attribute keys are permitted in HCL, they must be
quoted. Inadvertently, it looks like this was also being applied to the
attribute values. While a good measure, this isn't as important as we have
better measures to detect the value type and infer it appropriately.

This commit removes the additional handling and instead relies on the explicit
`.(type)` check instead which covers the key _and_ value.
@jacobbednarz
Copy link
Member Author

@jafowler do you mind eyeballing this and confirm i'm not missing anything here post the rewrite we did to tidy up the nested fields?

Copy link
Contributor

@jafowler jafowler left a comment

Choose a reason for hiding this comment

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

LGTM

@jafowler
Copy link
Contributor

@jafowler do you mind eyeballing this and confirm i'm not missing anything here post the rewrite we did to tidy up the nested fields?

LGTM. I have faith our test suit would be angry otherwise :)

@jacobbednarz jacobbednarz merged commit f191df8 into master May 14, 2024
6 checks passed
@jacobbednarz jacobbednarz deleted the handle-nested-maps-as-non-strings branch May 14, 2024 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants