computed

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package computed contains types that represent the computed diffs for Terraform blocks, attributes, and outputs.

Each Diff struct is made up of a renderer, an action, and a boolean describing the diff. The renderer internally holds child diffs or concrete values that allow it to know how to render the diff appropriately.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	// Renderer captures the uncommon functionality across the different kinds
	// of changes. Each type of change (lists, blocks, sets, etc.) will have a
	// unique renderer.
	Renderer DiffRenderer

	// Action is the action described by this change (such as create, delete,
	// update, etc.).
	Action action.Action

	// Replace tells the Change that it should add the `# forces replacement`
	// suffix.
	//
	// Every single change could potentially add this suffix, so we embed it in
	// the change as common functionality instead of in the specific renderers.
	Replace bool
}

Diff captures the computed diff for a single block, element or attribute.

It essentially merges common functionality across all types of changes, namely the replace logic and the action / change type. Any remaining behaviour can be offloaded to the renderer which will be unique for the various change types (eg. maps, objects, lists, blocks, primitives, etc.).

func NewDiff

func NewDiff(renderer DiffRenderer, action action.Action, replace bool) Diff

NewDiff creates a new Diff object with the provided renderer, action and replace context.

func (Diff) Render

func (diff Diff) Render() (node.Diff, error)

Render returns the rendered diff for the given change.

func (Diff) Warnings

func (diff Diff) Warnings() []string

Warnings returns a list of strings that should be rendered as warnings before a given change is node.

type DiffRenderer

type DiffRenderer interface {
	Render(diff Diff) (node.Diff, error)
	Warnings(diff Diff) []string
}

DiffRenderer is an interface that must be implemented by all diff renderers.

Directories

Path Synopsis
Package node provides the rendered node types
Package node provides the rendered node types
Package renderers provides the rendering logic for computed diffs
Package renderers provides the rendering logic for computed diffs

Jump to

Keyboard shortcuts

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