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

Cache env vars with slow exec function calls in templating #1261

Open
pdecat opened this issue Dec 24, 2023 · 3 comments
Open

Cache env vars with slow exec function calls in templating #1261

pdecat opened this issue Dec 24, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@pdecat
Copy link
Contributor

pdecat commented Dec 24, 2023

Setting environment variables from commands that are slow affects all prompt executions, e.g. setting:

mise env-vars TEST_MISE="{{exec(command='sleep 1')}}"

which translates into:

[env]
TEST_MISE = "{{exec(command='sleep 1')}}"

will add a 1 second latency at each prompt.

It would be awesome to allow caching such commands.

Note: that's just an example, my actual use case is invoking gopass to set an environment variable with GPG operations depending on my yubikey.

@pdecat pdecat added the enhancement New feature or request label Dec 24, 2023
@jdx
Copy link
Owner

jdx commented Dec 24, 2023

I think me putting caching around templates is too difficult. I have no idea what sort of invalidation logic would work since I have no idea what people might be putting in their files.

Perhaps what we could do though is expose caching inside the templates so you could read/write to the cache instead of performing expensive computations.

@hinricht
Copy link

hinricht commented Jun 7, 2024

Caching would be great, please have in mind that exec templates can be used to retrieve secrets so env vars shouldn't be cached/stored on disk unencrypted.

i.e.

[env]
TOKEN = "{{exec(command='gopass show --password token')}}"

@hinricht
Copy link

hinricht commented Jun 7, 2024

Oh just realized this use-case was the original motivation for this FR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants