Skip to content

Commit

Permalink
Omit empty cache entries
Browse files Browse the repository at this point in the history
It is not necessary to persist `"login": null` or `"service-principals": {}`.
  • Loading branch information
tobias-hashicorp committed Nov 6, 2023
1 parent 18213f8 commit 8ab425a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions auth/tokencache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
// cache is used to (un-)marshal the cached tokens from/to JSON.
type cache struct {
// Login contains the cached tokens for the interactive login session
Login *cacheEntry `json:"login"`
Login *cacheEntry `json:"login,omitempty"`

// ServicePrincipals contains cached tokens for service principals. The key is the service principal key's client_id.
ServicePrincipals map[string]cacheEntry `json:"service-principals"`
ServicePrincipals map[string]cacheEntry `json:"service-principals,omitempty"`

// Workloads contains cached tokens for workload identity providers. The key is the workload identity provider's
// resource name.
Workloads map[string]cacheEntry `json:"workloads"`
Workloads map[string]cacheEntry `json:"workloads,omitempty"`
}

// readCache will read the cached tokens from a file. If an error occurs it will return an error and an empty cache
Expand Down

0 comments on commit 8ab425a

Please sign in to comment.