Documentation
¶
Overview ¶
Package partial renders Terraform expressions evaluation cannot fully resolve into values rules can read. The parts that resolve keep their value and every part that does not becomes its own "${expr}" text, so a policy interpolating a computed ARN stays a parseable document instead of collapsing to unknown as a whole. Both the plain Terraform parser and module evaluation render through it, so an unresolved value reads the same either way.
Index ¶
- Constants
- func Bind(expr hcl.Expression, vars map[string]cty.Value) hcl.Expression
- func Scope(ctx *hcl.EvalContext, vars map[string]cty.Value) *hcl.EvalContext
- func Unbind(expr hcl.Expression) (inner hcl.Expression, vars map[string]cty.Value, ok bool)
- func WithUnknownRefs(expr hcl.Expression, ctx *hcl.EvalContext) cty.Value
- type Renderer
- type Source
Constants ¶
const UnknownPlaceholder = "${__dd_unknown__}"
UnknownPlaceholder stands for an unresolved value that has no source text to render. It has the "${...}" shape rules recognize as an unresolved reference.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
func Bind(expr hcl.Expression, vars map[string]cty.Value) hcl.Expression
Bind returns expr evaluating with vars added to the context it is given. A Renderer renders it against that scope, so its unresolved parts stay separate from the parts vars resolve.
func Scope ¶
func Scope(ctx *hcl.EvalContext, vars map[string]cty.Value) *hcl.EvalContext
Scope returns a child of ctx in which vars are defined.
func Unbind ¶
func Unbind(expr hcl.Expression) (inner hcl.Expression, vars map[string]cty.Value, ok bool)
Unbind returns the expression and variables Bind was given, for evaluators that read expressions themselves rather than through a Renderer.
func WithUnknownRefs ¶
func WithUnknownRefs(expr hcl.Expression, ctx *hcl.EvalContext) cty.Value
WithUnknownRefs evaluates expr with every reference that fails to resolve standing as unknown, as Terraform has an attribute only known after apply. A reference to a computed attribute thus leaves the rest of the value known rather than turning it unknown as a whole.
Types ¶
type Renderer ¶
type Renderer struct {
Ctx *hcl.EvalContext
Source Source
}
Renderer renders expressions against Ctx, taking the text of unresolved parts from Source. Without Source, references still render from their traversal; without Ctx, only what needs no context resolves.
func (*Renderer) Render ¶
Render returns expr's value with every unresolved part rendered as text, or false when expr cannot be rendered.
func (*Renderer) RenderUnresolved ¶
RenderUnresolved is Render for an expr already known not to resolve.
func (*Renderer) StringPart ¶
func (r *Renderer) StringPart(part hclsyntax.Expression) string
StringPart is the text a template part contributes: its value when it renders to a string, its own interpolation otherwise.
type Source ¶
Source returns the configuration text of a range, or false when it has none.
func BytesSource ¶
BytesSource reads ranges from the single file src.
func FileSources ¶
FileSources reads ranges from the native syntax files in files, keyed by filename.