Name: yaml-patch
Owner: Pivotal Cloud Foundry
Description: null
Created: 2017-11-08 19:39:52.0
Updated: 2018-05-14 07:32:28.0
Pushed: 2017-11-15 19:13:28.0
Homepage: null
Size: 49
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
yaml-patch
is a version of Evan Phoenix's
json-patch, which is an implementation
of JavaScript Object Notation (JSON) Patch,
but for YAML.
go get github.com/krishicks/yaml-patch
If you want to use the CLI:
go get github.com/krishicks/yaml-patch/cmd/yaml-patch
Given the following RFC6902-ish YAML document, ops
:
: add
th: /baz/waldo
lue: fred
And the following YAML that is to be modified, src
:
bar
ux: grault
Decode the ops file into a patch:
h, err := yamlpatch.DecodePatch(ops)
andle err
Then apply that patch to the document:
err := patch.Apply(src)
andle err
o something with dst
:= []byte(`---
bar
ux: grault
:= []byte(`---
: add
th: /baz/waldo
lue: fred
h, err := yamlpatch.DecodePatch(ops)
rr != nil {
g.Fatalf("decoding patch failed: %s", err)
err := patch.Apply(doc)
rr != nil {
g.Fatalf("applying patch failed: %s", err)
Println(string(bs))
ux: grault
ldo: fred
bar