From fa11fb70f628702443cd41d7600af1ca968615df Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 22 May 2018 15:13:27 -0700 Subject: [PATCH] govendor fetch github.com/hashicorp/hcl2/... This includes fixes to hcldec that should make our configschema.Block implementation behave better with Optional+Computed attributes. --- .../hashicorp/hcl2/ext/typeexpr/README.md | 4 +- .../hashicorp/hcl2/hcldec/public.go | 5 +- .../github.com/hashicorp/hcl2/hcldec/spec.go | 42 ++++++++++++++++ vendor/vendor.json | 48 +++++++++---------- 4 files changed, 72 insertions(+), 27 deletions(-) diff --git a/vendor/github.com/hashicorp/hcl2/ext/typeexpr/README.md b/vendor/github.com/hashicorp/hcl2/ext/typeexpr/README.md index 7c4d6939f0..ff2b3f2295 100644 --- a/vendor/github.com/hashicorp/hcl2/ext/typeexpr/README.md +++ b/vendor/github.com/hashicorp/hcl2/ext/typeexpr/README.md @@ -55,8 +55,8 @@ in a type expression: For example: * `list(string)` -* `object({"name":string,"age":number})` -* `map(object({"name":string,"age":number}))` +* `object({name=string,age=number})` +* `map(object({name=string,age=number}))` Note that the object constructor syntax is not fully-general for all possible object types because it requires the attribute names to be valid identifiers. diff --git a/vendor/github.com/hashicorp/hcl2/hcldec/public.go b/vendor/github.com/hashicorp/hcl2/hcldec/public.go index 5d1f10a3db..3c803632d9 100644 --- a/vendor/github.com/hashicorp/hcl2/hcldec/public.go +++ b/vendor/github.com/hashicorp/hcl2/hcldec/public.go @@ -65,7 +65,10 @@ func ChildBlockTypes(spec Spec) map[string]Spec { visit = func(s Spec) { if bs, ok := s.(blockSpec); ok { for _, blockS := range bs.blockHeaderSchemata() { - ret[blockS.Type] = bs.nestedSpec() + nested := bs.nestedSpec() + if nested != nil { // nil can be returned to dynamically opt out of this interface + ret[blockS.Type] = nested + } } } diff --git a/vendor/github.com/hashicorp/hcl2/hcldec/spec.go b/vendor/github.com/hashicorp/hcl2/hcldec/spec.go index 25cafcd97b..0d1288ce0b 100644 --- a/vendor/github.com/hashicorp/hcl2/hcldec/spec.go +++ b/vendor/github.com/hashicorp/hcl2/hcldec/spec.go @@ -848,6 +848,16 @@ func findLabelSpecs(spec Spec) []string { // // The two specifications must have the same implied result type for correct // operation. If not, the result is undefined. +// +// Any requirements imposed by the "Default" spec apply even if "Primary" does +// not return null. For example, if the "Default" spec is for a required +// attribute then that attribute is always required, regardless of the result +// of the "Primary" spec. +// +// The "Default" spec must not describe a nested block, since otherwise the +// result of ChildBlockTypes would not be decidable without evaluation. If +// the default spec _does_ describe a nested block then the result is +// undefined. type DefaultSpec struct { Primary Spec Default Spec @@ -872,6 +882,38 @@ func (s *DefaultSpec) impliedType() cty.Type { return s.Primary.impliedType() } +// attrSpec implementation +func (s *DefaultSpec) attrSchemata() []hcl.AttributeSchema { + // We must pass through the union of both of our nested specs so that + // we'll have both values available in the result. + var ret []hcl.AttributeSchema + if as, ok := s.Primary.(attrSpec); ok { + ret = append(ret, as.attrSchemata()...) + } + if as, ok := s.Default.(attrSpec); ok { + ret = append(ret, as.attrSchemata()...) + } + return ret +} + +// blockSpec implementation +func (s *DefaultSpec) blockHeaderSchemata() []hcl.BlockHeaderSchema { + // Only the primary spec may describe a block, since otherwise + // our nestedSpec method below can't know which to return. + if bs, ok := s.Primary.(blockSpec); ok { + return bs.blockHeaderSchemata() + } + return nil +} + +// blockSpec implementation +func (s *DefaultSpec) nestedSpec() Spec { + if bs, ok := s.Primary.(blockSpec); ok { + return bs.nestedSpec() + } + return nil +} + func (s *DefaultSpec) sourceRange(content *hcl.BodyContent, blockLabels []blockLabel) hcl.Range { // We can't tell from here which of the two specs will ultimately be used // in our result, so we'll just assume the first. This is usually the right diff --git a/vendor/vendor.json b/vendor/vendor.json index e5cfa3b387..b573edf267 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1891,68 +1891,68 @@ { "checksumSHA1": "dJPromzLdd492RQjE/09klKRXGs=", "path": "github.com/hashicorp/hcl2/ext/dynblock", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { - "checksumSHA1": "Tpj2tK/XrhxbIKB5xEJlfTI46M0=", + "checksumSHA1": "IAfC0Xri1iCRgbbiDBgs6ue8/Ic=", "path": "github.com/hashicorp/hcl2/ext/typeexpr", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "BRJaQcKriVKEirVC7YxBxPufQF0=", "path": "github.com/hashicorp/hcl2/gohcl", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "v1JCFNvhLqF3ErYcxkJJPboKO8c=", "path": "github.com/hashicorp/hcl2/hcl", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "ekhg+MJLLGkJQdh/tZ4A3EZwpNY=", "path": "github.com/hashicorp/hcl2/hcl/hclsyntax", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "G40fCmu1bSWXv4Hw5JXwEUTVThk=", "path": "github.com/hashicorp/hcl2/hcl/json", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { - "checksumSHA1": "672O/GQ9z+OFsG3eHLKq1yg3ZGM=", + "checksumSHA1": "c3Lb2st15sopmoLrjLQp+XyaZjE=", "path": "github.com/hashicorp/hcl2/hcldec", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "sySYF9Ew71VS/LfrG+s/0jK+1VQ=", "path": "github.com/hashicorp/hcl2/hcled", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "IzmftuG99BqNhbFGhxZaGwtiMtM=", "path": "github.com/hashicorp/hcl2/hclparse", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "v5qx2XghQ+EtvFLa4a0Efjiwt9I=", "path": "github.com/hashicorp/hcl2/hcltest", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "9UCSLRG+TEAsNKOZJUaJj/7d6r8=", "path": "github.com/hashicorp/hcl2/hclwrite", - "revision": "5f8ed954abd873b2c09616ba0aa607892bbca7e9", - "revisionTime": "2018-03-08T16:30:58Z" + "revision": "bbbd0ef30d601e5ecf89e492d0842170f144db85", + "revisionTime": "2018-05-22T22:06:42Z" }, { "checksumSHA1": "M09yxoBoCEtG7EcHR8aEWLzMMJc=",