diff --git a/Taskfile.yml b/Taskfile.yml index 6a4e05c..d530484 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -23,7 +23,7 @@ tasks: # renovate: datasource=git-refs depName=golangci-lint lookupName=https://github.com/sagikazarmark/daggerverse currentValue=main DAGGER_GOLANGCI_LINT_SHA: 5f2dc1bd1014cf79757f4605f2f731ed962d4da7 # renovate: datasource=docker depName=golangci/golangci-lint versioning=semver - GOLANGCI_LINT_VERSION: v2.11.4 + GOLANGCI_LINT_VERSION: v2.12.0 cmds: - > GITHUB_REF= dagger -sc "github.com/sagikazarmark/daggerverse/golangci-lint@${DAGGER_GOLANGCI_LINT_SHA} 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()