MCPcopy Index your code
hub / github.com/cli/cli / DefaultOptionsWithCacheSetting

Function DefaultOptionsWithCacheSetting

pkg/cmd/attestation/verification/tuf.go:21–46  ·  view source on GitHub ↗
(tufMetadataDir o.Option[string], hc *http.Client)

Source from the content-addressed store, hash-verified

19const GitHubTUFMirror = "https://tuf-repo.github.com"
20
21func 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
48func GitHubTUFOptions(tufMetadataDir o.Option[string], hc *http.Client) *tuf.Options {
49 opts := DefaultOptionsWithCacheSetting(tufMetadataDir, hc)

Callers 3

getTrustedRootFunction · 0.92
newPublicGoodVerifierFunction · 0.85
GitHubTUFOptionsFunction · 0.85

Calls 3

UnwrapOrMethod · 0.80
JoinMethod · 0.80
CacheDirMethod · 0.65

Tested by

no test coverage detected