From 6067121c6728d71161c6809e0fb41c45d8205e17 Mon Sep 17 00:00:00 2001 From: Armando Ruocco Date: Mon, 21 Oct 2024 15:18:30 +0200 Subject: [PATCH] chore: lint Signed-off-by: Armando Ruocco --- cmd/manager/main.go | 1 - go.mod | 2 +- go.sum | 4 ++-- internal/cnpgi/common/backup.go | 1 + internal/cnpgi/common/doc.go | 2 ++ internal/cnpgi/operator/reconciler.go | 2 +- internal/cnpgi/operator/specs/role.go | 2 +- internal/cnpgi/restore/restore.go | 16 ++++++++++++---- 8 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 internal/cnpgi/common/doc.go diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 4fecd48..c916b69 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -4,7 +4,6 @@ import ( "fmt" "os" - "github.com/cloudnative-pg/machinery/pkg/log" "github.com/spf13/cobra" diff --git a/go.mod b/go.mod index 398605e..3cd5e13 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/cloudnative-pg/barman-cloud v0.0.0-20240924124724-92831d48562a github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241017151552-20297270038b github.com/cloudnative-pg/cnpg-i v0.0.0-20241021130537-c4a74d755f0a - github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241017094517-76870f5660ef + github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241014090747-e9c2b3738d19 github.com/cloudnative-pg/machinery v0.0.0-20241010122207-5ac7af31ef72 github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/gomega v1.34.2 diff --git a/go.sum b/go.sum index fc4f99a..f837ca7 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241017151552-20297270038b h github.com/cloudnative-pg/cloudnative-pg v1.24.1-0.20241017151552-20297270038b/go.mod h1:0grklCuA9WSA5lazBeTgDqLHjxP13fqAhqlveDx7hPg= github.com/cloudnative-pg/cnpg-i v0.0.0-20241021130537-c4a74d755f0a h1:K4c+gX96NAt9C3AeffB8T4tvI3Qn9Fpi5x7Kzd+Iiyg= github.com/cloudnative-pg/cnpg-i v0.0.0-20241021130537-c4a74d755f0a/go.mod h1:fAU7ySVzjpt/RZntxWZiWJCjaBJayzIxEnd0NuO7oQc= -github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241017094517-76870f5660ef h1:Og/btbliFYkJ2sz899T+b832GaFQU4ai52k98zZr0xA= -github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241017094517-76870f5660ef/go.mod h1:X6r1fRuUEIAv4+5SSBY2RmQ201K6GcptOXgnmaX/8tY= +github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241014090747-e9c2b3738d19 h1:qy+LrScvQpIwt4qeg9FfCJuoC9CbX/kpFGLF8vSobXg= +github.com/cloudnative-pg/cnpg-i-machinery v0.0.0-20241014090747-e9c2b3738d19/go.mod h1:X6r1fRuUEIAv4+5SSBY2RmQ201K6GcptOXgnmaX/8tY= github.com/cloudnative-pg/machinery v0.0.0-20241010122207-5ac7af31ef72 h1:3pgtSYhv3RDd+51bnlqICNrcVpWQQvriCOvkxtbZpaE= github.com/cloudnative-pg/machinery v0.0.0-20241010122207-5ac7af31ef72/go.mod h1:bWp1Es5zlxElg4Z/c5f0RKOkDcyNvDHdYIvNcPQU4WM= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= diff --git a/internal/cnpgi/common/backup.go b/internal/cnpgi/common/backup.go index 69ac713..441ef2d 100644 --- a/internal/cnpgi/common/backup.go +++ b/internal/cnpgi/common/backup.go @@ -8,6 +8,7 @@ import ( cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" ) +// GetCredentialsFromBackup extracts the Barman credentials from the backup func GetCredentialsFromBackup(backup *cnpgv1.Backup) (barmanapi.BarmanCredentials, error) { rawCred := backup.Status.PluginMetadata["credentials"] diff --git a/internal/cnpgi/common/doc.go b/internal/cnpgi/common/doc.go new file mode 100644 index 0000000..d5ee793 --- /dev/null +++ b/internal/cnpgi/common/doc.go @@ -0,0 +1,2 @@ +// Package common contains reusable structs and methods for CNPGI plugins. +package common diff --git a/internal/cnpgi/operator/reconciler.go b/internal/cnpgi/operator/reconciler.go index 4142270..c47fc29 100644 --- a/internal/cnpgi/operator/reconciler.go +++ b/internal/cnpgi/operator/reconciler.go @@ -8,7 +8,6 @@ import ( "github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/object" "github.com/cloudnative-pg/cnpg-i/pkg/reconciler" "github.com/cloudnative-pg/machinery/pkg/log" - "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/equality" apierrs "k8s.io/apimachinery/pkg/api/errors" @@ -16,6 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1" + "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common" "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/config" "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/operator/specs" ) diff --git a/internal/cnpgi/operator/specs/role.go b/internal/cnpgi/operator/specs/role.go index 5a4ac09..12ef1ef 100644 --- a/internal/cnpgi/operator/specs/role.go +++ b/internal/cnpgi/operator/specs/role.go @@ -2,9 +2,9 @@ package specs import ( "fmt" - "github.com/cloudnative-pg/machinery/pkg/stringset" cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" + "github.com/cloudnative-pg/machinery/pkg/stringset" rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/internal/cnpgi/restore/restore.go b/internal/cnpgi/restore/restore.go index 9dbb4da..5cd6f99 100644 --- a/internal/cnpgi/restore/restore.go +++ b/internal/cnpgi/restore/restore.go @@ -4,8 +4,6 @@ import ( "context" "errors" "fmt" - "github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/decoder" - "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common" "os" "os/exec" "path" @@ -19,6 +17,7 @@ import ( barmanRestorer "github.com/cloudnative-pg/barman-cloud/pkg/restorer" cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" "github.com/cloudnative-pg/cloudnative-pg/pkg/utils" + "github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/decoder" restore "github.com/cloudnative-pg/cnpg-i/pkg/restore/job" "github.com/cloudnative-pg/machinery/pkg/execlog" "github.com/cloudnative-pg/machinery/pkg/fileutils" @@ -26,6 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1" + "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/common" "github.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/metadata" ) @@ -71,7 +71,11 @@ func (impl JobHookImpl) Restore( ) (*restore.RestoreResponse, error) { contextLogger := log.FromContext(ctx) var cluster cnpgv1.Cluster - if err := decoder.DecodeObject(req.GetClusterDefinition(), &cluster, cnpgv1.GroupVersion.WithKind("Cluster")); err != nil { + if err := decoder.DecodeObject( + req.GetClusterDefinition(), + &cluster, + cnpgv1.GroupVersion.WithKind("Cluster"), + ); err != nil { return nil, err } // Before starting the restore we check if the archive destination is safe to use @@ -82,7 +86,11 @@ func (impl JobHookImpl) Restore( var backup cnpgv1.Backup - if err := decoder.DecodeObject(req.GetBackupDefinition(), &backup, cnpgv1.GroupVersion.WithKind("Backup")); err != nil { + if err := decoder.DecodeObject( + req.GetBackupDefinition(), + &backup, + cnpgv1.GroupVersion.WithKind("Backup"), + ); err != nil { return nil, err }