Skip to content

Add template functions from sprig #418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 28, 2022
Merged

Add template functions from sprig #418

merged 6 commits into from
Mar 28, 2022

Conversation

rhansen
Copy link
Collaborator

@rhansen rhansen commented Mar 20, 2022

This PR adds a bunch of useful template functions from the sprig library, which makes it easier/possible to introduce more advanced logic in templates.

Fixes #177 by adding useful functions like append, join, and set.

Fixes #293 by enabling templates to use a Go map object as a set (via the set and hasKey functions).

Fixes #323 by adding a new getHostByName function.

The removed functions were removed because sprig offers those same functions with the same behavior. I left functions with the same name but different behavior alone to avoid breaking existing templates.

@buchdag
Copy link
Member

buchdag commented Mar 20, 2022

Hi. Could you give us a bit more info about what this PR does and how it fixes those three issues ?

@rhansen
Copy link
Collaborator Author

rhansen commented Mar 20, 2022

Updated the PR description with more context.

@buchdag
Copy link
Member

buchdag commented Mar 20, 2022

I'll look into this ASAP, thanks for the PR !

rhansen added 4 commits March 27, 2022 17:06
This prevents one failed test case from aborting attempts for the
other test cases, and it makes it easier to iterate on a particular
test case.
The template name doesn't need to be globally unique.
@rhansen
Copy link
Collaborator Author

rhansen commented Mar 27, 2022

I added some tests to ensure that the migration to sprig doesn't break any existing templates.

@buchdag

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is it possible to get ip? Add “Set” Function Go Template seems to be a bit limited. Is there any way we might have e.g. jinja2?
2 participants