terraform/configs/configschema
Kristin Laemmert b9138f4465
terraform: validate providers' schemas during NewContext (#28124)
* checkpoint save: update InternalValidate tests to compare exact error

* configschema: extract and extend attribute validation

This commit adds an attribute-specific InternalValidate which was extracted directly from the block.InternalValidate logic and extended to verify any NestedTypes inside an Attribute. Only one error message changed, since it is now valid to have a cty.NilType for Attribute.Type as long as NestedType is set.

* terraform: validate provider schema's during NewContext

We haven't been able to guarantee that providers are validating their own schemas using (some version of) InternalValidate since providers were split out of the main codebase. This PR adds a call to InternalValidate when provider schemas are initially loaded by NewContext, which required a few other changes:

InternalValidate's handling of errors vs multierrors was a little weird - before this PR, it was occasionally returning a non-nil error which only stated "0 errors occurred" - so I addressed that in InternalValidate. I then tested this with a configuration that was using all of our most popular providers, and found that at least on provider had some invalid attribute names, so I commented that particular validation out. Adding that in would be a breaking change which we would have to coordinate with enablement and providers and (especially in this case) make sure it's well communicated to external provider developers.

I ran a few very unscientific tests comparing the timing with and without this validation, and it appeared to only cause a sub-second increase.

* refactor validate error message to closer match the sdk's message

* better error message

* tweak error message: move the instruction to run init to the end of the message, after the specific error.
2021-03-22 13:17:50 -04:00
..
coerce_value.go do not validate Min/Max Items in CoerceValue 2019-08-20 10:13:15 -04:00
coerce_value_test.go do not validate Min/Max Items in CoerceValue 2019-08-20 10:13:15 -04:00
decoder_spec.go terraform: validate providers' schemas during NewContext (#28124) 2021-03-22 13:17:50 -04:00
decoder_spec_test.go configschema: fix various issues with NestedTypes 2021-02-12 13:34:25 -05:00
doc.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
empty_value.go configschema: fix various issues with NestedTypes 2021-02-12 13:34:25 -05:00
empty_value_test.go configschema: fix various issues with NestedTypes 2021-02-12 13:34:25 -05:00
implied_type.go Mildwonkey/nested type format (#27793) 2021-02-18 08:48:52 -05:00
implied_type_test.go Mildwonkey/nested type format (#27793) 2021-02-18 08:48:52 -05:00
internal_validate.go terraform: validate providers' schemas during NewContext (#28124) 2021-03-22 13:17:50 -04:00
internal_validate_test.go terraform: validate providers' schemas during NewContext (#28124) 2021-03-22 13:17:50 -04:00
nestingmode_string.go configs/configschema: Introduce the NestingGroup mode for blocks 2019-04-10 14:53:52 -07:00
none_required.go move "configschema" from "config" to "configs" 2018-10-16 18:50:29 -07:00
path.go Block.AttribuuteByPath 2021-01-12 16:31:18 -05:00
path_test.go Block.AttribuuteByPath 2021-01-12 16:31:18 -05:00
schema.go configs/configschema: add new NestedType to attribute 2021-02-05 13:34:55 -05:00
validate_traversal.go didyoumean: move from "helper" to "internal" 2020-10-02 13:35:07 -07:00
validate_traversal_test.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00