json patch syntax for overlays #313
Replies: 1 comment 6 replies
-
I like the idea of using a notation that is likely familiar to the person using the tool. Why Structures? Granted that this almost always a shift in thinking. We're painfully aware of the pain that many folks go through to make that shift. However, we believe that given the time to do so, we can mitigate those pains sufficiently to make the host of benefits on the other side well worth that trade-off. I don't want to distract with elaborating the total scope of those benefits, here, but just consider what can be accomplished when the tool has information about the exact shape (and potentially meaning) of the structure. One relevant benefit to the user can be increasing their confidence while visually reasoning that the path they have described will match the documents they intend. For example, one trick is when writing an overlay, I can copy the relevant snippet from an actual document to seed my overlay and then resolve the ambiguities with annotations. Modulo the sharp edges around overlays (of which many are getting filed down, as we type), this is a great way to "get it right" out the gate. An indirect relevant benefit to the user is that there's one mechanism/symbol-system for talking about documents: YAML. There's one notation to learn (albeit, an expanding notation when doing things like patching): almost all of what you know about the notation works as you take on more capabilities. This also keeps the implementation and interface complexity of the tool itself minimized. Tools that do this tend to mature more quickly and have fewer defects: they are more reliable. ... So, if there seems to be resistance to supporting JSON Path notation, well ... it can be in part because doing so — despite the obvious value of reuse across (some) tools in the ecosystem — it would mitigate these desired qualities of the tool. Now, it's not to say that once the Carvel tools reach a certain level of maturity that they couldn't be in a place to take on convenience features like supporting JSON Path. Looking into my 🔮 , I see that once this tool starts to tackle problems that practically speaking require paths, it would be important to seriously consider this notation. All of this said to expose the structure of some thinking around the topic. Others (even from within the project) have different perspectives. And impact does not necessarily follow intention. |
Beta Was this translation helpful? Give feedback.
-
I work on some projects that use
ytt
, and some that usekustomize
.For patching array items, I do like the use of
json path
andjson patch
thatkustomize
supports.https://github.com/kubernetes-sigs/kustomize/blob/master/examples/jsonpatch.md
ytt
's matcher functions give a nice option for when you have more complex needs, but I wonder if an@overlay/match by=overlay.jsonpath(/foo/bar/2/baz)
option would be consise and readable in some cases. It seems to me thatytt
overlays require several nested layers of#@overlay/match
for arrays within arrays.Beta Was this translation helpful? Give feedback.
All reactions