-
Notifications
You must be signed in to change notification settings - Fork 62
kubecfg's recursive jsonnet walk should be exposed to jsonnet somehow #242
Comments
what about a "deep map" function that can do things such "add a label to all things" but preserving the original structure? |
Oh interesting. Yes, that would work too, and be more useful. There's a big gotcha here with jsonnet (and kube.libsonnet in particular) - passing an object through a jsonnet function evaluates all the Both flatten and deepMap are quite easy to implement in jsonnet fwiw. |
what do you mean?
-->
|
There is indeed a problem with |
A more practical example of what I'm talking about. Given:
and see how you can apply an override deeply in the structure while preserving super/self:
would return:
While, using
->
A more detailed example in https://gist.github.com/mkmik/aa7f495541e4c883ad2426615d6e3525 |
I'm glad to know the late-bound-self semantics do indeed survive in more situations than I thought :) (I've been caught out by this in the past, and I can't recall exactly when - it was long before I think a structure-preserving |
it seems that the recursive jsonnet walk fits as a kubecfg primitive (so we know it uses the very same logic used by kubecfg internally). On the same note, perhaps the predicate that tells whether a given object is a k8s resource (and of which kind) could be exposed as a kubecfg function (I assume it's used by the aforementioned walk logic). What about, |
I don't care particularly. If we add it to ... 🤔 I think I would like to stick to "obviously correct" function signatures for kubecfg.libsonnet for now - and I think that means (in some pseudo type syntax): (Happy to bikeshed the specific names)
In particular, Note the above Thoughts? |
Several times I have wanted to convert kubecfg's "hierarchical" k8s resources into a simple flattened list, for use elsewhere in jsonnet (eg: to do an "add a label to all things" post-processing step).
This should be something that is easier to do than writing out a recursive jsonnet function from scratch every time.
The text was updated successfully, but these errors were encountered: