crossplane-contrib / function-go-templating

A Go templating composition function
https://crossplane.io
Apache License 2.0
37 stars 26 forks source link

Support for additional sprig template functions #102

Open nothingofuse opened 3 weeks ago

nothingofuse commented 3 weeks ago

What problem are you facing?

I want to use function-go-templating to do things like:

How could this Function help solve your problem?

By implementing more of the functions from the masterminds/sprig library the function is using to enable support for more of the library's functions, primarily the functions in http://masterminds.github.io/sprig/defaults.html http://masterminds.github.io/sprig/strings.html http://masterminds.github.io/sprig/lists.html

LCaparelli commented 1 week ago

I would also add that supporting Sprig functions would assist engineers that are already used to Helm, which provides the same Spring functions. Familiarity with Helm seems to be one of the goals of this function, or at least being as familiar to the user as possible, a very nice-to-have feature in that sense.

jaylevin commented 1 week ago

This function already supports all the Sprig functions.

From the README:

This function supports all of Go's built-in template functions. The above examples use the index function to access keys like resource-name that contain periods, hyphens and other special characters. Like Helm, this function also supports Sprig template functions as well as additional functions.

LCaparelli commented 1 week ago

@jaylevin You're right, the function that I was looking for and couldn't find was truncate, which doesn't exist and I really meant to use trunc :sweat_smile: .

Thanks, sorry for the noise.