govendor fetch github.com/hashicorp/hcl2/...

This includes fixes to hcldec that should make our configschema.Block
implementation behave better with Optional+Computed attributes.
This commit is contained in:
Martin Atkins 2018-05-22 15:13:27 -07:00
parent 8c1f0842b0
commit fa11fb70f6
4 changed files with 72 additions and 27 deletions

View File

@ -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.

View File

@ -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
}
}
}

View File

@ -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

48
vendor/vendor.json vendored
View File

@ -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=",