From da32468988adeeecce8f86e7a28628c0aa475a20 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 1 Jul 2024 16:10:33 -0700 Subject: [PATCH] version/mkversion: allow env config of oss git cache dir Updates tailscale/corp#21262 Change-Id: I80bd880b53f6d851c15479f39fad62b25f1095f1 Signed-off-by: Brad Fitzpatrick --- version/mkversion/mkversion.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/version/mkversion/mkversion.go b/version/mkversion/mkversion.go index 7d0a0f5eb..148bca926 100644 --- a/version/mkversion/mkversion.go +++ b/version/mkversion/mkversion.go @@ -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 {