MCPcopy
hub / github.com/hashicorp/hcl / TraverseRel

Method TraverseRel

traversal.go:44–60  ·  traversal.go::Traversal.TraverseRel

TraverseRel applies the receiving traversal to the given value, returning the resulting value. This is supported only for relative traversals, and will panic if applied to an absolute traversal.

(val cty.Value)

Source from the content-addressed store, hash-verified

42// the resulting value. This is supported only for relative traversals,
43// and will panic if applied to an absolute traversal.
44func (t Traversal) TraverseRel(val cty.Value) (cty.Value, Diagnostics) {
45 if !t.IsRelative() {
46 panic("can't use TraverseRel on an absolute traversal")
47 }
48
49 current := val
50 var diags Diagnostics
51 for _, tr := range t {
52 var newDiags Diagnostics
53 current, newDiags = tr.TraversalStep(current)
54 diags = append(diags, newDiags...)
55 if newDiags.HasErrors() {
56 return cty.DynamicVal, diags
57 }
58 }
59 return current, diags
60}
61
62// TraverseAbs applies the receiving traversal to the given eval context,
63// returning the resulting value. This is supported only for absolute

Callers 3

TraverseAbsMethod · 0.45
TraverseRelMethod · 0.45
ValueMethod · 0.45

Calls 3

IsRelativeMethod · 0.95
HasErrorsMethod · 0.95
TraversalStepMethod · 0.65

Tested by

no test coverage detected