-
Notifications
You must be signed in to change notification settings - Fork 472
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
Option to not make github API requests when it's not needed #2725
Comments
Thank you for opening the issue and for a very well considered report! For reference, a similar issue is encountered with the tl;dr summary: caching is hard and there might already be a work-around. A couple of questions/possible solutions:
Would any of these be an option for you? |
And on the topic of using sneaky template evaluation methods to solve this problem: I already had an idea that I could use scripts and cache directory to keep my own timestamp of last run, and then gate the offending But again, it feels like an ugly hack for something that should be relatively easy to provide by chezmoi itself. Especially since I expect my case to not really be rare. People probably use |
@mkalinski Running |
Is your feature request related to a problem? Please describe.
When I work with my configuration files, I often like to make a quick tweak, do a
chezmoi apply
, see the results, tweak again, apply again, and so on.Lately, I've started using externals, with
gitHubLatestRelease
to automatically upgrade a tool I'm using. But with my workflow of often callingchezmoi apply
, I've been running into github's rate limiting.I know the usual answer to issues with rate limiting seems to be "connect an API token to lift the limit", but I think it's a wrong solution in my particular case. I just find chezmoi's current behaviour slightly wrong.
Let's assume I had the following external configured:
(I don't update chezmoi this way, this is just a hypothetical.)
Because of
refreshPeriod
, the download has no chance of running more often than once a day. However, every time I dochezmoi apply
, the.chezmoiexternal.toml
file gets evaluated, andgitHubLatestRelease
is called, causing unnecessary web requests, and eventually rate limiting.Of course, the problem is that chezmoi needs to evaluate the template functions in
.chezmoiexternal.toml
before it can read its contents and interpret therefreshPeriod
value. But from the user perspective, this is a bit frustrating, as I feel there really should be an option to let chezmoi know that it shouldn't phone github more often than it's logically necessary.Describe the solution you'd like
I'm going to only consider
gitHub*
functions in.chezmoiexternal
files. I know they could be used in other templates, too, but I feel it's probably really rare, and superfluous to my problem.I think the least problematic solution would be to add a command line flag that would make chezmoi not touch
.chezmoiexternal
files during a run. Like--refresh-externals never
but stronger (--no-externals
?).It's probably the easiest way to flag that I, as a user, am sure that I need no externals update during this run under any circumstances.
Describe alternatives you've considered
Passing
refreshPeriod
togitHub*
functions as an argumentSince the problem is that template functions need to be evaluated before chezmoi can read the
refreshPeriod
value, perhaps it would help to make these functions aware of the value. Something like{{ (gitHubLatestRelease "twpayne/chezmoi" "24h").TagName }}
.Of course, then the problem becomes what should the function evaluate to when it doesn't make a call to github? Should they cache return values between calls? I feel like it's not ideal to ask to make these functions more complicated.
Lazy alternative to template functions for
.chezmoiexternal
Some special syntax that would make chezmoi substitute values in the URL only after reading
refreshPeriod
if needed. For example:It's unfortunately inelegant compared to the template syntax.
The text was updated successfully, but these errors were encountered: