allow passing github cache v2 urls from env

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2025-02-11 12:51:46 -08:00
parent 03569c2188
commit e1f690abfc
No known key found for this signature in database
GPG Key ID: AFA9DE5F8AB7AF39

View File

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"maps" "maps"
"os" "os"
"strconv"
"strings" "strings"
awsconfig "github.com/aws/aws-sdk-go-v2/config" awsconfig "github.com/aws/aws-sdk-go-v2/config"
@ -204,14 +205,29 @@ func addGithubToken(ci *controllerapi.CacheOptionsEntry) {
if ci.Type != "gha" { if ci.Type != "gha" {
return return
} }
version, ok := ci.Attrs["version"]
if !ok {
if v, ok := os.LookupEnv("ACTIONS_CACHE_SERVICE_V2"); ok {
if b, err := strconv.ParseBool(v); err == nil && b {
version = "2"
ci.Attrs["version"] = version
}
}
}
if _, ok := ci.Attrs["token"]; !ok { if _, ok := ci.Attrs["token"]; !ok {
if v, ok := os.LookupEnv("ACTIONS_RUNTIME_TOKEN"); ok { if v, ok := os.LookupEnv("ACTIONS_RUNTIME_TOKEN"); ok {
ci.Attrs["token"] = v ci.Attrs["token"] = v
} }
} }
if _, ok := ci.Attrs["url"]; !ok { if _, ok := ci.Attrs["url"]; !ok {
if v, ok := os.LookupEnv("ACTIONS_CACHE_URL"); ok { if version == "2" {
ci.Attrs["url"] = v if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
ci.Attrs["url"] = v
}
} else {
if v, ok := os.LookupEnv("ACTIONS_CACHE_URL"); ok {
ci.Attrs["url"] = v
}
} }
} }
} }