mise
mise copied to clipboard
Cache env vars with slow exec function calls in templating
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.
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.
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')}}"
Oh just realized this use-case was the original motivation for this FR :)