Skip to content

Commit

Permalink
fix: test print, no opts set, var type nit
Browse files Browse the repository at this point in the history
Signed-off-by: nromriell <nateromriell@gmail.com>
  • Loading branch information
nromriell committed Mar 23, 2024
1 parent f069756 commit d8c2313
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions reposerver/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func AddCacheFlagsToCmd(cmd *cobra.Command, opts ...cacheutil.Options) func() (*

cmd.Flags().DurationVar(&repoCacheExpiration, "repo-cache-expiration", env.ParseDurationFromEnv("ARGOCD_REPO_CACHE_EXPIRATION", 24*time.Hour, 0, math.MaxInt64), "Cache expiration for repo state, incl. app lists, app details, manifest generation, revision meta-data")
cmd.Flags().DurationVar(&revisionCacheExpiration, "revision-cache-expiration", env.ParseDurationFromEnv("ARGOCD_RECONCILIATION_TIMEOUT", 3*time.Minute, 0, math.MaxInt64), "Cache expiration for cached revision")
cmd.Flags().DurationVar(&revisionCacheExpiration, "revision-cache-lock-timeout", env.ParseDurationFromEnv("ARGOCD_REVISION_CACHE_LOCK_TIMEOUT", 10*time.Second, 0, math.MaxInt64), "Cache TTL for locks to prevent duplicate requests on revisions, set to 0 to disable")
cmd.Flags().DurationVar(&revisionCacheLockTimeout, "revision-cache-lock-timeout", env.ParseDurationFromEnv("ARGOCD_REVISION_CACHE_LOCK_TIMEOUT", 10*time.Second, 0, math.MaxInt64), "Cache TTL for locks to prevent duplicate requests on revisions, set to 0 to disable")

repoFactory := cacheutil.AddCacheFlagsToCmd(cmd, opts...)

Expand Down Expand Up @@ -230,7 +230,6 @@ func (c *Cache) GetGitReferences(repo string, references *[]*plumbing.Reference)
return "", err
// Value is set
case valueExists && input[0][0] != cacheutil.CacheLockedValue:
fmt.Printf("Input: %v\n", references)
*references = *GitRefCacheItemToReferences(input)
return "", nil
// Key is locked
Expand Down
2 changes: 1 addition & 1 deletion reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newCacheMocks() *repoCacheMocks {
return newCacheMocksWithOpts(1*time.Minute, 1*time.Minute, 10*time.Second)
}

func newCacheMocksWithOpts(repoCacheExpiration time.Duration, revisionCacheExpiration time.Duration, revisionCacheLockTimeout time.Duration) *repoCacheMocks {
func newCacheMocksWithOpts(repoCacheExpiration, revisionCacheExpiration, revisionCacheLockTimeout time.Duration) *repoCacheMocks {
mockRepoCache := repositorymocks.NewMockRepoCache(&repositorymocks.MockCacheOptions{
RepoCacheExpiration: 1 * time.Minute,
RevisionCacheExpiration: 1 * time.Minute,
Expand Down
6 changes: 3 additions & 3 deletions util/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ func (c *Cache) generateFullKey(key string) string {

// Sets or deletes an item in cache
func (c *Cache) SetItem(key string, item interface{}, opts *CacheActionOpts) error {
if opts == nil {
opts = &CacheActionOpts{}
}
if item == nil {
return fmt.Errorf("cannot set nil item in cache")
}
if opts == nil {
opts = &CacheActionOpts{}
}
fullKey := c.generateFullKey(key)
client := c.GetClient()
if opts.Delete {
Expand Down

0 comments on commit d8c2313

Please sign in to comment.