differ

package
v0.0.0-...-d4e16af Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeYamlObject

func DecodeYamlObject(reader io.Reader, obj *YamlObject) error

func EncodeYamlObject

func EncodeYamlObject(writer io.Writer, obj *YamlObject) error

func EncodeYamlObjectAsJson

func EncodeYamlObjectAsJson(writer io.Writer, obj *YamlObject) error

func WriteStateToDirectory

func WriteStateToDirectory(objects []*YamlObject, path, outputTemplate string) error

Types

type DebugInfo

type DebugInfo struct {
	RuleDebugInfos []*RuleDebugInfo
	InitialObjects []*YamlObject
}

func NewDebugInfo

func NewDebugInfo(ruleSet RuleSet) *DebugInfo

func (*DebugInfo) AddInitialObjects

func (d *DebugInfo) AddInitialObjects(objects []*YamlObject)

func (*DebugInfo) NewRuleDebugInfo

func (d *DebugInfo) NewRuleDebugInfo(i int, rule ObjectRule) *RuleDebugInfo

func (*DebugInfo) Print

func (d *DebugInfo) Print()

func (*DebugInfo) ValidateAllRulesWereEffective

func (d *DebugInfo) ValidateAllRulesWereEffective() error

type IgnoreRule

type IgnoreRule struct {
	Match Json6902Patch `yaml:"match"`
	Name  string        `yaml:"name"`

	Todo bool `yaml:"todo"`
}

func (IgnoreRule) Describe

func (e IgnoreRule) Describe() ObjectRuleDescription

func (IgnoreRule) MapObject

func (e IgnoreRule) MapObject(obj *YamlObject, debug *RuleDebugInfo) (*YamlObject, error)

type IncrementalMatchDebugInfo

type IncrementalMatchDebugInfo struct {
	// contains filtered or unexported fields
}

type IncrementalPatchDebugInfo

type IncrementalPatchDebugInfo struct {
	// contains filtered or unexported fields
}

type IneffectiveMatchError

type IneffectiveMatchError struct {
	RuleName  string
	Step      int
	Matched   []*YamlObject
	MatchRule Json6902Operation
}

func (IneffectiveMatchError) Error

func (e IneffectiveMatchError) Error() string

type IneffectivePatchError

type IneffectivePatchError struct {
	RuleName  string
	Step      int
	Matched   []*YamlObject
	PatchRule Json6902Operation
}

func (IneffectivePatchError) Error

func (e IneffectivePatchError) Error() string

type Json6902Operation

type Json6902Operation struct {
	Op    string      `yaml:"op" json:"op"`                 // Required for all
	Path  string      `yaml:"path" json:"path"`             // Required for all
	From  string      `yaml:"from" json:"from,omitempty"`   // Required for copy / move
	Value interface{} `yaml:"value" json:"value,omitempty"` // Required for add / replace / test
}

func (Json6902Operation) Apply

func (j Json6902Operation) Apply(buf []byte) ([]byte, error)

func (Json6902Operation) ApplyToObject

func (j Json6902Operation) ApplyToObject(obj *YamlObject) error

func (Json6902Operation) Matches

func (j Json6902Operation) Matches(obj *YamlObject) (bool, error)

func (Json6902Operation) String

func (j Json6902Operation) String() string

type Json6902Patch

type Json6902Patch []Json6902Operation

func (Json6902Patch) ApplyToObject

func (j Json6902Patch) ApplyToObject(obj *YamlObject, debug *RuleDebugInfo) error

func (Json6902Patch) Matches

func (j Json6902Patch) Matches(obj *YamlObject, debug *RuleDebugInfo) (bool, error)

type Json6902PatchRule

type Json6902PatchRule struct {
	Name  string        `yaml:"name,omitempty"`
	Match Json6902Patch `yaml:"match,omitempty"`
	Steps Json6902Patch `yaml:"steps,omitempty"`

	Todo bool `yaml:"todo,omitempty"`

	// These fields exist to support syntax sugar.
	// They are converted to the above fields when the rule is created.
	RemoveField  string                   `yaml:"remove_field,omitempty"`
	RenameField  *RenameRule              `yaml:"rename_field,omitempty"`
	RenameObject *RenameRule              `yaml:"rename_object,omitempty"`
	Matchers     map[string][]interface{} `yaml:",inline"`
}

func Desugar

func Desugar(rule Json6902PatchRule) []Json6902PatchRule

func (Json6902PatchRule) Describe

func (Json6902PatchRule) MapObject

func (j Json6902PatchRule) MapObject(obj *YamlObject, debug *RuleDebugInfo) (*YamlObject, error)

type MultiError

type MultiError struct {
	Errors []error
}

func (*MultiError) Error

func (e *MultiError) Error() string

type ObjectRule

type ObjectRule interface {
	Describe() ObjectRuleDescription
	MapObject(obj *YamlObject, debug *RuleDebugInfo) (*YamlObject, error)
}

type ObjectRuleDescription

type ObjectRuleDescription struct {
	Name       string
	Todo       bool
	MatchRules Json6902Patch
	PatchRules Json6902Patch
}

type RenameRule

type RenameRule struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
}

type ResourceKey

type ResourceKey struct {
	Source string
}

ResourceKey represents a unique identifier for any object

func ResourceKeyForObject

func ResourceKeyForObject(obj *YamlObject) ResourceKey

func (ResourceKey) String

func (r ResourceKey) String() string

type RuleDebugInfo

type RuleDebugInfo struct {
	Parent  *DebugInfo
	Rule    ObjectRule
	Matches []IncrementalMatchDebugInfo
	Patches []IncrementalPatchDebugInfo
	Ignored []*YamlObject
}

RuleDebugInfo is created during the rule application process and can be used to understand the state of the system after each rule application or to debug the rule application process.

func (*RuleDebugInfo) Print

func (d *RuleDebugInfo) Print()

func (*RuleDebugInfo) RecordIgnore

func (d *RuleDebugInfo) RecordIgnore(obj *YamlObject)

func (*RuleDebugInfo) RecordIncrementalMatch

func (d *RuleDebugInfo) RecordIncrementalMatch(step int, obj *YamlObject)

func (*RuleDebugInfo) RecordIncrementalPatch

func (d *RuleDebugInfo) RecordIncrementalPatch(step int, oldObj, newObj *YamlObject)

func (*RuleDebugInfo) ValidateAllStepsWereEffective

func (d *RuleDebugInfo) ValidateAllStepsWereEffective() error

type RuleSet

type RuleSet struct {
	IgnoreRules []IgnoreRule        `yaml:"ignore_rules"`
	PatchRules  []Json6902PatchRule `yaml:"patch_rules"`
}

func (*RuleSet) Desugar

func (r *RuleSet) Desugar()

func (*RuleSet) Merge

func (r *RuleSet) Merge(other *RuleSet)

type YamlObject

type YamlObject struct {
	Object      map[string]interface{}
	ResourceKey ResourceKey
}

func ApplyRuleSet

func ApplyRuleSet(objects []*YamlObject, ruleSet RuleSet, debugInfo *DebugInfo) ([]*YamlObject, error)

func MapObjects

func MapObjects(state []*YamlObject, mapper ObjectRule, ruleDebugInfo *RuleDebugInfo) ([]*YamlObject, error)

func NewYamlObject

func NewYamlObject(source string) *YamlObject

func ReadStateFromDirectory

func ReadStateFromDirectory(path string) ([]*YamlObject, error)

func (*YamlObject) DeepCopy

func (obj *YamlObject) DeepCopy() *YamlObject

func (*YamlObject) Get

func (obj *YamlObject) Get(path string) (value interface{}, error error)

func (*YamlObject) RemoveNulls

func (y *YamlObject) RemoveNulls()

RemoveNulls removes all null values from the object. This is useful because the default removal process leaves null values for fields that are not set.

func (*YamlObject) Set

func (obj *YamlObject) Set(path string, value interface{}) (error error)

Jump to

Keyboard shortcuts

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