-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add slim-sprig functions to template language #451
Conversation
actions/recipe.go
Outdated
- decimal: Returns the integer argument as a decimal integer e.g. `{{ decimal 0x40 }} => 64` | ||
- add: Returns the calculation of two integer arguments `a + b`, e.g. `{{ add 1 1 }} => 2` | ||
- sub: Returns the calculation of two integer arguments `a - b`, e.g. `{{ sub 10 1 }} => 9` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go this route i'd rather pull in exist library with template functions; doing some google makes sprig come up (https://pkg.go.dev/github.com/go-task/slim-sprig/v3#section-readme) with includes those and many more integer operations etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep it seems to work; i have added that into the top commit.
it's in debian as https://packages.debian.org/sid/source/golang-github-masterminds-sprig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's the full sprig mind ; slim-spring limits sprig to not depend on extra dependencies (which may avoid the CI failure you're seeing)..
Also can you clean up you branch so it doesn't have commits that get converted later and drop the decimal function ? that should be unneeded (int should do the trick there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added slim-sprig, it's not in debian yet though.
right I did that as a quick test, it wasnt of course meant to be final ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a minimal test case to ensure the functions are available? Also it seems to fail to build on bullseye, though i'm ok to drop support for that assuming it's due to a golang version issue.
7953f28
to
34ae5ee
Compare
34ae5ee
to
503694b
Compare
actions/recipe.go
Outdated
- decimal: Returns the integer argument as a decimal integer e.g. `{{ decimal 0x40 }} => 64` | ||
- add: Returns the calculation of two integer arguments `a + b`, e.g. `{{ add 1 1 }} => 2` | ||
- sub: Returns the calculation of two integer arguments `a - b`, e.g. `{{ sub 10 1 }} => 9` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added slim-sprig, it's not in debian yet though.
right I did that as a quick test, it wasnt of course meant to be final ;-)
503694b
to
0a13528
Compare
slim-sprig is a lightweight library containing a number of useful helper functions which are useful to use in go templates. Include it in debos so we can use the functions in recipes. Signed-off-by: Christopher Obbard <[email protected]>
aa282b0
to
b7884de
Compare
Renaming the escaping test to a general templating test and add tests for a selection of functions from sprig-slim as well as the builtin sector function Signed-off-by: Sjoerd Simons <[email protected]>
No description provided.