Add a foldersIn templating function - #120
Conversation
Adds a subdirectories templating function which enables ConfigMap templating to be highly dynamic based on the structure of the project it's pulling from. This is useeful when a directory has a set of homogeneous subdirectories. (e.g. subdirectories a and b both have the same set of secrets, and the subdirectory names a and b may not be known).
Fixes the feedback from @greptile-apps: Incorrect leaf-exclusion filter silently drops valid subdirectories. The tree allows a node to carry both a `Secret` (when a secret key name matches a directory segment name) and `Children` (when that segment also has nested secrets). The current guard if child.Secret != nil { continue } skips any such node, so `subdirectories("/")` would never return a folder whose name collides with a root-level secret key, even though `BuildSecretTree` explicitly supports this state (see the "allows a secret key and folder segment with the same name" test). The correct predicate is to skip nodes that have no children (pure leaves), not nodes that happen to also carry a secret value.
This naming is more consistent with other templating function names and less ambiguous than subdirectories.
|
💬 Discussion in Slack: #pr-review-kubernetes-operator-120-add-a-foldersin-templating-function Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| internal/template/v1/template.go | Adds foldersIn using the existing secret tree, correctly excludes secret leaves, retains colliding folder nodes, and sorts results deterministically. |
| internal/template/v1/template_test.go | Adds focused coverage for immediate folders, paths, root traversal, absent paths, secret leaves, and secret/folder collisions. |
| internal/model/model.go | Adds the simple name-and-path model exposed by foldersIn. |
| helm-charts/secrets-operator/Chart.yaml | Bumps the chart and application versions consistently to v0.11.8. |
| helm-charts/secrets-operator/values.yaml | Aligns the default operator image tag with the new application version. |
Reviews (1): Last reviewed commit: "Update template_test.go" | Re-trigger Greptile
Adds a subdirectories templating function which enables ConfigMap templating to be highly dynamic based on the structure of the project it's pulling from.
This is useeful when a directory has a set of homogeneous subdirectories. (e.g. subdirectories a and b both have the same set of secrets, and the subdirectory names a and b may not be known).