differ

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {

	// BeforeExplicit matches AfterExplicit except references the Before value.
	BeforeExplicit bool

	// AfterExplicit refers to whether the After value is explicit or
	// implicit. It is explicit if it has been specified by the user, and
	// implicit if it has been set as a consequence of other changes.
	//
	// For example, explicitly setting a value to null in a list should result
	// in After being null and AfterExplicit being true. In comparison,
	// removing an element from a list should also result in After being null
	// and AfterExplicit being false. Without the explicit information our
	// functions would not be able to tell the difference between these two
	// cases.
	AfterExplicit bool

	// Before contains the value before the proposed change.
	//
	// The type of the value should be informed by the schema and cast
	// appropriately when needed.
	Before interface{}

	// After contains the value after the proposed change.
	//
	// The type of the value should be informed by the schema and cast
	// appropriately when needed.
	After interface{}

	// Unknown describes whether the After value is known or unknown at the time
	// of the plan. In practice, this means the after value should be rendered
	// simply as `(known after apply)`.
	//
	// The concrete value could be a boolean describing whether the entirety of
	// the After value is unknown, or it could be a list or a map depending on
	// the schema describing whether specific elements or attributes within the
	// value are unknown.
	Unknown interface{}

	// BeforeSensitive matches Unknown, but references whether the Before value
	// is sensitive.
	BeforeSensitive interface{}

	// AfterSensitive matches Unknown, but references whether the After value is
	// sensitive.
	AfterSensitive interface{}

	// ReplacePaths contains a set of paths that point to attributes/elements
	// that are causing the overall resource to be replaced rather than simply
	// updated.
	ReplacePaths attribute_path.Matcher

	// RelevantAttributes contains a set of paths that point attributes/elements
	// that we should display. Any element/attribute not matched by this Matcher
	// should be skipped.
	RelevantAttributes attribute_path.Matcher
}

Change contains the unmarshalled generic interface{} types that are output by the JSON functions in the various json packages (such as jsonplan and jsonprovider).

A Change can be converted into a computed.Diff, ready for rendering, with the ComputeDiffForAttribute, ComputeDiffForOutput, and ComputeDiffForBlock functions.

The Before and After fields are actually go-cty values, but we cannot convert them directly because of the Terraform Cloud redacted endpoint. The redacted endpoint turns sensitive values into strings regardless of their types. Because of this, we cannot just do a direct conversion using the ctyjson package. We would have to iterate through the schema first, find the sensitive values and their mapped types, update the types inside the schema to strings, and then go back and do the overall conversion. This isn't including any of the more complicated parts around what happens if something was sensitive before and isn't sensitive after or vice versa. This would mean the type would need to change between the before and after value. It is in fact just easier to iterate through the values as generic JSON interfaces.

func FromJsonChange

func FromJsonChange(change jsonplan.Change, relevantAttributes attribute_path.Matcher) Change

FromJsonChange unmarshals the raw []byte values in the jsonplan.Change structs into generic interface{} types that can be reasoned about.

func FromJsonOutput

func FromJsonOutput(output jsonstate.Output) Change

FromJsonOutput unmarshals the raw values in the jsonstate.Output structs into generic interface{} types that can be reasoned about.

func FromJsonResource

func FromJsonResource(resource jsonstate.Resource) Change

FromJsonResource unmarshals the raw values in the jsonstate.Resource structs into generic interface{} types that can be reasoned about.

func FromJsonViewsOutput

func FromJsonViewsOutput(output viewsjson.Output) Change

FromJsonViewsOutput unmarshals the raw values in the viewsjson.Output structs into generic interface{} types that can be reasoned about.

func (Change) AsNoOp

func (change Change) AsNoOp() Change

AsNoOp returns the current change as if it is a NoOp operation.

Basically it replaces all the after values with the before values.

func (Change) ComputeDiffForAttribute

func (change Change) ComputeDiffForAttribute(attribute *jsonprovider.Attribute) computed.Diff

func (Change) ComputeDiffForBlock

func (change Change) ComputeDiffForBlock(block *jsonprovider.Block) computed.Diff

func (Change) ComputeDiffForOutput

func (change Change) ComputeDiffForOutput() computed.Diff

func (Change) ComputeDiffForType

func (change Change) ComputeDiffForType(ctype cty.Type) computed.Diff

type ChangeMap

type ChangeMap struct {
	// Before contains the value before the proposed change.
	Before map[string]interface{}

	// After contains the value after the proposed change.
	After map[string]interface{}

	// Unknown contains the unknown status of any elements/attributes of this
	// map/object.
	Unknown map[string]interface{}

	// BeforeSensitive contains the before sensitive status of any
	// elements/attributes of this map/object.
	BeforeSensitive map[string]interface{}

	// AfterSensitive contains the after sensitive status of any
	// elements/attributes of this map/object.
	AfterSensitive map[string]interface{}

	// ReplacePaths matches the same attributes in Change exactly.
	ReplacePaths attribute_path.Matcher

	// RelevantAttributes matches the same attributes in Change exactly.
	RelevantAttributes attribute_path.Matcher
}

ChangeMap is a Change that represents a Map or an Object type, and has converted the relevant interfaces into maps for easier access.

type ChangeSlice

type ChangeSlice struct {
	// Before contains the value before the proposed change.
	Before []interface{}

	// After contains the value after the proposed change.
	After []interface{}

	// Unknown contains the unknown status of any elements of this list/set.
	Unknown []interface{}

	// BeforeSensitive contains the before sensitive status of any elements of
	//this list/set.
	BeforeSensitive []interface{}

	// AfterSensitive contains the after sensitive status of any elements of
	//this list/set.
	AfterSensitive []interface{}

	// ReplacePaths matches the same attributes in Change exactly.
	ReplacePaths attribute_path.Matcher

	// RelevantAttributes matches the same attributes in Change exactly.
	RelevantAttributes attribute_path.Matcher
}

ChangeSlice is a Change that represents a Tuple, Set, or List type, and has converted the relevant interfaces into slices for easier access.

type CreateSensitiveRenderer

type CreateSensitiveRenderer func(computed.Diff, bool, bool) computed.DiffRenderer

type NestingMode

type NestingMode string

NestingMode is a wrapper around a string type to describe the various different kinds of nesting modes that can be applied to nested blocks and objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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