Skip to content

Commit 9a05892

Browse files
committed
fix: logic to retrieve ObjectStore from cache
There was mistake on the object used to compare the ObjectStore, we were using a type Secret instead of ObjectStore. Also, make it more clear the logic to retrieve the cached objects by getting the cached objects when are cached. Signed-off-by: Jonathan Gonzalez V. <[email protected]>
1 parent a225902 commit 9a05892

File tree

1 file changed

+5
-4
lines changed
  • internal/cnpgi/instance/internal/client

1 file changed

+5
-4
lines changed

internal/cnpgi/instance/internal/client/client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package client
33
import (
44
"context"
55
"fmt"
6+
pluginBarman "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
67
"reflect"
78
"sync"
89
"time"
@@ -48,7 +49,7 @@ func (e *ExtendedClient) isObjectCached(obj client.Object) bool {
4849
return true
4950
}
5051

51-
if _, isObjectStore := obj.(*corev1.Secret); isObjectStore {
52+
if _, isObjectStore := obj.(*pluginBarman.ObjectStore); isObjectStore {
5253
return true
5354
}
5455

@@ -62,11 +63,11 @@ func (e *ExtendedClient) Get(
6263
obj client.Object,
6364
opts ...client.GetOption,
6465
) error {
65-
if !e.isObjectCached(obj) {
66-
return e.Client.Get(ctx, key, obj, opts...)
66+
if e.isObjectCached(obj) {
67+
return e.getCachedObject(ctx, key, obj, opts...)
6768
}
6869

69-
return e.getCachedObject(ctx, key, obj, opts...)
70+
return e.Client.Get(ctx, key, obj, opts...)
7071
}
7172

7273
func (e *ExtendedClient) getCachedObject(

0 commit comments

Comments
 (0)