This repository was archived by the owner on Nov 17, 2021. It is now read-only.
Implement local file cache for HTTP URLs#309
Open
tinyzimmer wants to merge 2 commits intovmware-archive:mainfrom
Open
Implement local file cache for HTTP URLs#309tinyzimmer wants to merge 2 commits intovmware-archive:mainfrom
tinyzimmer wants to merge 2 commits intovmware-archive:mainfrom
Conversation
tinyzimmer
commented
Jun 5, 2021
| } | ||
| } | ||
|
|
||
| var httpRegex = regexp.MustCompile("^(https?)://") |
Author
There was a problem hiding this comment.
I was originally going to just escape the // - hence the capture group.
Ultimately, liked just stripping the protocol and nesting directories more. Makes for an easier to manage cache as well imo.
tinyzimmer
commented
Jun 5, 2021
| if err == nil && !finfo.IsDir() { | ||
| return fmt.Errorf("%q is not a directory, it cannot be used for caching", localPathDir) | ||
| } | ||
| return ioutil.WriteFile(localPath, contents, 0644) |
Author
There was a problem hiding this comment.
I don't know off hand if this will replace an existing symlink to nothing (the afore discussed power-user way of disabling caching for certain things) or return an error. I should test it probably before this is merged. I assume if it doesn't error, we'll want to check for a pre-existing dead link or whatever to make sure we don't mess with something the user did on purpose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a dumb local cache for files fetched remotely. Cache location defaults to
<user_cache_dir>/kubecfg. Files are written to subdirectories matching the "path" fields in the URL.The location of the cache is configurable with the
--cache-dirflag.