2 ms·
> ...just means YAML juggling. Perhaps I'm missing something, but even the "YAML juggling" still seems to be in an immature stage. As an example, a problem I'v
by yourapostasy 2y ago
> ...just means YAML juggling.
Perhaps I'm missing something, but even the "YAML juggling" still seems to be in an immature stage. As an example, a problem I've been wrestling with recently where I could not find a solution with yq or other YAML wrangling tooling is the following.
Say I have a YAML fragment like this:
rules:
- apiGroups:
- rbac.authorization.k8s.io
resources:
-clusterroles
verbs:
- get
- apiGroups:
- rbac.authorization.k8s.io
resources:
-clusterroles
verbs:
- list
I want to condense it to this:
rules:
- apiGroups:
- rbac.authorization.k8s.io
resources:
-clusterroles
verbs:
- get
- list
More generally, I want to find the smallest most compact representation possible between the apiGroups, resources and verbs terms, combining everywhere possible. In the example, I combined the verbs, but the same combining can take place for the apiGroups and resources terms. This comes in really handy when cleaning up a litter trail of these constructs built from figuring out what resources to add to enable more complex Helm Chart installs (the iterative nature of that exercise is another rant in itself) in reasonably restrictive environments.
I resorted to writing a script to solve just this problem, but I keep thinking I must have missed some solution to this everyone else seems to have solved but me. Apparently the solution eludes my local K8S experts as well, because they condense it by hand, which I refuse to accept as the proper solution.