Help us shape the future of Go! Take the 2026 Go Developer Survey

partial

package
v1.20.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

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

View Source
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

func (r *Renderer) Render(expr hcl.Expression) (cty.Value, bool)

Render returns expr's value with every unresolved part rendered as text, or false when expr cannot be rendered.

func (*Renderer) RenderUnresolved

func (r *Renderer) RenderUnresolved(expr hclsyntax.Expression) (cty.Value, bool)

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.

func (*Renderer) Text

func (r *Renderer) Text(expr hclsyntax.Expression) (string, bool)

Text renders expr as its own "${expr}" text, from Source or else from its traversal. Rules link resources by parsing reference texts such as "${aws_s3_bucket.b.id}".

type Source

type Source func(hcl.Range) (string, bool)

Source returns the configuration text of a range, or false when it has none.

func BytesSource

func BytesSource(src []byte) Source

BytesSource reads ranges from the single file src.

func FileSources

func FileSources(files map[string][]byte) Source

FileSources reads ranges from the native syntax files in files, keyed by filename.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL