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

schema: Enable map value validation #12638

Merged
merged 1 commit into from
Mar 13, 2017
Merged

schema: Enable map value validation #12638

merged 1 commit into from
Mar 13, 2017

Conversation

radeksimko
Copy link
Member

I noticed we expect the Elem for maps to be ValueType directly per #10203 which probably makes sense for primitive types, because wrapping the type in Schema{} doesn't provide much benefits as most schema attributes don't make any sense in this context, e.g. Optional/Required/Computed - you cannot have value computed or not present as you'd have to know the key which means the whole pair has to be defined beforehand anyway and HCL has AFAIK no notion of a map with optional/no value.

That said we do have some Type: TypeMap, Elem: &Schema{Type: ValueType} in the codebase, specifically:

  • data source aws_kms_secret: context
  • data source consul_agent_self: advertise_addrs
  • data source consul_catalog_nodes: tagged_addresses
  • data source consul_catalog_service: tagged_addresses
  • data source consul_catalog_services: services
  • data source external: query
  • data source external: result
  • resource aws_ssm_document: permissions
  • resource chef_environment: cookbook_constraints
  • resource circonus_check: check_by_collector
  • resource consul_key_prefix: subkeys
  • resource datadog_monitor: thresholds
  • resource ns1_user: notify
  • resource test_resource: map_that_look_like_set

So all of these are well handled in this new validation, but we don't actually cast to right type at this point, so even if the type is right (passed validation), you'll get string values there anyway.

I'm happy to send a separate PR to tighten the internal validation too and modify the schema of the mentioned data sources and resources ^, but it will be obviously BC for any external/pluggable providers, so I'd like to hear some thoughts or at least 👍 / 👎 on this idea.

Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

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

yes, I like the added validation here. I think we can wait on the BC issues for when we decide how to properly handle nested data structures in general.

@ghost
Copy link

ghost commented Apr 15, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants