Last active
November 9, 2022 21:36
-
-
Save ikurni/1cf84e321a5a2d3a23e52c39273315c5 to your computer and use it in GitHub Desktop.
Working with JSON Patch for Openshift OC Patch command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you @ikurni, that's help me.