Documentation ¶
Overview ¶
Package collections provides utilities for working with collections inside of plan
Index ¶
- func CompareActions(current, next action.Action) action.Action
- func LongestCommonSubsequence[V any](xs, ys []V, equals func(x, y V) bool) ([]V, error)
- func ProcessSlice[Input any](before, after []Input, process ProcessIndices, isObjType IsObjType[Input]) error
- func TransformMap[Input any](before, after map[string]Input, keys []string, process ProcessKey) (map[string]computed.Diff, action.Action, error)
- func TransformSlice[Input any](before, after []Input, process TransformIndices, isObjType IsObjType[Input]) ([]computed.Diff, action.Action, error)
- type IsObjType
- type ProcessIndices
- type ProcessKey
- type TransformIndices
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareActions ¶
CompareActions will compare current and next, and return plans.Update if they are different, and current if they are the same.
func LongestCommonSubsequence ¶
LongestCommonSubsequence finds a sequence of values that are common to both x and y, with the same relative ordering as in both collections. This result is useful as a first step towards computing a diff showing added/removed elements in a sequence.
The approached used here is a "naive" one, assuming that both xs and ys will generally be small in most reasonable Terraform configurations. For larger lists the time/space usage may be sub-optimal.
A pair of lists may have multiple longest common subsequences. In that case, the one selected by this function is undefined.
func ProcessSlice ¶
func ProcessSlice[Input any](before, after []Input, process ProcessIndices, isObjType IsObjType[Input]) error
ProcessSlice will process each element in the before and after slices
func TransformMap ¶
func TransformMap[Input any](before, after map[string]Input, keys []string, process ProcessKey) (map[string]computed.Diff, action.Action, error)
TransformMap transforms an input map into a computed.Diff and a action.Action
func TransformSlice ¶
func TransformSlice[Input any](before, after []Input, process TransformIndices, isObjType IsObjType[Input]) ([]computed.Diff, action.Action, error)
TransformSlice transforms a pair of slices into a computed.Diff and a action.Action
Types ¶
type ProcessIndices ¶
ProcessIndices is a callback function that processes a pair of indices
type ProcessKey ¶
ProcessKey is a callback function that processes a key