Documentation
¶
Index ¶
- Constants
- func ConvertToJSONInterface(data *yaml.Node) *interface{}
- func ConvertToJSONobject(data *yaml.Node) map[string]interface{}
- func ConvertToYamlNode(data interface{}) *yaml.Node
- func ValidateValuesFlags(values []string) (map[string]interface{}, []string, error)
- type DeckPatch
- type DeckPatchFile
Constants ¶
const DefaultSelector = "$"
Variables ¶
This section is empty.
Functions ¶
func ConvertToJSONInterface ¶
func ConvertToJSONInterface(data *yaml.Node) *interface{}
func ConvertToJSONobject ¶
func ConvertToJSONobject(data *yaml.Node) map[string]interface{}
func ConvertToYamlNode ¶
func ConvertToYamlNode(data interface{}) *yaml.Node
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
Types ¶
type DeckPatch ¶
type DeckPatch struct { // Format string // Name of the format specified SelectorSource string // Source query for the JSONpath object Selector *yamlpath.Path // JSONpath object Values map[string]interface{} // Values to set on target objects 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) ApplyToNode ¶
ApplyToNode applies the DeckPatch on a JSONobject. The yaml.Node MUST be of type "MappingNode" (JSONobject), 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) 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.