Skip to content

Commit 2a75d40

Browse files
authored
fix: logic to retrieve ObjectStore from cache (#429)
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 0769a28 commit 2a75d40

File tree

1 file changed

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

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
corev1 "k8s.io/api/core/v1"
1212
"k8s.io/apimachinery/pkg/runtime"
1313
"sigs.k8s.io/controller-runtime/pkg/client"
14+
15+
pluginBarman "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
1416
)
1517

1618
// DefaultTTLSeconds is the default TTL in seconds of cache entries
@@ -48,7 +50,7 @@ func (e *ExtendedClient) isObjectCached(obj client.Object) bool {
4850
return true
4951
}
5052

51-
if _, isObjectStore := obj.(*corev1.Secret); isObjectStore {
53+
if _, isObjectStore := obj.(*pluginBarman.ObjectStore); isObjectStore {
5254
return true
5355
}
5456

@@ -62,11 +64,11 @@ func (e *ExtendedClient) Get(
6264
obj client.Object,
6365
opts ...client.GetOption,
6466
) error {
65-
if !e.isObjectCached(obj) {
66-
return e.Client.Get(ctx, key, obj, opts...)
67+
if e.isObjectCached(obj) {
68+
return e.getCachedObject(ctx, key, obj, opts...)
6769
}
6870

69-
return e.getCachedObject(ctx, key, obj, opts...)
71+
return e.Client.Get(ctx, key, obj, opts...)
7072
}
7173

7274
func (e *ExtendedClient) getCachedObject(

0 commit comments

Comments
 (0)