diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/hcl2/hcl/traversal.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/hcl2/hcl/traversal.go')
-rw-r--r-- | vendor/github.com/hashicorp/hcl2/hcl/traversal.go | 61 |
1 files changed, 1 insertions, 60 deletions
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 { | |||
255 | } | 255 | } |
256 | 256 | ||
257 | func (tn TraverseAttr) TraversalStep(val cty.Value) (cty.Value, Diagnostics) { | 257 | func (tn TraverseAttr) TraversalStep(val cty.Value) (cty.Value, Diagnostics) { |
258 | if val.IsNull() { | 258 | return GetAttr(val, tn.Name, &tn.SrcRange) |
259 | return cty.DynamicVal, Diagnostics{ | ||
260 | { | ||
261 | Severity: DiagError, | ||
262 | Summary: "Attempt to get attribute from null value", | ||
263 | Detail: "This value is null, so it does not have any attributes.", | ||
264 | Subject: &tn.SrcRange, | ||
265 | }, | ||
266 | } | ||
267 | } | ||
268 | |||
269 | ty := val.Type() | ||
270 | switch { | ||
271 | case ty.IsObjectType(): | ||
272 | if !ty.HasAttribute(tn.Name) { | ||
273 | return cty.DynamicVal, Diagnostics{ | ||
274 | { | ||
275 | Severity: DiagError, | ||
276 | Summary: "Unsupported attribute", | ||
277 | Detail: fmt.Sprintf("This object does not have an attribute named %q.", tn.Name), | ||
278 | Subject: &tn.SrcRange, | ||
279 | }, | ||
280 | } | ||
281 | } | ||
282 | |||
283 | if !val.IsKnown() { | ||
284 | return cty.UnknownVal(ty.AttributeType(tn.Name)), nil | ||
285 | } | ||
286 | |||
287 | return val.GetAttr(tn.Name), nil | ||
288 | case ty.IsMapType(): | ||
289 | if !val.IsKnown() { | ||
290 | return cty.UnknownVal(ty.ElementType()), nil | ||
291 | } | ||
292 | |||
293 | idx := cty.StringVal(tn.Name) | ||
294 | if val.HasIndex(idx).False() { | ||
295 | return cty.DynamicVal, Diagnostics{ | ||
296 | { | ||
297 | Severity: DiagError, | ||
298 | Summary: "Missing map element", | ||
299 | Detail: fmt.Sprintf("This map does not have an element with the key %q.", tn.Name), | ||
300 | Subject: &tn.SrcRange, | ||
301 | }, | ||
302 | } | ||
303 | } | ||
304 | |||
305 | return val.Index(idx), nil | ||
306 | case ty == cty.DynamicPseudoType: | ||
307 | return cty.DynamicVal, nil | ||
308 | default: | ||
309 | return cty.DynamicVal, Diagnostics{ | ||
310 | { | ||
311 | Severity: DiagError, | ||
312 | Summary: "Unsupported attribute", | ||
313 | Detail: "This value does not have any attributes.", | ||
314 | Subject: &tn.SrcRange, | ||
315 | }, | ||
316 | } | ||
317 | } | ||
318 | } | 259 | } |
319 | 260 | ||
320 | func (tn TraverseAttr) SourceRange() Range { | 261 | func (tn TraverseAttr) SourceRange() Range { |