renderers

package
v0.27.1 Latest Latest
Warning

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

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

Documentation

Overview

Package renderers provides the rendering logic for computed diffs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Block

func Block(attributes map[string]computed.Diff, blocks Blocks) computed.DiffRenderer

Block is a renderer for a block diff

func List

func List(elements []computed.Diff) computed.DiffRenderer

List renders a list of computed.Diffs.

func Map

func Map(elements map[string]computed.Diff) computed.DiffRenderer

Map renders a map of computed.Diffs.

func NestedList

func NestedList(elements []computed.Diff) computed.DiffRenderer

NestedList renders a nested list of computed.Diffs

func NestedMap

func NestedMap(elements map[string]computed.Diff) computed.DiffRenderer

NestedMap renders a map of computed.Diffs

func NestedObject

func NestedObject(attributes map[string]computed.Diff) computed.DiffRenderer

NestedObject renders a nested map of computed.Diffs

func NestedSet

func NestedSet(elements []computed.Diff) computed.DiffRenderer

NestedSet renders a nested set of computed.Diffs

func Object

func Object(attributes map[string]computed.Diff) computed.DiffRenderer

Object renders a map of computed.Diffs.

func Primitive

func Primitive(before, after interface{}, ctype cty.Type) computed.DiffRenderer

Primitive is a renderer for a primitive diff

func RendererJSONOpts

func RendererJSONOpts() jsondiff.JSONOpts

RendererJSONOpts creates a jsondiff.JSONOpts object that returns the correct embedded renderers for each JSON type.

We need to define this in our renderers package in order to avoid cycles, and to help with reuse between the output processing in the differs package, and our JSON string rendering here.

func Sensitive

func Sensitive(change computed.Diff, beforeSensitive, afterSensitive bool) computed.DiffRenderer

Sensitive renders a sensitive computed.Diff.

func SensitiveBlock

func SensitiveBlock(diff computed.Diff, beforeSensitive, afterSensitive bool) computed.DiffRenderer

SensitiveBlock is a renderer for a sensitive block diff

func Set

func Set(elements []computed.Diff) computed.DiffRenderer

Set renders a set of computed.Diffs.

func TypeChange

func TypeChange(before, after computed.Diff) computed.DiffRenderer

TypeChange is a renderer for a type change diff

func Unknown

func Unknown(before computed.Diff) computed.DiffRenderer

Unknown is a renderer for an unknown diff

Types

type Blocks

type Blocks struct {
	SingleBlocks map[string]computed.Diff
	ListBlocks   map[string][]computed.Diff
	SetBlocks    map[string][]computed.Diff
	MapBlocks    map[string]map[string]computed.Diff

	ReplaceBlocks         map[string]bool
	BeforeSensitiveBlocks map[string]bool
	AfterSensitiveBlocks  map[string]bool
}

Blocks is a helper struct for collating the different kinds of blocks in a simple way for rendering.

func (*Blocks) AddAllListBlock

func (blocks *Blocks) AddAllListBlock(key string, diffs []computed.Diff, replace, beforeSensitive, afterSensitive bool)

AddAllListBlock adds a list of block diffs

func (*Blocks) AddAllMapBlocks

func (blocks *Blocks) AddAllMapBlocks(key string, diffs map[string]computed.Diff, replace, beforeSensitive, afterSensitive bool)

AddAllMapBlocks adds a map of block diffs

func (*Blocks) AddAllSetBlock

func (blocks *Blocks) AddAllSetBlock(key string, diffs []computed.Diff, replace, beforeSensitive, afterSensitive bool)

AddAllSetBlock adds a set of block diffs

func (*Blocks) AddSingleBlock

func (blocks *Blocks) AddSingleBlock(key string, diff computed.Diff, replace, beforeSensitive, afterSensitive bool)

AddSingleBlock adds a single block

func (*Blocks) GetAllKeys

func (blocks *Blocks) GetAllKeys() []string

GetAllKeys returns a list of keys for the blocks

func (*Blocks) IsListBlock

func (blocks *Blocks) IsListBlock(key string) bool

IsListBlock returns true if the key is for a list block

func (*Blocks) IsMapBlock

func (blocks *Blocks) IsMapBlock(key string) bool

IsMapBlock returns true if the key is for a map block

func (*Blocks) IsSetBlock

func (blocks *Blocks) IsSetBlock(key string) bool

IsSetBlock returns true if the key is for a set block

func (*Blocks) IsSingleBlock

func (blocks *Blocks) IsSingleBlock(key string) bool

IsSingleBlock returns true if the key is for a single block

type NoWarningsRenderer

type NoWarningsRenderer struct{}

NoWarningsRenderer defines a Warnings function that returns an empty list of warnings. This can be used by other renderers to ensure we don't see lots of repeats of this empty function.

func (NoWarningsRenderer) Warnings

func (render NoWarningsRenderer) Warnings(_ computed.Diff) []string

Warnings returns an empty slice, as the name NoWarningsRenderer suggests.

type ValidateDiffFunction

type ValidateDiffFunction func(t *testing.T, diff computed.Diff)

ValidateDiffFunction is a function that validates a computed.Diff

func ValidateBlock

func ValidateBlock(
	attributes map[string]ValidateDiffFunction,
	singleBlocks map[string]ValidateDiffFunction,
	listBlocks map[string][]ValidateDiffFunction,
	mapBlocks map[string]map[string]ValidateDiffFunction,
	setBlocks map[string][]ValidateDiffFunction,
	action action.Action,
	replace bool) ValidateDiffFunction

ValidateBlock validates a block diff

func ValidateList

func ValidateList(elements []ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateList validates a list diff

func ValidateMap

func ValidateMap(elements map[string]ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateMap validates a map diff

func ValidateNestedList

func ValidateNestedList(elements []ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateNestedList validates a nested list diff

func ValidateNestedObject

func ValidateNestedObject(attributes map[string]ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateNestedObject validates a nested object diff

func ValidateObject

func ValidateObject(attributes map[string]ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateObject validates an object diff

func ValidatePrimitive

func ValidatePrimitive(before, after interface{}, action action.Action, replace bool) ValidateDiffFunction

ValidatePrimitive validates a primitive diff

func ValidateSensitive

func ValidateSensitive(inner ValidateDiffFunction, beforeSensitive, afterSensitive bool, action action.Action, replace bool) ValidateDiffFunction

ValidateSensitive validates a sensitive diff

func ValidateSet

func ValidateSet(elements []ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateSet validates a set diff

func ValidateTypeChange

func ValidateTypeChange(before, after ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateTypeChange validates a type change diff

func ValidateUnknown

func ValidateUnknown(before ValidateDiffFunction, action action.Action, replace bool) ValidateDiffFunction

ValidateUnknown validates an unknown diff

Jump to

Keyboard shortcuts

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