Skip to content

Instantly share code, notes, and snippets.

@ikurni
Last active November 9, 2022 21:36
Show Gist options
  • Save ikurni/1cf84e321a5a2d3a23e52c39273315c5 to your computer and use it in GitHub Desktop.
Save ikurni/1cf84e321a5a2d3a23e52c39273315c5 to your computer and use it in GitHub Desktop.
Working with JSON Patch for Openshift OC Patch command
##Openshift OC Command using json type :
oc patch <object> <object> --type=json -p (sample)
##The original document :
{
"baz": "qux",
"foo": "bar"
}
The patch :
[
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add", "path": "/hello", "value": ["world"] },
{ "op": "remove", "path": "/foo" }
]
##The result :
{
"baz": "boo",
"hello": ["world"]
}
----------------------------------------------------------------------
##Openshift OC Command using merge type :
oc patch <object> <object> --type=merge -p (sample)
##First command :
{
"a": "b",
"c": {
"d": "e",
"f": "g"
}
}
##Second command :
{
"a":"x",
"c": {
"f": null
}
}
##which will change the value of "a" to "x" and will delete the "f" key, while "d" value still exist
@mrcomoraes
Copy link

Thank you @ikurni, that's help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment