From 5108f8ffe58e477ad15086e7e05d2e3281506e85 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 7 Oct 2024 14:26:15 +0100 Subject: [PATCH 1/2] Remove confusing else statement in cache.go --- pkg/cache/cache.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 614eaf78..5133001d 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -152,10 +152,9 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re UseGitCaBundle: c.useGitCaBundle, }); err != nil { return nil, err - } else { - cachedRepo = newRepository(key, repositorySpec, r, c.objectNotifier, c.metadataStore, c.repoSyncFrequency) - c.repositories[key] = cachedRepo } + cachedRepo = newRepository(key, repositorySpec, r, c.objectNotifier, c.metadataStore, c.repoSyncFrequency) + c.repositories[key] = cachedRepo } else { // If there is an error from the background refresh goroutine, return it. if err := cachedRepo.getRefreshError(); err != nil { From 02c618accddd4fef091da763e2b1afeda47a6d5e Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 7 Oct 2024 14:33:21 +0100 Subject: [PATCH 2/2] Fix compile error --- pkg/cache/cache.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 5133001d..9e194cb7 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -145,14 +145,17 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re } else { mbs = git.ErrorIfMissing } - if r, err := git.OpenRepository(ctx, repositorySpec.Name, repositorySpec.Namespace, gitSpec, repositorySpec.Spec.Deployment, filepath.Join(c.cacheDir, "git"), git.GitRepositoryOptions{ + + r, err := git.OpenRepository(ctx, repositorySpec.Name, repositorySpec.Namespace, gitSpec, repositorySpec.Spec.Deployment, filepath.Join(c.cacheDir, "git"), git.GitRepositoryOptions{ CredentialResolver: c.credentialResolver, UserInfoProvider: c.userInfoProvider, MainBranchStrategy: mbs, UseGitCaBundle: c.useGitCaBundle, - }); err != nil { + }) + if err != nil { return nil, err } + cachedRepo = newRepository(key, repositorySpec, r, c.objectNotifier, c.metadataStore, c.repoSyncFrequency) c.repositories[key] = cachedRepo } else {