diff

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package diff provides the Diff class that can be used to compare CloudFormation templates

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetResourceActions added in v1.7.0

func GetResourceActions(d Diff) map[string]ActionType

Types

type ActionType added in v1.7.0

type ActionType string
const (
	Create ActionType = "Create"
	Update ActionType = "Update"
	Delete ActionType = "Delete"
	None   ActionType = "None"
)

type Diff

type Diff interface {
	// Mode represents the type of change in a Diff
	Mode() Mode

	// String returns a string representation of the Diff
	String() string

	// Format returns a pretty-printed representation of the Diff
	// The long flag determines whether to produce long or short output
	Format(bool) string

	// Value returns the value represented by the Diff
	Value() interface{}
}

Diff is the common interface for the other types in this package.

A Diff represents the difference (or lack of difference) between two values

func New

func New(a, b cft.Template) Diff

New returns a Diff that represents the difference between two templates

Example
original := map[string]interface{}{
	"foo": []interface{}{
		"bar",
		"baz",
	},
	"quux": map[string]interface{}{
		"mooz": "xyzzy",
	},
}

fmt.Println(compareValues(original, map[string]interface{}{
	"cake": "lie",
}))
Output:

(|)map[cake:(+)lie foo:(-)[bar baz] quux:(-)map[mooz:xyzzy]]

type Mode

type Mode string

Mode represents a diff mode

const (
	// Added represents a new value
	Added Mode = "+"

	// Removed represents a removed value
	Removed Mode = "-"

	// Changed represents a modified value
	Changed Mode = ">"

	// Involved represents a value that contains changes but is not wholly new itself
	Involved Mode = "|"

	// Unchanged represents a value that has not changed
	Unchanged Mode = "="
)

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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