From ff426a651e60ef76d09fd686d10ed967aca70f84 Mon Sep 17 00:00:00 2001 From: Leonardo Cecchi Date: Mon, 4 May 2026 14:35:46 +0200 Subject: [PATCH] chore: make linter happy Signed-off-by: Leonardo Cecchi --- internal/cnpgi/operator/lifecycle.go | 7 ++++++- internal/cnpgi/operator/lifecycle_test.go | 4 ++-- internal/cnpgi/operator/specs/role.go | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/cnpgi/operator/lifecycle.go b/internal/cnpgi/operator/lifecycle.go index 8a0bbb5..b25af55 100644 --- a/internal/cnpgi/operator/lifecycle.go +++ b/internal/cnpgi/operator/lifecycle.go @@ -41,6 +41,9 @@ import ( "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/config" ) +// fullRecoveryJobName is the name of the restore job. +const fullRecoveryJobName = "full-recovery" + // LifecycleImplementation is the implementation of the lifecycle handler type LifecycleImplementation struct { lifecycle.UnimplementedOperatorLifecycleServer @@ -48,6 +51,8 @@ type LifecycleImplementation struct { } // GetCapabilities exposes the lifecycle capabilities +// +//nolint:goconst func (impl LifecycleImplementation) GetCapabilities( _ context.Context, _ *lifecycle.OperatorLifecycleCapabilitiesRequest, @@ -186,7 +191,7 @@ func reconcileJob( contextLogger.Debug("starting job reconciliation") jobRole := getCNPGJobRole(&job) - if jobRole != "full-recovery" && + if jobRole != fullRecoveryJobName && jobRole != "snapshot-recovery" { contextLogger.Debug("job is not a recovery job, skipping") return nil, nil diff --git a/internal/cnpgi/operator/lifecycle_test.go b/internal/cnpgi/operator/lifecycle_test.go index 9d70a84..1d76bf7 100644 --- a/internal/cnpgi/operator/lifecycle_test.go +++ b/internal/cnpgi/operator/lifecycle_test.go @@ -139,10 +139,10 @@ var _ = Describe("LifecycleImplementation", func() { Spec: batchv1.JobSpec{Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ - utils.JobRoleLabelName: "full-recovery", + utils.JobRoleLabelName: fullRecoveryJobName, }, }, - Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: "full-recovery"}}}, + Spec: corev1.PodSpec{Containers: []corev1.Container{{Name: fullRecoveryJobName}}}, }}, } jobJSON, _ := json.Marshal(job) diff --git a/internal/cnpgi/operator/specs/role.go b/internal/cnpgi/operator/specs/role.go index 9d61a7b..a53278d 100644 --- a/internal/cnpgi/operator/specs/role.go +++ b/internal/cnpgi/operator/specs/role.go @@ -47,6 +47,8 @@ func BuildRole( } // BuildRoleRules builds the RBAC PolicyRules for the given ObjectStores. +// +//nolint:goconst func BuildRoleRules(barmanObjects []barmancloudv1.ObjectStore) []rbacv1.PolicyRule { secretsSet := stringset.New() barmanObjectsSet := stringset.New()