Skip to content
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

[spire-server] go template functions (sprig) #5575

Closed
kfox1111 opened this issue Oct 14, 2024 · 4 comments · Fixed by #5593
Closed

[spire-server] go template functions (sprig) #5575

kfox1111 opened this issue Oct 14, 2024 · 4 comments · Fixed by #5593
Labels
priority/backlog Issue is approved and in the backlog unscoped The issue needs more design or understanding in order for the work to progress

Comments

@kfox1111
Copy link
Contributor

The embeded go template engine does not have many useful functions built in.

Other tools such as helm and step-ca embed a library named sprig (https://masterminds.github.io/sprig/)

In particular, some of the string functions are extremely useful. (contains, hasPrefix, trimPrefix, cat, replace, ...)

It would be very easy to embed the library and make it available for use in templates.

Alternately, it would be possible to embed the library and cherry pick only the functions we want to make available to our templates if there is concern there is too many functions there.

@azdagron azdagron added triage/in-progress Issue triage is in progress priority/backlog Issue is approved and in the backlog unscoped The issue needs more design or understanding in order for the work to progress and removed triage/in-progress Issue triage is in progress labels Oct 15, 2024
@azdagron
Copy link
Member

We gave it some discussion. The consensus was that many of these functions seem super useful but a few seem undesirable. In order to pick this up, someone needs to go through that list and make a proposal of functions we'd like to include in the first pass.

@kfox1111
Copy link
Contributor Author

Would be happy to inventory the functions, but not being part of the discussion, am not privy to the thinking behind what might be undesirable. Could you please give some guidance on what that might be?

Alternately, we could start with just the string functions and skip the rest for now?

@azdagron
Copy link
Member

Concerns were mostly around usefulness and some small safety concerns. I think taking only the immediately useful functions on the first pass is appropriate. Others can be added if a strong case can be made.

Things that seem immediately useful:

  • anything to manipulate strings, lists, dicts
  • some of the defaults functions
  • path functions (but not filepath functions, e.g. os*)
  • encoding functions
  • fail
  • uuidv4

Most of the advanced functions seem weird to include. Same with the math, time, and int/float functions.

@kfox1111
Copy link
Contributor Author

Took a really rough stab at making a list.

kfox1111 added a commit to kfox1111/spire that referenced this issue Oct 22, 2024
Fixes: spiffe#5575

Signed-off-by: Kevin Fox <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/backlog Issue is approved and in the backlog unscoped The issue needs more design or understanding in order for the work to progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants