X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=vendor%2Fgithub.com%2Fhashicorp%2Fhcl2%2Fhcl%2Ftraversal.go;h=d710197008c72dafb2b2b73960e247cce2528fb0;hb=107c1cdb09c575aa2f61d97f48d8587eb6bada4c;hp=24f4c91b7f478a001d1167f3fd1381853481d633;hpb=15c0b25d011f37e7c20aeca9eaf461f78285b8d9;p=github%2Ffretlink%2Fterraform-provider-statuscake.git diff --git a/vendor/github.com/hashicorp/hcl2/hcl/traversal.go b/vendor/github.com/hashicorp/hcl2/hcl/traversal.go index 24f4c91..d710197 100644 --- a/vendor/github.com/hashicorp/hcl2/hcl/traversal.go +++ b/vendor/github.com/hashicorp/hcl2/hcl/traversal.go @@ -255,66 +255,7 @@ type TraverseAttr struct { } func (tn TraverseAttr) TraversalStep(val cty.Value) (cty.Value, Diagnostics) { - if val.IsNull() { - return cty.DynamicVal, Diagnostics{ - { - Severity: DiagError, - Summary: "Attempt to get attribute from null value", - Detail: "This value is null, so it does not have any attributes.", - Subject: &tn.SrcRange, - }, - } - } - - ty := val.Type() - switch { - case ty.IsObjectType(): - if !ty.HasAttribute(tn.Name) { - return cty.DynamicVal, Diagnostics{ - { - Severity: DiagError, - Summary: "Unsupported attribute", - Detail: fmt.Sprintf("This object does not have an attribute named %q.", tn.Name), - Subject: &tn.SrcRange, - }, - } - } - - if !val.IsKnown() { - return cty.UnknownVal(ty.AttributeType(tn.Name)), nil - } - - return val.GetAttr(tn.Name), nil - case ty.IsMapType(): - if !val.IsKnown() { - return cty.UnknownVal(ty.ElementType()), nil - } - - idx := cty.StringVal(tn.Name) - if val.HasIndex(idx).False() { - return cty.DynamicVal, Diagnostics{ - { - Severity: DiagError, - Summary: "Missing map element", - Detail: fmt.Sprintf("This map does not have an element with the key %q.", tn.Name), - Subject: &tn.SrcRange, - }, - } - } - - return val.Index(idx), nil - case ty == cty.DynamicPseudoType: - return cty.DynamicVal, nil - default: - return cty.DynamicVal, Diagnostics{ - { - Severity: DiagError, - Summary: "Unsupported attribute", - Detail: "This value does not have any attributes.", - Subject: &tn.SrcRange, - }, - } - } + return GetAttr(val, tn.Name, &tn.SrcRange) } func (tn TraverseAttr) SourceRange() Range {