Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultSelector = []string{"$"}
Functions ¶
func ValidateValuesFlags ¶
ValidateValuesFlags parses the CLI '--values' keys formatted 'key:json-string', into a map. The map will hold the parsed JSON value by the key. The second return value is an array of field names that is supposed to be deleted form the target. Returns an error is value is not a valid JSON string. Important: strings must be quoted;
'--value foo:bar' is invalid '--value foo:"bar"' results in string "bar" '--value foo:true' results in boolean true '--value foo:' results in deleting key 'foo' if it exists '--value ["foo"]' results in appending string "foo" to arrays
Types ¶
type DeckPatch ¶
type DeckPatch struct { // Format string // Name of the format specified SelectorSources []string // Source query for the JSONpath object Selectors []*jsonpath.JSONPath // JSONpath object ObjValues map[string]interface{} // Values to set on target objects ArrValues []interface{} // Values to set on target arrays Remove []string // List of keys to remove from the target object }
DeckPatch models a single DeckPatch that can be applied on a deckfile.
func (*DeckPatch) ApplyToArrayNode ¶ added in v0.1.19
ApplyToArrayNode applies the DeckPatch on a JSONarray. The yaml.Node MUST be of type "SequenceNode" (JSONarray), otherwise it panics.
func (*DeckPatch) ApplyToNodes ¶
ApplyToNodes queries the yamlData using the selector, and applies the patch on every Object returned. Any non-objects returned by the selector will be ignored. If Selector wasn't set yet, will try and create it from the SelectorSource.
func (*DeckPatch) ApplyToObjectNode ¶ added in v0.1.19
ApplyToObjectNode applies the DeckPatch on a JSONobject. The yaml.Node MUST be of type "MappingNode" (JSONobject), otherwise it panics.
func (*DeckPatch) Parse ¶
Parse will parse JSONobject into a DeckPatch. selector is optional, default to "$". If given MUST be a string, and a valid JSONpath. values is optional, defaults to empty map. If given, MUST be an object. remove is optional, defaults to empty array. If given MUST be an array. Non-string entries will be ignored.
type DeckPatchFile ¶
type DeckPatchFile struct { VersionMajor int // 0 if not present VersionMinor int // 0 if not present Patches []DeckPatch }
DeckPatchFile represents a list of patches.
func (*DeckPatchFile) Apply ¶
func (patchFile *DeckPatchFile) Apply(yamlData *yaml.Node) error
Apply applies the set of patches on the yaml.Node given.
func (*DeckPatchFile) MustApply ¶
func (patchFile *DeckPatchFile) MustApply(yamlData *yaml.Node, source string)
MustApply applies the set of patches on the yaml.Node given. Same as Apply, but in case of an error it will panic. 'source' will be used to format the error in case of a panic.
func (*DeckPatchFile) ParseFile ¶
func (patchFile *DeckPatchFile) ParseFile(filename string) error
ParseFile parses a patchfile. Any non-object in the 'patches' array will be ignored. If the array doesn't exist, it returns an empty array.