Skip to content

Add a foldersIn templating function - #120

Merged
varonix0 merged 5 commits into
mainfrom
daniel/folders-in-templating-function
Aug 6, 2026
Merged

Add a foldersIn templating function#120
varonix0 merged 5 commits into
mainfrom
daniel/folders-in-templating-function

Conversation

@varonix0

@varonix0 varonix0 commented Aug 6, 2026

Copy link
Copy Markdown
Member

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).

jwilm and others added 5 commits August 3, 2026 14:12
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.
@infisical-review-police

Copy link
Copy Markdown

💬 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.

@varonix0 varonix0 self-assigned this Aug 6, 2026
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

Adds the foldersIn template helper for deterministically listing immediate child folders with their names and paths, including secret/folder name collisions.

  • Adds the V1Folder template result model.
  • Adds folder traversal, leaf exclusion, and name sorting.
  • Covers root, missing, leaf-only, collision, and path-output behavior in tests.
  • Bumps the chart, application, and default image versions to v0.11.8.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete correctness or security issues identified in the changed behavior.

The helper follows the existing tree’s construction and path semantics, handles secret/folder collisions, produces deterministic output, and does not introduce network access or weaken an authorization boundary.

Important Files Changed

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

@varonix0
varonix0 merged commit fc5931f into main Aug 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants