feat(templates): auto-discover flowfile templates on sync#413
Merged
Conversation
Templates previously had to be registered by name in the global config to be usable via name. They are now also auto-discovered from *.flow.tmpl files within workspaces during `flow sync`, mirroring how executables are found. - share the workspace walk between executable and template discovery - add a TemplateCache stage to cache.UpdateAll, wired into the app context - resolve templates by name: -f path > registered name > discovered name; support a workspace/name form to disambiguate cross-workspace collisions - merge registered + discovered templates in `template list` - add a workspace-scoped `templates` include/exclude filter (flow.yaml) - normalize registered template paths to absolute - fix .tmpl.flow test fixtures to the canonical .flow.tmpl extension Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Flowfile templates previously had to be registered by name (
flow template add) in the global config to be usable by name. This PR makes them auto-discovered from*.flow.tmplfiles within workspaces duringflow sync— the same way executables (.flowfiles) are found — so dropping a template into a workspace makes it available with zero configuration.Registration still works and is preserved for templates that live outside a workspace or should be available from every workspace.
Resolution order:
-f <path>→ registered name → discovered name.What changed
pkg/filesystem/executables.go): extracted the workspace tree walk into a sharedfindFiles(cfg, filter, match); executable discovery is behavior-preserving.pkg/filesystem/templates.go):LoadWorkspaceFlowFileTemplates, mirroring the executable loader.TemplateCache(pkg/cache/templates_cache.go): mirrorsExecutableCacheImpl— validates each template, warns on cross-workspace name collisions, persists to the store. Added as a third stage incache.UpdateAll, soflow syncdiscovers templates.pkg/context/context.go):Context.TemplateCacheconstructed and propagated inShallowCopy.cmd/internal/): name resolution falls back to the cache;template listmerges registered + discovered (registered wins on collision);template addnow stores absolute paths.types/workspace/schema.yaml): atemplatesinclude/exclude block inflow.yaml, same semantics asexecutables..tmpl.flow→.flow.tmplin test fixtures.Only files with the exact
.flow.tmplextension are discovered, so artifact partials likedeployment.yaml.tmplare never treated as template generators. For cross-workspace name collisions, aworkspace/namereference disambiguates.Testing
mergeTemplatesprecedence..flow.tmpl,flow sync, then list and generate it.flow validatepasses (generate → lint → unit + e2e → schemas).🤖 Generated with Claude Code