use CLI cache dir to store tuf metadata

Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
Meredith Lancaster 2024-03-20 15:18:19 -06:00
parent 98d7bef299
commit 49dfa3f6d5
2 changed files with 8 additions and 0 deletions

View file

@ -3,7 +3,9 @@ package verification
import (
_ "embed"
"os"
"path/filepath"
"github.com/cli/go-gh/v2/pkg/config"
"github.com/sigstore/sigstore-go/pkg/tuf"
)
@ -23,6 +25,9 @@ func DefaultOptionsWithCacheSetting() *tuf.Options {
opts.DisableLocalCache = true
}
// Set the cache path to a directory owned by the CLI
opts.CachePath = filepath.Join(config.CacheDir(), ".sigstore", "root")
return opts
}

View file

@ -2,8 +2,10 @@ package verification
import (
"os"
"path/filepath"
"testing"
"github.com/cli/go-gh/v2/pkg/config"
"github.com/stretchr/testify/require"
)
@ -14,4 +16,5 @@ func TestGitHubTUFOptions(t *testing.T) {
require.Equal(t, GitHubTUFMirror, opts.RepositoryBaseURL)
require.NotNil(t, opts.Root)
require.True(t, opts.DisableLocalCache)
require.Equal(t, filepath.Join(config.CacheDir(), ".sigstore", "root"), opts.CachePath)
}