From 8cd2a2e1ac1728dd60a2c4a8b7b15308ade41a0c Mon Sep 17 00:00:00 2001 From: Francesco Canovai Date: Wed, 13 Nov 2024 16:21:06 +0100 Subject: [PATCH] chore: fix linter issues Signed-off-by: Francesco Canovai --- internal/cnpgi/instance/internal/client/client.go | 4 ++++ internal/cnpgi/instance/internal/client/client_test.go | 9 +++++---- internal/cnpgi/operator/lifecycle.go | 4 +--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/cnpgi/instance/internal/client/client.go b/internal/cnpgi/instance/internal/client/client.go index 450179d..66da622 100644 --- a/internal/cnpgi/instance/internal/client/client.go +++ b/internal/cnpgi/instance/internal/client/client.go @@ -50,6 +50,7 @@ func (e *ExtendedClient) refreshTTL(ctx context.Context) error { return nil } +// Get behaves like the original Get method, but uses a cache for secrets func (e *ExtendedClient) Get( ctx context.Context, key client.ObjectKey, @@ -139,6 +140,7 @@ func (e *ExtendedClient) RemoveSecret(key client.ObjectKey) { } } +// Update behaves like the original Update method, but on secrets it removes the secret from the cache func (e *ExtendedClient) Update( ctx context.Context, obj client.Object, @@ -157,6 +159,7 @@ func (e *ExtendedClient) Update( return e.Client.Update(ctx, obj, opts...) } +// Delete behaves like the original Delete method, but on secrets it removes the secret from the cache func (e *ExtendedClient) Delete( ctx context.Context, obj client.Object, @@ -175,6 +178,7 @@ func (e *ExtendedClient) Delete( return e.Client.Delete(ctx, obj, opts...) } +// Patch behaves like the original Patch method, but on secrets it removes the secret from the cache func (e *ExtendedClient) Patch( ctx context.Context, obj client.Object, diff --git a/internal/cnpgi/instance/internal/client/client_test.go b/internal/cnpgi/instance/internal/client/client_test.go index 1313c00..d5fb68d 100644 --- a/internal/cnpgi/instance/internal/client/client_test.go +++ b/internal/cnpgi/instance/internal/client/client_test.go @@ -1,15 +1,16 @@ package client import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/ptr" - "sigs.k8s.io/controller-runtime/pkg/client/fake" "time" - v1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + + v1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" diff --git a/internal/cnpgi/operator/lifecycle.go b/internal/cnpgi/operator/lifecycle.go index 62ec5d1..8155b37 100644 --- a/internal/cnpgi/operator/lifecycle.go +++ b/internal/cnpgi/operator/lifecycle.go @@ -165,14 +165,12 @@ func reconcilePod( request *lifecycle.OperatorLifecycleRequest, pluginConfiguration *config.PluginConfiguration, ) (*lifecycle.OperatorLifecycleResponse, error) { - contextLogger := log.FromContext(ctx).WithName("lifecycle") - pod, err := decoder.DecodePodJSON(request.GetObjectDefinition()) if err != nil { return nil, err } - contextLogger = log.FromContext(ctx).WithName("plugin-barman-cloud-lifecycle"). + contextLogger := log.FromContext(ctx).WithName("plugin-barman-cloud-lifecycle"). WithValues("podName", pod.Name) mutatedPod := pod.DeepCopy()