Skip to content

Commit c7e271e

Browse files
authored
Merge pull request #316 from depot/feat/gocache-prefer-depot-cache-token
feat: default gocache token to DEPOT_CACHE_TOKEN
2 parents dc5bf1a + 5f7b56f commit c7e271e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/cmd/gocache/gocache.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ func NewCmdGoCache() *cobra.Command {
4848
return err
4949
}
5050

51-
token, err := helpers.ResolveToken(ctx, token)
51+
token := os.Getenv("DEPOT_CACHE_TOKEN")
52+
token, err = helpers.ResolveToken(ctx, token)
5253
if err != nil {
5354
return err
5455
}
@@ -66,7 +67,7 @@ func NewCmdGoCache() *cobra.Command {
6667
flags.SortFlags = false
6768
flags.BoolVarP(&verbose, "verbose", "v", false, "Print verbose output")
6869
flags.StringVar(&token, "token", "", "Depot token")
69-
flags.StringVarP(&orgID, "organization", "o", "", "Depot organization ID")
70+
flags.StringVarP(&orgID, "organization", "o", os.Getenv("DEPOT_ORG_ID"), "Depot organization ID")
7071
flags.StringVar(&dir, "dir", defaultCacheDir(), "Directory to store cache files")
7172

7273
return cmd
@@ -126,6 +127,10 @@ func NewCache(baseURL, orgID, token, dir string, verbose bool) *Cache {
126127
}
127128

128129
func (p *Cache) Run(ctx context.Context) error {
130+
if p.Verbose {
131+
log.Printf("using depot gocache")
132+
}
133+
129134
defer p.RemoteCache.Close()
130135

131136
br := bufio.NewReader(os.Stdin)

0 commit comments

Comments
 (0)