(tufMetadataDir o.Option[string], hc *http.Client)
| 19 | const GitHubTUFMirror = "https://tuf-repo.github.com" |
| 20 | |
| 21 | func DefaultOptionsWithCacheSetting(tufMetadataDir o.Option[string], hc *http.Client) *tuf.Options { |
| 22 | opts := tuf.DefaultOptions() |
| 23 | |
| 24 | // The CODESPACES environment variable will be set to true in a Codespaces workspace |
| 25 | if os.Getenv("CODESPACES") == "true" { |
| 26 | // if the tool is being used in a Codespace, disable the local cache |
| 27 | // because there is a permissions issue preventing the tuf library |
| 28 | // from writing the Sigstore cache to the home directory |
| 29 | opts.DisableLocalCache = true |
| 30 | } |
| 31 | |
| 32 | // Set the cache path to the provided dir, or a directory owned by the CLI |
| 33 | opts.CachePath = tufMetadataDir.UnwrapOr(filepath.Join(config.CacheDir(), ".sigstore", "root")) |
| 34 | |
| 35 | // Allow TUF cache for 1 day |
| 36 | opts.CacheValidity = 1 |
| 37 | |
| 38 | // configure fetcher timeout and retry |
| 39 | f := fetcher.NewDefaultFetcher() |
| 40 | f.SetHTTPClient(hc) |
| 41 | retryOptions := []backoff.RetryOption{backoff.WithMaxTries(3)} |
| 42 | f.SetRetryOptions(retryOptions...) |
| 43 | opts.WithFetcher(f) |
| 44 | |
| 45 | return opts |
| 46 | } |
| 47 | |
| 48 | func GitHubTUFOptions(tufMetadataDir o.Option[string], hc *http.Client) *tuf.Options { |
| 49 | opts := DefaultOptionsWithCacheSetting(tufMetadataDir, hc) |
no test coverage detected