Skip to content

feat: string template functions for projection schemas#134

Merged
jamestexas merged 2 commits intomainfrom
feat/template-string-funcs
Mar 25, 2026
Merged

feat: string template functions for projection schemas#134
jamestexas merged 2 commits intomainfrom
feat/template-string-funcs

Conversation

@jamestexas
Copy link
Copy Markdown
Contributor

Summary

  • Adds 10 string template functions to the schema FuncMap: replace, lower, upper, title, split, join, hasPrefix, hasSuffix, trimPrefix, trimSuffix
  • join takes sep as first arg so it works in pipelines: {{split .s ":" | join ", "}}
  • Needed for trivy-db/osv-scanner projection schemas (namespace → bucket name mapping)

Test plan

  • 19 tests covering all functions including edge cases and pipeline composition
  • task lint — 0 issues
  • task test — full suite green

Bead: mache-996aaf

🤖 Generated with Claude Code

…plit, join, hasPrefix, hasSuffix, trimPrefix, trimSuffix

Extends the schema FuncMap with standard string ops needed for
projection schemas (trivy-db, osv-scanner). join takes sep as first
arg so it works in pipelines: {{split .s ":" | join ", "}}.

19 tests, all TDD.

[mache-996aaf]
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds common string manipulation helpers to the ingestion template FuncMap so projection schemas (e.g., trivy-db/osv-scanner) can transform fields like namespaces into bucket/path-friendly names.

Changes:

  • Extend tmplFuncs with 10 string functions: replace, lower, upper, title, split, join, hasPrefix, hasSuffix, trimPrefix, trimSuffix
  • Implement join(sep, parts) to work naturally in template pipelines and to accept both []string and JSON-parsed []any
  • Add a dedicated test suite covering the new functions and pipeline composition

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/ingest/engine.go Adds the new string template functions to the shared tmplFuncs map (used by RenderTemplate)
internal/ingest/template_funcs_test.go New tests validating each added function plus pipeline chaining and []any handling for join

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/ingest/engine.go Outdated
Comment thread internal/ingest/engine.go Outdated
Comment thread internal/ingest/template_funcs_test.go Outdated
…nt, rename test

- title func: replace deprecated strings.Title with cases.Title(language.Und)
- join comment: fix arg order to match signature (sep, parts)
- Rename TestTemplateFuncs_SplitJoinReplace → SplitJoin (accurate name)

[mache-996aaf]
@jamestexas jamestexas merged commit 949c727 into main Mar 25, 2026
14 checks passed
@jamestexas jamestexas deleted the feat/template-string-funcs branch March 25, 2026 21:17
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.

2 participants