yamlpatch

package
v1.5.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMapping

func IsMapping(i interface{}) bool

IsMapping reports whether a type is a mapping in YAML, represented as a map[interface{}]interface{}.

func IsScalar

func IsScalar(i interface{}) bool

IsScalar reports whether a type is a scalar value in YAML.

func IsSequence

func IsSequence(i interface{}) bool

IsSequence reports whether a type is a sequence in YAML, represented as an []interface{}.

func YAML

func YAML(sources [][]byte, strict bool) (*bytes.Buffer, error)

YAML deep-merges any number of YAML sources, with later sources taking priority over earlier ones.

Maps are deep-merged. For example,

{"one": 1, "two": 2} + {"one": 42, "three": 3}
== {"one": 42, "two": 2, "three": 3}

Sequences are replaced. For example,

{"foo": [1, 2, 3]} + {"foo": [4, 5, 6]}
== {"foo": [4, 5, 6]}

In non-strict mode, duplicate map keys are allowed within a single source, with later values overwriting previous ones. Attempting to merge mismatched types (e.g., merging a sequence into a map) replaces the old value with the new.

Enabling strict mode returns errors in both of the above cases.

Types

type Patcher

type Patcher struct {
	BaseFilePath  string
	PatchFilePath string
	// contains filtered or unexported fields
}

func NewPatcher

func NewPatcher(filePath string, suffix string) *Patcher

func (*Patcher) MergedPatchContent

func (p *Patcher) MergedPatchContent() ([]byte, error)

MergedPatchContent reads a YAML file and, if it exists, its patch file, then merges them and returns it serialized.

func (*Patcher) PrependedPatchContent

func (p *Patcher) PrependedPatchContent() ([]byte, error)

PrependedPatchContent collates the base .yaml file with the .yaml.patch, by putting the content of the patch BEFORE the base document. The result is a multi-document YAML in all cases, even if the base and patch files are single documents.

func (*Patcher) SetQuiet added in v1.5.0

func (p *Patcher) SetQuiet(quiet bool)

SetQuiet sets the quiet flag, which will log as DEBUG_LEVEL instead of INFO

Jump to

Keyboard shortcuts

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