Skip to content

Add sprig template functions to label templates#783

Merged
lucaslorentz merged 1 commit intomasterfrom
fix/container-name-leading-slash
Mar 12, 2026
Merged

Add sprig template functions to label templates#783
lucaslorentz merged 1 commit intomasterfrom
fix/container-name-leading-slash

Conversation

@lucaslorentz
Copy link
Owner

Summary

  • Adds the sprig template function library, giving users access to 100+ utility functions (string manipulation, math, date, etc.) in Docker label templates
  • Sprig was already a transitive dependency, so no new dependencies are added
  • This enables workarounds for issues like Template to get container name includes leading slash #648 (container names with leading slash from Docker API), e.g.: {{trimPrefix "/" (index .Names 0)}}

Closes #648

Test plan

  • All existing tests pass
  • Updated TestContainers_TemplateData to use trimPrefix with a realistic /container-name input from the Docker API

🤖 Generated with Claude Code

Add the sprig template function library, giving users access to
100+ utility functions (string manipulation, math, date, etc.)
in their Docker label templates.

This enables workarounds like trimPrefix for the leading slash in
container names from the Docker API, e.g.:
  {{trimPrefix "/" (index .Names 0)}}

Closes #648

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lucaslorentz lucaslorentz force-pushed the fix/container-name-leading-slash branch from ffbb8b9 to 1cb9231 Compare March 11, 2026 21:15
@lucaslorentz lucaslorentz merged commit 007a0c1 into master Mar 12, 2026
3 checks passed
@lucaslorentz lucaslorentz deleted the fix/container-name-leading-slash branch March 12, 2026 06:07
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.

Template to get container name includes leading slash

1 participant