version/mkversion: allow env config of oss git cache dir

Updates tailscale/corp#21262

Change-Id: I80bd880b53f6d851c15479f39fad62b25f1095f1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2024-07-01 16:10:33 -07:00 committed by Brad Fitzpatrick
parent ddf94a7b39
commit da32468988
1 changed files with 7 additions and 4 deletions

View File

@ -336,11 +336,14 @@ type verInfo struct {
const unknownPatchVersion = 9999999
func infoFromCache(ref string, runner dirRunner) (verInfo, error) {
cacheDir, err := os.UserCacheDir()
if err != nil {
return verInfo{}, fmt.Errorf("Getting user cache dir: %w", err)
tailscaleCache := os.Getenv("TS_MKVERSION_OSS_GIT_CACHE")
if tailscaleCache == "" {
cacheDir, err := os.UserCacheDir()
if err != nil {
return verInfo{}, fmt.Errorf("Getting user cache dir: %w", err)
}
tailscaleCache = filepath.Join(cacheDir, "tailscale-oss")
}
tailscaleCache := filepath.Join(cacheDir, "tailscale-oss")
r := dirRunner(tailscaleCache)
if _, err := os.Stat(tailscaleCache); err != nil {