Skip to content

Commit

Permalink
Merge pull request #316 from depot/feat/gocache-prefer-depot-cache-token
Browse files Browse the repository at this point in the history
feat: default gocache token to DEPOT_CACHE_TOKEN
  • Loading branch information
goller authored Feb 26, 2025
2 parents dc5bf1a + 5f7b56f commit c7e271e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/cmd/gocache/gocache.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ func NewCmdGoCache() *cobra.Command {
return err
}

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

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

func (p *Cache) Run(ctx context.Context) error {
if p.Verbose {
log.Printf("using depot gocache")
}

defer p.RemoteCache.Close()

br := bufio.NewReader(os.Stdin)
Expand Down

0 comments on commit c7e271e

Please sign in to comment.