diff --git a/.golangci.yaml b/.golangci.yaml index 13aeb81467..b73faa119d 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -57,7 +57,7 @@ linters: deny: - pkg: net/http/httptest desc: Should be used only in tests. - - pkg: github.com/percona/percona-postgresql-operator/v2/internal/testing/* + - pkg: github.com/percona/percona-postgresql-operator/v3/internal/testing/* desc: The "internal/testing" packages should be used only in tests. - pkg: errors desc: Use "github.com/pkg/errors" instead (errors.Wrap/Wrapf/Errorf) for stack traces. diff --git a/Jenkinsfile b/Jenkinsfile index 537f9cd964..db92843aed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -517,7 +517,7 @@ pipeline { -e GO111MODULE=on \ golang:1.26.0 sh -c ' go install github.com/google/go-licenses@latest; - /go/bin/go-licenses csv github.com/percona/percona-postgresql-operator/v2/cmd/postgres-operator \ + /go/bin/go-licenses csv github.com/percona/percona-postgresql-operator/v3/cmd/postgres-operator \ | cut -d , -f 3 \ | sort -u \ > go-licenses-new || : diff --git a/Makefile b/Makefile index 24ce2f8279..7a722df8c2 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,12 @@ build-postgres-operator: ## Build the postgres-operator binary ) --trimpath -o bin/postgres-operator ./cmd/postgres-operator ##@ Test +GOLANGCI_LINT_VERSION ?= v2.12.2 + +.PHONY: lint +lint: ## Run golangci-lint (same as CI) + go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --timeout 5m --max-issues-per-linter 0 --max-same-issues 0 + .PHONY: check check: ## Run basic go tests with coverage output check: get-pgmonitor diff --git a/cmd/extension-installer/main.go b/cmd/extension-installer/main.go index 6f628e0f85..d4a42bc1ff 100644 --- a/cmd/extension-installer/main.go +++ b/cmd/extension-installer/main.go @@ -7,7 +7,7 @@ import ( "os" "path" - "github.com/percona/percona-postgresql-operator/v2/percona/extensions" + "github.com/percona/percona-postgresql-operator/v3/percona/extensions" ) func main() { @@ -77,7 +77,7 @@ func initStorage(storageType extensions.StorageType, endpoint, bucket, region st case extensions.StorageTypeS3: return extensions.NewS3(endpoint, region, bucket, s3ForcePathStyle, disableSSL) default: - log.Fatalf("unknown storage type: %s", os.Getenv("STORAGE_TYPE")) + log.Fatalf("unknown storage type: %s", string(storageType)) } return nil diff --git a/cmd/pgbackrest/main.go b/cmd/pgbackrest/main.go index bda9fc29bf..a8260e1f55 100644 --- a/cmd/pgbackrest/main.go +++ b/cmd/pgbackrest/main.go @@ -142,6 +142,10 @@ func (k *KubeAPI) Exec(ctx context.Context, namespace, pod, container string, st }, ParameterCodec) exec, err := remotecommand.NewSPDYExecutor(k.Config, "POST", request.URL()) + if err != nil { + log.Error(err) + return err + } stdoutReader, stdoutWriter := io.Pipe() defer func() { @@ -384,7 +388,7 @@ else fi ` - localHashCmd := exec.Command("bash", "-ceu", "--", localScript) + localHashCmd := exec.CommandContext(ctx, "bash", "-ceu", "--", localScript) hashOutput, err := localHashCmd.Output() if err != nil { log.Fatalf("unable to calculate hash for pgBackRest config: %v", err) diff --git a/cmd/pgbouncer-startup/main.go b/cmd/pgbouncer-startup/main.go index cd5b35d827..f64b6d1fa0 100644 --- a/cmd/pgbouncer-startup/main.go +++ b/cmd/pgbouncer-startup/main.go @@ -12,8 +12,8 @@ import ( "github.com/pkg/errors" - pgbruntime "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer/startup" + pgbruntime "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer/startup" ) const ( diff --git a/cmd/pgbouncer-startup/main_test.go b/cmd/pgbouncer-startup/main_test.go index 4887daf4a9..309291135f 100644 --- a/cmd/pgbouncer-startup/main_test.go +++ b/cmd/pgbouncer-startup/main_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/mock" "gotest.tools/v3/assert" - pgbmock "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime/pgbouncer/mock" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer/startup" + pgbmock "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime/pgbouncer/mock" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer/startup" ) func TestPauseWanted(t *testing.T) { diff --git a/cmd/postgres-operator/main.go b/cmd/postgres-operator/main.go index 6cae8a70e8..7e01f72646 100644 --- a/cmd/postgres-operator/main.go +++ b/cmd/postgres-operator/main.go @@ -30,26 +30,26 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/pgupgrade" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/standalone_pgadmin" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/upgradecheck" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - perconaController "github.com/percona/percona-postgresql-operator/v2/percona/controller" - "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgbackup" - "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgcluster" - "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgrestore" - perconaPGUpgrade "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgupgrade" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - perconaRuntime "github.com/percona/percona-postgresql-operator/v2/percona/runtime" - "github.com/percona/percona-postgresql-operator/v2/percona/utils/registry" - "github.com/percona/percona-postgresql-operator/v2/percona/watcher" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/pgupgrade" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/standalone_pgadmin" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/upgradecheck" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + perconaController "github.com/percona/percona-postgresql-operator/v3/percona/controller" + "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgbackup" + "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgcluster" + "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgrestore" + perconaPGUpgrade "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgupgrade" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + perconaRuntime "github.com/percona/percona-postgresql-operator/v3/percona/runtime" + "github.com/percona/percona-postgresql-operator/v3/percona/utils/registry" + "github.com/percona/percona-postgresql-operator/v3/percona/watcher" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var ( @@ -158,7 +158,7 @@ func addControllersToManager(ctx context.Context, mgr manager.Manager) error { APIReader: mgr.GetAPIReader(), // K8SPG-992 Scheme: mgr.GetScheme(), Owner: postgrescluster.ControllerName, - Recorder: mgr.GetEventRecorderFor(postgrescluster.ControllerName), + Recorder: mgr.GetEventRecorderFor(postgrescluster.ControllerName), //nolint:staticcheck Tracer: otel.Tracer(postgrescluster.ControllerName), IsOpenShift: openShift, CertManagerCtrlFunc: certmanager.NewController, @@ -204,7 +204,7 @@ func addControllersToManager(ctx context.Context, mgr manager.Manager) error { pc := &pgcluster.PGClusterReconciler{ Client: mgr.GetClient(), Owner: pgcluster.PGClusterControllerName, - Recorder: mgr.GetEventRecorderFor(pgcluster.PGClusterControllerName), + Recorder: mgr.GetEventRecorderFor(pgcluster.PGClusterControllerName), //nolint:staticcheck Tracer: otel.Tracer(pgcluster.PGClusterControllerName), Platform: platform, KubeVersion: getServerVersion(ctx, mgr.GetConfig()), @@ -259,7 +259,7 @@ func addControllersToManager(ctx context.Context, mgr manager.Manager) error { pr := &pgrestore.PGRestoreReconciler{ Client: mgr.GetClient(), Owner: pgrestore.PGRestoreControllerName, - Recorder: mgr.GetEventRecorderFor(pgrestore.PGRestoreControllerName), + Recorder: mgr.GetEventRecorderFor(pgrestore.PGRestoreControllerName), //nolint:staticcheck Tracer: otel.Tracer(pgrestore.PGRestoreControllerName), } if err := pr.SetupWithManager(mgr); err != nil { @@ -285,7 +285,7 @@ func addControllersToManager(ctx context.Context, mgr manager.Manager) error { pgAdminReconciler := &standalone_pgadmin.PGAdminReconciler{ Client: mgr.GetClient(), Owner: "pgadmin-controller", - Recorder: mgr.GetEventRecorderFor(naming.ControllerPGAdmin), + Recorder: mgr.GetEventRecorderFor(naming.ControllerPGAdmin), //nolint:staticcheck IsOpenShift: openShift, } diff --git a/cmd/postgres-operator/main_test.go b/cmd/postgres-operator/main_test.go index 690b3db2a8..017582506e 100644 --- a/cmd/postgres-operator/main_test.go +++ b/cmd/postgres-operator/main_test.go @@ -12,7 +12,7 @@ import ( "gotest.tools/v3/assert" "gotest.tools/v3/assert/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" ) func TestInitManager(t *testing.T) { diff --git a/cmd/postgres-operator/open_telemetry.go b/cmd/postgres-operator/open_telemetry.go index f8c9b7fc73..cc52a7a63a 100644 --- a/cmd/postgres-operator/open_telemetry.go +++ b/cmd/postgres-operator/open_telemetry.go @@ -9,6 +9,7 @@ import ( "io" "net/http" "os" + "path/filepath" "github.com/pkg/errors" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" @@ -35,7 +36,7 @@ func initOpenTelemetry() (func(), error) { options := []stdouttrace.Option{} if filename != "" { - file, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) + file, err := os.OpenFile(filepath.Clean(filename), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) if err != nil { return nil, errors.Wrap(err, "unable to open exporter file") } diff --git a/go.mod b/go.mod index 3cbdadf96b..10a6314756 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/percona/percona-postgresql-operator/v2 +module github.com/percona/percona-postgresql-operator/v3 go 1.26.0 diff --git a/hack/create-todo-patch.sh b/hack/create-todo-patch.sh index 7b9bc4dbce..669b90353c 100755 --- a/hack/create-todo-patch.sh +++ b/hack/create-todo-patch.sh @@ -36,9 +36,11 @@ name_desc_with_todo=$( .spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.customTLSSecret.properties.name.description \ "${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml" ) +# shellcheck disable=SC2001 name_desc_without_todo=$(sed 's/ TODO.*//g' <<< "${name_desc_with_todo}") # Generate a JSON patch file to update the "name" description for all applicable paths in the CRD. +# shellcheck disable=SC2016 python3 -m yq -y --arg old "${name_desc_with_todo}" --arg new "${name_desc_without_todo}" ' [{ op: "add", path: "/work", value: $new }] + [paths(select(. == $old)) | { op: "copy", from: "/work", path: "/\(map(tostring) | join("/"))" }] + @@ -46,6 +48,7 @@ python3 -m yq -y --arg old "${name_desc_with_todo}" --arg new "${name_desc_witho ' \ "${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml" > "${clusters_dir}/todos.yaml" +# shellcheck disable=SC2016 python3 -m yq -y --arg old "${name_desc_with_todo}" --arg new "${name_desc_without_todo}" ' [{ op: "add", path: "/work", value: $new }] + [paths(select(. == $old)) | { op: "copy", from: "/work", path: "/\(map(tostring) | join("/"))" }] + diff --git a/internal/bridge/client.go b/internal/bridge/client.go index a0831a9736..fdad90f5d7 100644 --- a/internal/bridge/client.go +++ b/internal/bridge/client.go @@ -19,7 +19,7 @@ import ( "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/wait" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const defaultAPI = "https://api.crunchybridge.com" @@ -279,7 +279,7 @@ func (c *Client) doWithBackoff( request.Header = headers.Clone() //nolint:bodyclose // This response is returned to the caller. - response, err = c.Client.Do(request) + response, err = c.Do(request) } // An error indicates there was no response from the server, and the @@ -723,7 +723,7 @@ func (c *Client) UpdateCluster( ) (*ClusterApiResource, error) { result := &ClusterApiResource{} - clusterbyte, err := json.Marshal(clusterRequestPayload) + clusterbyte, err := json.Marshal(clusterRequestPayload) //nolint:errchkjson //in case the struct changes, we would need to check the error anyway if err != nil { return result, err } diff --git a/internal/bridge/client_test.go b/internal/bridge/client_test.go index 365192f09d..b1a46c9677 100644 --- a/internal/bridge/client_test.go +++ b/internal/bridge/client_test.go @@ -29,8 +29,8 @@ func TestClientBackoff(t *testing.T) { client := NewClient("", "") var total time.Duration - for i := 1; i <= 50 && client.Backoff.Steps > 0; i++ { - step := client.Backoff.Step() + for i := 1; i <= 50 && client.Backoff.Steps > 0; i++ { //nolint:staticcheck //test data + step := client.Backoff.Step() //nolint:staticcheck //test data total += step t.Logf("%02d:%20v%20v", i, step, total) @@ -66,7 +66,7 @@ func TestClientDoWithBackoff(t *testing.T) { // Client with one attempt, i.e. no backoff. client := NewClient(server.URL, "xyz") - client.Backoff.Steps = 1 + client.Backoff.Steps = 1 //nolint:staticcheck //test data assert.Equal(t, client.BaseURL.String(), server.URL) ctx := context.Background() @@ -111,8 +111,8 @@ func TestClientDoWithBackoff(t *testing.T) { // Client with brief backoff. client := NewClient(server.URL, "") - client.Backoff.Duration = time.Millisecond - client.Backoff.Steps = 5 + client.Duration = time.Millisecond + client.Steps = 5 assert.Equal(t, client.BaseURL.String(), server.URL) ctx := context.Background() @@ -168,8 +168,8 @@ func TestClientDoWithBackoff(t *testing.T) { // Client with brief backoff. client := NewClient(server.URL, "") - client.Backoff.Duration = time.Millisecond - client.Backoff.Steps = 5 + client.Duration = time.Millisecond + client.Steps = 5 assert.Equal(t, client.BaseURL.String(), server.URL) ctx := context.Background() @@ -188,8 +188,8 @@ func TestClientDoWithBackoff(t *testing.T) { // Client with lots of brief backoff. client := NewClient(server.URL, "") - client.Backoff.Duration = time.Millisecond - client.Backoff.Steps = 100 + client.Duration = time.Millisecond + client.Steps = 100 assert.Equal(t, client.BaseURL.String(), server.URL) ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) @@ -1227,7 +1227,7 @@ func TestGetClusterRole(t *testing.T) { } t.Run("WeSendCorrectData", func(t *testing.T) { - responsePayloadJson, err := json.Marshal(clusterRoleApiResource) + responsePayloadJson, err := json.Marshal(clusterRoleApiResource) //nolint:gosec // test data, not a real secret assert.NilError(t, err) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -1249,7 +1249,7 @@ func TestGetClusterRole(t *testing.T) { }) t.Run("OkResponse", func(t *testing.T) { - responsePayloadJson, err := json.Marshal(clusterRoleApiResource) + responsePayloadJson, err := json.Marshal(clusterRoleApiResource) //nolint:gosec // test data, not a real secret assert.NilError(t, err) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -1267,7 +1267,7 @@ func TestGetClusterRole(t *testing.T) { }) t.Run("ErrorResponse", func(t *testing.T) { - responsePayloadJson, err := json.Marshal(clusterRoleApiResource) + responsePayloadJson, err := json.Marshal(clusterRoleApiResource) //nolint:gosec // test data, not a real secret assert.NilError(t, err) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/bridge/crunchybridgecluster/apply.go b/internal/bridge/crunchybridgecluster/apply.go index d77d719d6a..49195d1291 100644 --- a/internal/bridge/crunchybridgecluster/apply.go +++ b/internal/bridge/crunchybridgecluster/apply.go @@ -8,6 +8,7 @@ import ( "context" "reflect" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -22,7 +23,7 @@ func (r *CrunchyBridgeClusterReconciler) patch( patch client.Patch, options ...client.PatchOption, ) error { options = append([]client.PatchOption{r.Owner}, options...) - return r.Client.Patch(ctx, object, patch, options...) + return r.Patch(ctx, object, patch, options...) } // apply sends an apply patch to object's endpoint in the Kubernetes API and @@ -36,7 +37,7 @@ func (r *CrunchyBridgeClusterReconciler) apply(ctx context.Context, object clien // Generate an apply-patch by comparing the object to its zero value. zero := reflect.New(reflect.TypeOf(object).Elem()).Interface() data, err := client.MergeFrom(zero.(client.Object)).Data(object) - apply := client.RawPatch(client.Apply.Type(), data) + apply := client.RawPatch(types.ApplyPatchType, data) // Send the apply-patch with force=true. if err == nil { diff --git a/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller.go b/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller.go index 9e567d4236..fe022aeea6 100644 --- a/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller.go +++ b/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller.go @@ -21,10 +21,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - pgoRuntime "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + pgoRuntime "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // CrunchyBridgeClusterReconciler reconciles a CrunchyBridgeCluster object @@ -79,7 +79,7 @@ func (r *CrunchyBridgeClusterReconciler) SetupWithManager( func (r *CrunchyBridgeClusterReconciler) setControllerReference( owner *v1beta1.CrunchyBridgeCluster, controlled client.Object, ) error { - return controllerutil.SetControllerReference(owner, controlled, r.Client.Scheme()) + return controllerutil.SetControllerReference(owner, controlled, r.Scheme()) } //+kubebuilder:rbac:groups="upstream.pgv2.percona.com",resources="crunchybridgeclusters",verbs={get,patch,update} @@ -669,7 +669,7 @@ func (r *CrunchyBridgeClusterReconciler) GetSecretKeys( }} err := errors.WithStack( - r.Client.Get(ctx, client.ObjectKeyFromObject(existing), existing)) + r.Get(ctx, client.ObjectKeyFromObject(existing), existing)) if err == nil { if existing.Data["key"] != nil && existing.Data["team"] != nil { @@ -692,7 +692,7 @@ func (r *CrunchyBridgeClusterReconciler) deleteControlled( version := object.GetResourceVersion() exactly := client.Preconditions{UID: &uid, ResourceVersion: &version} - return r.Client.Delete(ctx, object, exactly) + return r.Delete(ctx, object, exactly) } return nil diff --git a/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller_test.go b/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller_test.go index 23d352ffab..51844e53f9 100644 --- a/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller_test.go +++ b/internal/bridge/crunchybridgecluster/crunchybridgecluster_controller_test.go @@ -19,11 +19,11 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var testTeamId = "5678" diff --git a/internal/bridge/crunchybridgecluster/delete.go b/internal/bridge/crunchybridgecluster/delete.go index 27a3384ea2..778921ebd0 100644 --- a/internal/bridge/crunchybridgecluster/delete.go +++ b/internal/bridge/crunchybridgecluster/delete.go @@ -11,8 +11,8 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const finalizer = "crunchybridgecluster.postgres-operator.crunchydata.com/finalizer" @@ -27,7 +27,7 @@ func (r *CrunchyBridgeClusterReconciler) handleDelete( log := ctrl.LoggerFrom(ctx) // If the CrunchyBridgeCluster isn't being deleted, add the finalizer - if crunchybridgecluster.ObjectMeta.DeletionTimestamp.IsZero() { + if crunchybridgecluster.ObjectMeta.DeletionTimestamp.IsZero() { //nolint:staticcheck //test data if !controllerutil.ContainsFinalizer(crunchybridgecluster, finalizer) { controllerutil.AddFinalizer(crunchybridgecluster, finalizer) if err := r.Update(ctx, crunchybridgecluster); err != nil { diff --git a/internal/bridge/crunchybridgecluster/delete_test.go b/internal/bridge/crunchybridgecluster/delete_test.go index bbc0d6036a..c4ea4be54a 100644 --- a/internal/bridge/crunchybridgecluster/delete_test.go +++ b/internal/bridge/crunchybridgecluster/delete_test.go @@ -14,8 +14,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) func TestHandleDeleteCluster(t *testing.T) { @@ -65,7 +65,7 @@ func TestHandleDeleteCluster(t *testing.T) { // Get cluster from kubernetes and assert that the deletion timestamp was added assert.NilError(t, tClient.Get(ctx, client.ObjectKeyFromObject(cluster), cluster)) - assert.Check(t, !cluster.ObjectMeta.DeletionTimestamp.IsZero()) + assert.Check(t, !cluster.DeletionTimestamp.IsZero()) // Note: We must run handleDelete multiple times because we don't want to remove the // finalizer until we're sure that the cluster has been deleted from Bridge, so we @@ -107,7 +107,7 @@ func TestHandleDeleteCluster(t *testing.T) { // Get cluster from kubernetes and assert that the deletion timestamp was added assert.NilError(t, tClient.Get(ctx, client.ObjectKeyFromObject(cluster), cluster)) - assert.Check(t, !cluster.ObjectMeta.DeletionTimestamp.IsZero()) + assert.Check(t, !cluster.DeletionTimestamp.IsZero()) // Run handleDelete again to attempt to delete from Bridge, but provide bad api key cluster.Status.ID = "2345" diff --git a/internal/bridge/crunchybridgecluster/helpers_test.go b/internal/bridge/crunchybridgecluster/helpers_test.go index 9327d8a82e..55f4fbf75d 100644 --- a/internal/bridge/crunchybridgecluster/helpers_test.go +++ b/internal/bridge/crunchybridgecluster/helpers_test.go @@ -17,9 +17,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // Scale extends d according to PGO_TEST_TIMEOUT_SCALE. diff --git a/internal/bridge/crunchybridgecluster/mock_bridge_api.go b/internal/bridge/crunchybridgecluster/mock_bridge_api.go index 4dfe2ebc89..40ced78dd9 100644 --- a/internal/bridge/crunchybridgecluster/mock_bridge_api.go +++ b/internal/bridge/crunchybridgecluster/mock_bridge_api.go @@ -11,8 +11,8 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type TestBridgeClient struct { diff --git a/internal/bridge/crunchybridgecluster/postgres.go b/internal/bridge/crunchybridgecluster/postgres.go index e4cdb7f224..1af2f07d64 100644 --- a/internal/bridge/crunchybridgecluster/postgres.go +++ b/internal/bridge/crunchybridgecluster/postgres.go @@ -15,9 +15,9 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // generatePostgresRoleSecret returns a Secret containing a password and @@ -93,7 +93,7 @@ func (r *CrunchyBridgeClusterReconciler) reconcilePostgresRoleSecrets( // Make sure that this cluster's role secret names are not being used by any other // secrets in the namespace allSecretsInNamespace := &corev1.SecretList{} - err := errors.WithStack(r.Client.List(ctx, allSecretsInNamespace, client.InNamespace(cluster.Namespace))) + err := errors.WithStack(r.List(ctx, allSecretsInNamespace, client.InNamespace(cluster.Namespace))) if err != nil { return nil, nil, err } @@ -116,7 +116,7 @@ func (r *CrunchyBridgeClusterReconciler) reconcilePostgresRoleSecrets( selector, err := naming.AsSelector(naming.CrunchyBridgeClusterPostgresRoles(cluster.Name)) if err == nil { err = errors.WithStack( - r.Client.List(ctx, secrets, + r.List(ctx, secrets, client.InNamespace(cluster.Namespace), client.MatchingLabelsSelector{Selector: selector}, )) diff --git a/internal/bridge/crunchybridgecluster/postgres_test.go b/internal/bridge/crunchybridgecluster/postgres_test.go index 30bef9669a..a5c4ed273b 100644 --- a/internal/bridge/crunchybridgecluster/postgres_test.go +++ b/internal/bridge/crunchybridgecluster/postgres_test.go @@ -15,9 +15,9 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/bridge" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/bridge" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGeneratePostgresRoleSecret(t *testing.T) { @@ -36,7 +36,7 @@ func TestGeneratePostgresRoleSecret(t *testing.T) { Name: "application", SecretName: "application-role-secret", } - role := &bridge.ClusterRoleApiResource{ + role := &bridge.ClusterRoleApiResource{ //nolint:gosec //test data Name: "application", Password: "password", URI: "postgres://application:password@example.com:5432/postgres", @@ -149,7 +149,7 @@ func TestReconcilePostgresRoleSecrets(t *testing.T) { Name: "application", SecretName: "application-role-secret", } - postgresSpec := &v1beta1.CrunchyBridgeClusterRoleSpec{ + postgresSpec := &v1beta1.CrunchyBridgeClusterRoleSpec{ //nolint:gosec //test data Name: "postgres", SecretName: "postgres-role-secret", } diff --git a/internal/bridge/crunchybridgecluster/watches.go b/internal/bridge/crunchybridgecluster/watches.go index 03899138f3..1de380ad88 100644 --- a/internal/bridge/crunchybridgecluster/watches.go +++ b/internal/bridge/crunchybridgecluster/watches.go @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // watchForRelatedSecret handles create/update/delete events for secrets, diff --git a/internal/bridge/crunchybridgecluster/watches_test.go b/internal/bridge/crunchybridgecluster/watches_test.go index bc91930f75..6318c2d78a 100644 --- a/internal/bridge/crunchybridgecluster/watches_test.go +++ b/internal/bridge/crunchybridgecluster/watches_test.go @@ -12,7 +12,7 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) func TestFindCrunchyBridgeClustersForSecret(t *testing.T) { diff --git a/internal/bridge/installation.go b/internal/bridge/installation.go index bdfe494d4e..10ef19b0d0 100644 --- a/internal/bridge/installation.go +++ b/internal/bridge/installation.go @@ -14,6 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" corev1apply "k8s.io/client-go/applyconfigurations/core/v1" "sigs.k8s.io/controller-runtime/pkg/builder" @@ -25,9 +26,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" ) // self is a singleton Installation. See [InstallationReconciler]. @@ -192,7 +193,7 @@ func (r *InstallationReconciler) persist( ctx context.Context, config *corev1apply.SecretApplyConfiguration, ) error { data, err := json.Marshal(config) - apply := client.RawPatch(client.Apply.Type(), data) + apply := client.RawPatch(types.ApplyPatchType, data) // [client.Client] decides where to write by looking at the underlying type, // namespace, and name of its [client.Object] argument. That is also where diff --git a/internal/bridge/installation_test.go b/internal/bridge/installation_test.go index 88dddf855d..a2c42921b6 100644 --- a/internal/bridge/installation_test.go +++ b/internal/bridge/installation_test.go @@ -20,8 +20,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) func TestExtractSecretContract(t *testing.T) { @@ -99,7 +99,7 @@ func TestInstallationReconcile(t *testing.T) { reconciler.NewClient = func() *Client { c := NewClient(server.URL, "") - c.Backoff.Steps = 1 + c.Steps = 1 assert.Equal(t, c.BaseURL.String(), server.URL) return c } @@ -155,7 +155,7 @@ func TestInstallationReconcile(t *testing.T) { reconciler.NewClient = func() *Client { c := NewClient(server.URL, "") - c.Backoff.Steps = 1 + c.Steps = 1 assert.Equal(t, c.BaseURL.String(), server.URL) return c } @@ -289,7 +289,7 @@ func TestInstallationReconcile(t *testing.T) { reconciler.NewClient = func() *Client { c := NewClient(server.URL, "") - c.Backoff.Steps = 1 + c.Steps = 1 assert.Equal(t, c.BaseURL.String(), server.URL) return c } @@ -343,7 +343,7 @@ func TestInstallationReconcile(t *testing.T) { reconciler.NewClient = func() *Client { c := NewClient(server.URL, "") - c.Backoff.Steps = 1 + c.Steps = 1 assert.Equal(t, c.BaseURL.String(), server.URL) return c } @@ -426,7 +426,7 @@ func TestInstallationReconcile(t *testing.T) { reconciler.NewClient = func() *Client { c := NewClient(server.URL, "") - c.Backoff.Steps = 1 + c.Steps = 1 assert.Equal(t, c.BaseURL.String(), server.URL) return c } diff --git a/internal/config/config.go b/internal/config/config.go index 9adcaf1080..f21b8f5d49 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -10,7 +10,7 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // defaultFromEnv reads the environment variable key when value is empty. diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 1487562a67..03c2694f2d 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -12,7 +12,7 @@ import ( "gotest.tools/v3/assert" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPGAdminContainerImage(t *testing.T) { diff --git a/internal/controller/pgupgrade/apply.go b/internal/controller/pgupgrade/apply.go index 71cf65cd4f..88880e15dd 100644 --- a/internal/controller/pgupgrade/apply.go +++ b/internal/controller/pgupgrade/apply.go @@ -8,6 +8,7 @@ import ( "context" "reflect" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -32,7 +33,7 @@ func (r *PGUpgradeReconciler) apply(ctx context.Context, object client.Object) e // Generate an apply-patch by comparing the object to its zero value. zero := reflect.New(reflect.TypeOf(object).Elem()).Interface() data, err := client.MergeFrom(zero.(client.Object)).Data(object) - apply := client.RawPatch(client.Apply.Type(), data) + apply := client.RawPatch(types.ApplyPatchType, data) // Send the apply-patch with force=true. if err == nil { diff --git a/internal/controller/pgupgrade/jobs.go b/internal/controller/pgupgrade/jobs.go index edf35d02aa..05a3faf167 100644 --- a/internal/controller/pgupgrade/jobs.go +++ b/internal/controller/pgupgrade/jobs.go @@ -17,10 +17,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // Upgrade job diff --git a/internal/controller/pgupgrade/jobs_test.go b/internal/controller/pgupgrade/jobs_test.go index 3db01b4e32..11e0f491f1 100644 --- a/internal/controller/pgupgrade/jobs_test.go +++ b/internal/controller/pgupgrade/jobs_test.go @@ -17,9 +17,9 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestLargestWholeCPU(t *testing.T) { diff --git a/internal/controller/pgupgrade/labels.go b/internal/controller/pgupgrade/labels.go index ea36fcb229..27f1025703 100644 --- a/internal/controller/pgupgrade/labels.go +++ b/internal/controller/pgupgrade/labels.go @@ -5,8 +5,8 @@ package pgupgrade import ( - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/controller/pgupgrade/pgupgrade_controller.go b/internal/controller/pgupgrade/pgupgrade_controller.go index 018220b163..ed149bd43b 100644 --- a/internal/controller/pgupgrade/pgupgrade_controller.go +++ b/internal/controller/pgupgrade/pgupgrade_controller.go @@ -21,9 +21,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/registration" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/registration" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/controller/pgupgrade/registration.go b/internal/controller/pgupgrade/registration.go index 9f979e3205..35b43c9662 100644 --- a/internal/controller/pgupgrade/registration.go +++ b/internal/controller/pgupgrade/registration.go @@ -7,8 +7,8 @@ package pgupgrade import ( "k8s.io/apimachinery/pkg/api/meta" - "github.com/percona/percona-postgresql-operator/v2/internal/registration" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/registration" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func (r *PGUpgradeReconciler) UpgradeAuthorized(upgrade *v1beta1.PGUpgrade) bool { diff --git a/internal/controller/pgupgrade/registration_test.go b/internal/controller/pgupgrade/registration_test.go index 050f972f8a..bd72d6eeac 100644 --- a/internal/controller/pgupgrade/registration_test.go +++ b/internal/controller/pgupgrade/registration_test.go @@ -13,11 +13,11 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/registration" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/registration" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestUpgradeAuthorized(t *testing.T) { diff --git a/internal/controller/pgupgrade/utils.go b/internal/controller/pgupgrade/utils.go index 0e0434e238..483b5dce84 100644 --- a/internal/controller/pgupgrade/utils.go +++ b/internal/controller/pgupgrade/utils.go @@ -12,7 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // The owner reference created by controllerutil.SetControllerReference blocks diff --git a/internal/controller/pgupgrade/world.go b/internal/controller/pgupgrade/world.go index 98c6832b7f..89951408d7 100644 --- a/internal/controller/pgupgrade/world.go +++ b/internal/controller/pgupgrade/world.go @@ -15,7 +15,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // The client used by the controller sets up a cache and an informer for any GVK @@ -97,7 +97,7 @@ func (w *World) populateCluster(cluster *v1beta1.PostgresCluster, err error) err return err } -func (w *World) populatePatroniEndpoints(endpoints []corev1.Endpoints) { +func (w *World) populatePatroniEndpoints(endpoints []corev1.Endpoints) { //nolint:staticcheck // SA1019 for index, endpoint := range endpoints { if endpoint.Labels[LabelPatroni] != "" { w.PatroniEndpoints = append(w.PatroniEndpoints, &endpoints[index]) @@ -164,7 +164,7 @@ type World struct { ClusterShutdown bool ReplicasExpected int - PatroniEndpoints []*corev1.Endpoints + PatroniEndpoints []*corev1.Endpoints //nolint:staticcheck // SA1019 Jobs map[string]*batchv1.Job } diff --git a/internal/controller/pgupgrade/world_test.go b/internal/controller/pgupgrade/world_test.go index ef42b91837..82ecc94371 100644 --- a/internal/controller/pgupgrade/world_test.go +++ b/internal/controller/pgupgrade/world_test.go @@ -14,8 +14,8 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPopulateCluster(t *testing.T) { @@ -57,7 +57,7 @@ func TestPopulateCluster(t *testing.T) { } func TestPopulatePatroniEndpoint(t *testing.T) { - endpoints := []corev1.Endpoints{ + endpoints := []corev1.Endpoints{ //nolint:staticcheck // SA1019 { ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ @@ -85,7 +85,7 @@ func TestPopulatePatroniEndpoint(t *testing.T) { world.populatePatroniEndpoints(endpoints) // The first two have the correct labels. - assert.DeepEqual(t, world.PatroniEndpoints, []*corev1.Endpoints{ + assert.DeepEqual(t, world.PatroniEndpoints, []*corev1.Endpoints{ //nolint:staticcheck // SA1019 &endpoints[0], &endpoints[1], }) diff --git a/internal/controller/postgrescluster/apply.go b/internal/controller/postgrescluster/apply.go index a923856e66..01697733ae 100644 --- a/internal/controller/postgrescluster/apply.go +++ b/internal/controller/postgrescluster/apply.go @@ -10,9 +10,10 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/kubeapi" + "github.com/percona/percona-postgresql-operator/v3/internal/kubeapi" ) // apply sends an apply patch to object's endpoint in the Kubernetes API and @@ -24,7 +25,7 @@ func (r *Reconciler) apply(ctx context.Context, object client.Object) error { // Generate an apply-patch by comparing the object to its zero value. zero := reflect.New(reflect.TypeOf(object).Elem()).Interface() data, err := client.MergeFrom(zero.(client.Object)).Data(object) - apply := client.RawPatch(client.Apply.Type(), data) + apply := client.RawPatch(types.ApplyPatchType, data) // Keep a copy of the object before any API calls. intent := object.DeepCopyObject() diff --git a/internal/controller/postgrescluster/apply_test.go b/internal/controller/postgrescluster/apply_test.go index d41148ae43..edfd4498f8 100644 --- a/internal/controller/postgrescluster/apply_test.go +++ b/internal/controller/postgrescluster/apply_test.go @@ -24,7 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) func TestServerSideApply(t *testing.T) { @@ -55,7 +55,7 @@ func TestServerSideApply(t *testing.T) { // Create the object. before := constructor() - assert.NilError(t, cc.Patch(ctx, before, client.Apply, reconciler.Owner)) + assert.NilError(t, cc.Patch(ctx, before, client.Apply, reconciler.Owner)) //nolint:staticcheck assert.Assert(t, before.GetResourceVersion() != "") // Allow the Kubernetes API clock to advance. @@ -63,7 +63,7 @@ func TestServerSideApply(t *testing.T) { // client.Apply changes the ResourceVersion inadvertently. after := constructor() - assert.NilError(t, cc.Patch(ctx, after, client.Apply, reconciler.Owner)) + assert.NilError(t, cc.Patch(ctx, after, client.Apply, reconciler.Owner)) //nolint:staticcheck assert.Assert(t, after.GetResourceVersion() != "") switch { @@ -115,7 +115,7 @@ func TestServerSideApply(t *testing.T) { assert.NilError(t, controllerutil.SetControllerReference(controller2, applied, cc.Scheme())) - err1 := cc.Patch(ctx, applied, client.Apply, client.ForceOwnership, reconciler.Owner) + err1 := cc.Patch(ctx, applied, client.Apply, client.ForceOwnership, reconciler.Owner) //nolint:staticcheck // Patch not accepted; the ownerReferences field is invalid. assert.Assert(t, apierrors.IsInvalid(err1), "got %#v", err1) @@ -167,13 +167,13 @@ func TestServerSideApply(t *testing.T) { switch { case serverVersion.LessThan(version.MustParseGeneric("1.22")): assert.ErrorContains(t, - cc.Patch(ctx, upstream, client.Apply, client.ForceOwnership, reconciler.Owner), + cc.Patch(ctx, upstream, client.Apply, client.ForceOwnership, reconciler.Owner), //nolint:staticcheck "field not declared in schema", "expected https://issue.k8s.io/109210") default: assert.NilError(t, - cc.Patch(ctx, upstream, client.Apply, client.ForceOwnership, reconciler.Owner)) + cc.Patch(ctx, upstream, client.Apply, client.ForceOwnership, reconciler.Owner)) //nolint:staticcheck } // Our apply method generates the correct apply-patch. @@ -201,7 +201,7 @@ func TestServerSideApply(t *testing.T) { // Create the Service. before := intent.DeepCopy() assert.NilError(t, - cc.Patch(ctx, before, client.Apply, client.ForceOwnership, reconciler.Owner)) + cc.Patch(ctx, before, client.Apply, client.ForceOwnership, reconciler.Owner)) //nolint:staticcheck // Something external mucks it up. assert.NilError(t, @@ -212,7 +212,7 @@ func TestServerSideApply(t *testing.T) { // client.Apply cannot correct it in old versions of Kubernetes. after := intent.DeepCopy() assert.NilError(t, - cc.Patch(ctx, after, client.Apply, client.ForceOwnership, reconciler.Owner)) + cc.Patch(ctx, after, client.Apply, client.ForceOwnership, reconciler.Owner)) //nolint:staticcheck switch { case serverVersion.LessThan(version.MustParseGeneric("1.22")): @@ -242,8 +242,8 @@ func TestServerSideApply(t *testing.T) { assert.Equal(t, managed.Operation, metav1.ManagedFieldsOperationApply) assert.Assert(t, managed.FieldsV1 != nil) - assert.Assert(t, strings.Contains(string(managed.FieldsV1.Raw), `"f:selector":{`), - "expected f:selector in %s", managed.FieldsV1.Raw) + assert.Assert(t, strings.Contains(managed.FieldsV1.GetRawString(), `"f:selector":{`), + "expected f:selector in %s", managed.FieldsV1.GetRawString()) }) for _, tt := range []struct { @@ -262,7 +262,7 @@ func TestServerSideApply(t *testing.T) { // Create the Service. before := intent.DeepCopy() assert.NilError(t, - cc.Patch(ctx, before, client.Apply, client.ForceOwnership, reconciler.Owner)) + cc.Patch(ctx, before, client.Apply, client.ForceOwnership, reconciler.Owner)) //nolint:staticcheck // Something external mucks it up. assert.NilError(t, @@ -273,7 +273,7 @@ func TestServerSideApply(t *testing.T) { // client.Apply cannot correct it. after := intent.DeepCopy() assert.NilError(t, - cc.Patch(ctx, after, client.Apply, client.ForceOwnership, reconciler.Owner)) + cc.Patch(ctx, after, client.Apply, client.ForceOwnership, reconciler.Owner)) //nolint:staticcheck assert.Assert(t, len(after.Spec.Selector) != len(intent.Spec.Selector), "got %v", after.Spec.Selector) @@ -300,8 +300,8 @@ func TestServerSideApply(t *testing.T) { // The selector field is forgotten, however. assert.Assert(t, managed.FieldsV1 != nil) - assert.Assert(t, !strings.Contains(string(managed.FieldsV1.Raw), `"f:selector":{`), - "expected f:selector to be missing from %s", managed.FieldsV1.Raw) + assert.Assert(t, !strings.Contains(managed.FieldsV1.GetRawString(), `"f:selector":{`), + "expected f:selector to be missing from %s", managed.FieldsV1.GetRawString()) }) } }) diff --git a/internal/controller/postgrescluster/cluster.go b/internal/controller/postgrescluster/cluster.go index 6dc24b3ef4..7a538d82a1 100644 --- a/internal/controller/postgrescluster/cluster.go +++ b/internal/controller/postgrescluster/cluster.go @@ -15,13 +15,13 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="",resources="configmaps",verbs={create,patch} @@ -94,7 +94,7 @@ func (r *Reconciler) reconcileClusterPodService( // resolve to the PostgreSQL primary instance. func (r *Reconciler) generateClusterPrimaryService( cluster *v1beta1.PostgresCluster, leader *corev1.Service, -) (*corev1.Service, *corev1.Endpoints, error) { +) (*corev1.Service, *corev1.Endpoints, error) { //nolint:staticcheck // SA1019 // We want to name and label our primary Service consistently. When Patroni is // using Endpoints for its DCS, however, they and any Service that uses them // must use the same name as the Patroni "scope" which has its own constraints. @@ -120,7 +120,7 @@ func (r *Reconciler) generateClusterPrimaryService( // Endpoints for a Service have the same name as the Service. Copy labels, // annotations, and ownership, too. - endpoints := &corev1.Endpoints{} + endpoints := &corev1.Endpoints{} //nolint:staticcheck // SA1019 service.ObjectMeta.DeepCopyInto(&endpoints.ObjectMeta) endpoints.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("Endpoints")) @@ -143,7 +143,7 @@ func (r *Reconciler) generateClusterPrimaryService( }} // Resolve to the ClusterIP for which Patroni has configured the Endpoints. - endpoints.Subsets = []corev1.EndpointSubset{{ + endpoints.Subsets = []corev1.EndpointSubset{{ //nolint:staticcheck // SA1019 Addresses: []corev1.EndpointAddress{{IP: leader.Spec.ClusterIP}}, }} diff --git a/internal/controller/postgrescluster/cluster_test.go b/internal/controller/postgrescluster/cluster_test.go index 69b4e00c9d..688c8c0334 100644 --- a/internal/controller/postgrescluster/cluster_test.go +++ b/internal/controller/postgrescluster/cluster_test.go @@ -21,11 +21,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var gvks = []runtime.GVK{{ @@ -102,7 +102,7 @@ func TestCustomLabels(t *testing.T) { NamespacedName: client.ObjectKeyFromObject(cluster), }) assert.NilError(t, err) - assert.Assert(t, result.Requeue == false) + assert.Assert(t, result.RequeueAfter == 0) } getUnstructuredLabels := func(t *testing.T, cluster *v1beta1.PostgresCluster, u *unstructured.Unstructured) map[string]map[string]string { @@ -136,8 +136,8 @@ func TestCustomLabels(t *testing.T) { t.Run("Cluster", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "global-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "global-cluster" + cluster.Namespace = ns.Name cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{{ Name: "daisy-instance1", InitContainer: &v1beta1.InitContainerSpec{ @@ -190,8 +190,8 @@ func TestCustomLabels(t *testing.T) { t.Run("Instance", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "instance-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "instance-cluster" + cluster.Namespace = ns.Name cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{{ Name: "max-instance", InitContainer: &v1beta1.InitContainerSpec{ @@ -246,8 +246,8 @@ func TestCustomLabels(t *testing.T) { t.Run("PGBackRest", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "pgbackrest-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "pgbackrest-cluster" + cluster.Namespace = ns.Name cluster.Spec.Backups.PGBackRest.Metadata = &v1beta1.Metadata{ Labels: map[string]string{"my.pgbackrest.label": "lucy"}, } @@ -290,8 +290,8 @@ func TestCustomLabels(t *testing.T) { t.Run("PGBouncer", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "pgbouncer-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "pgbouncer-cluster" + cluster.Namespace = ns.Name cluster.Spec.Proxy.PGBouncer.Metadata = &v1beta1.Metadata{ Labels: map[string]string{"my.pgbouncer.label": "lucy"}, } @@ -352,7 +352,7 @@ func TestCustomAnnotations(t *testing.T) { NamespacedName: client.ObjectKeyFromObject(cluster), }) assert.NilError(t, err) - assert.Assert(t, result.Requeue == false) + assert.Assert(t, result.RequeueAfter == 0) } getUnstructuredAnnotations := func(t *testing.T, cluster *v1beta1.PostgresCluster, u *unstructured.Unstructured) map[string]map[string]string { @@ -386,8 +386,8 @@ func TestCustomAnnotations(t *testing.T) { t.Run("Cluster", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "global-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "global-cluster" + cluster.Namespace = ns.Name cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{{ Name: "daisy-instance1", InitContainer: &v1beta1.InitContainerSpec{ @@ -441,8 +441,8 @@ func TestCustomAnnotations(t *testing.T) { t.Run("Instance", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "instance-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "instance-cluster" + cluster.Namespace = ns.Name cluster.Spec.InstanceSets = []v1beta1.PostgresInstanceSetSpec{{ Name: "max-instance", InitContainer: &v1beta1.InitContainerSpec{ @@ -497,8 +497,8 @@ func TestCustomAnnotations(t *testing.T) { t.Run("PGBackRest", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "pgbackrest-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "pgbackrest-cluster" + cluster.Namespace = ns.Name cluster.Spec.Backups.PGBackRest.Metadata = &v1beta1.Metadata{ Annotations: map[string]string{"my.pgbackrest.annotation": "lucy"}, } @@ -541,8 +541,8 @@ func TestCustomAnnotations(t *testing.T) { t.Run("PGBouncer", func(t *testing.T) { cluster := testCluster() - cluster.ObjectMeta.Name = "pgbouncer-cluster" - cluster.ObjectMeta.Namespace = ns.Name + cluster.Name = "pgbouncer-cluster" + cluster.Namespace = ns.Name cluster.Spec.Proxy.PGBouncer.Metadata = &v1beta1.Metadata{ Annotations: map[string]string{"my.pgbouncer.annotation": "lucy"}, } @@ -597,7 +597,7 @@ func TestGenerateClusterPrimaryService(t *testing.T) { _, _, err := reconciler.generateClusterPrimaryService(cluster, nil) assert.ErrorContains(t, err, "not implemented") - alwaysExpect := func(t testing.TB, service *corev1.Service, endpoints *corev1.Endpoints) { + alwaysExpect := func(t testing.TB, service *corev1.Service, endpoints *corev1.Endpoints) { //nolint:staticcheck // SA1019 assert.Assert(t, cmp.MarshalMatches(service.TypeMeta, ` apiVersion: v1 kind: Service @@ -812,12 +812,12 @@ type: ClusterIP assert.NilError(t, err) // Annotations present in the metadata. - assert.Assert(t, cmp.MarshalMatches(service.ObjectMeta.Annotations, ` + assert.Assert(t, cmp.MarshalMatches(service.Annotations, ` some: note `)) // Labels present in the metadata. - assert.Assert(t, cmp.MarshalMatches(service.ObjectMeta.Labels, ` + assert.Assert(t, cmp.MarshalMatches(service.Labels, ` app.kubernetes.io/component: pg app.kubernetes.io/instance: pg2 app.kubernetes.io/managed-by: percona-postgresql-operator diff --git a/internal/controller/postgrescluster/controller.go b/internal/controller/postgrescluster/controller.go index 3a56378162..de6c300abc 100644 --- a/internal/controller/postgrescluster/controller.go +++ b/internal/controller/postgrescluster/controller.go @@ -38,29 +38,29 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - pgbruntime "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/logicalreplica" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgaudit" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/pgcron" - "github.com/percona/percona-postgresql-operator/v2/internal/pgmonitor" - "github.com/percona/percona-postgresql-operator/v2/internal/pgstatmonitor" - "github.com/percona/percona-postgresql-operator/v2/internal/pgstatstatements" - "github.com/percona/percona-postgresql-operator/v2/internal/pgtde" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/pmm" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/registration" - "github.com/percona/percona-postgresql-operator/v2/internal/setuser" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + pgbruntime "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/logicalreplica" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgaudit" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/pgcron" + "github.com/percona/percona-postgresql-operator/v3/internal/pgmonitor" + "github.com/percona/percona-postgresql-operator/v3/internal/pgstatmonitor" + "github.com/percona/percona-postgresql-operator/v3/internal/pgstatstatements" + "github.com/percona/percona-postgresql-operator/v3/internal/pgtde" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/pmm" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/registration" + "github.com/percona/percona-postgresql-operator/v3/internal/setuser" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -485,9 +485,8 @@ func (r *Reconciler) Reconcile( if err == nil { var next reconcile.Result if next, err = r.reconcilePGBackRest(ctx, cluster, - instances, rootCA, backupsSpecFound); err == nil && !next.IsZero() { - result.Requeue = result.Requeue || next.Requeue - if next.RequeueAfter > 0 { + instances, rootCA, backupsSpecFound); err == nil && next.RequeueAfter > 0 { + if result.RequeueAfter == 0 || next.RequeueAfter < result.RequeueAfter { result.RequeueAfter = next.RequeueAfter } } @@ -649,7 +648,7 @@ func (r *Reconciler) SetupWithManager(mgr manager.Manager) error { bldr := builder.ControllerManagedBy(mgr). For(&v1beta1.PostgresCluster{}). Owns(&corev1.ConfigMap{}, configMapPredicate). // K8SPG-712 - Owns(&corev1.Endpoints{}). + Owns(&corev1.Endpoints{}). //nolint:staticcheck // SA1019: matches production code Owns(&corev1.PersistentVolumeClaim{}). Owns(&corev1.Secret{}). Owns(&corev1.Service{}). diff --git a/internal/controller/postgrescluster/controller_ref_manager.go b/internal/controller/postgrescluster/controller_ref_manager.go index e2a6a80e0b..bc81204258 100644 --- a/internal/controller/postgrescluster/controller_ref_manager.go +++ b/internal/controller/postgrescluster/controller_ref_manager.go @@ -17,10 +17,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/kubeapi" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/kubeapi" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // adoptObject adopts the provided Object by adding controller owner refs for the provided diff --git a/internal/controller/postgrescluster/controller_ref_manager_test.go b/internal/controller/postgrescluster/controller_ref_manager_test.go index 4781ff6bb5..0f907de5ed 100644 --- a/internal/controller/postgrescluster/controller_ref_manager_test.go +++ b/internal/controller/postgrescluster/controller_ref_manager_test.go @@ -13,8 +13,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) func TestManageControllerRefs(t *testing.T) { diff --git a/internal/controller/postgrescluster/controller_test.go b/internal/controller/postgrescluster/controller_test.go index 395ef4da6a..8c48c66362 100644 --- a/internal/controller/postgrescluster/controller_test.go +++ b/internal/controller/postgrescluster/controller_test.go @@ -29,11 +29,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/registration" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/registration" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestDeleteControlled(t *testing.T) { diff --git a/internal/controller/postgrescluster/delete.go b/internal/controller/postgrescluster/delete.go index ff7deb3a40..7eee51665b 100644 --- a/internal/controller/postgrescluster/delete.go +++ b/internal/controller/postgrescluster/delete.go @@ -12,8 +12,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="upstream.pgv2.percona.com",resources="postgresclusters",verbs={patch} diff --git a/internal/controller/postgrescluster/helpers_test.go b/internal/controller/postgrescluster/helpers_test.go index af882bcc57..101f9aea66 100644 --- a/internal/controller/postgrescluster/helpers_test.go +++ b/internal/controller/postgrescluster/helpers_test.go @@ -20,11 +20,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var ( diff --git a/internal/controller/postgrescluster/instance.go b/internal/controller/postgrescluster/instance.go index 7aec530132..fd979f79e9 100644 --- a/internal/controller/postgrescluster/instance.go +++ b/internal/controller/postgrescluster/instance.go @@ -29,21 +29,21 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/pgtde" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/pgtde" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // Instance represents a single PostgreSQL instance of a PostgresCluster. @@ -559,12 +559,12 @@ func (r *Reconciler) deleteInstances( // There are multiple instances; stop the replicas. When none are found, // requeue to try again. - result.Requeue = true + result.RequeueAfter = 1 * time.Second for i := range pods.Items { role := pods.Items[i].Labels[naming.LabelRole] if err == nil && role == naming.RolePatroniReplica { err = stop(&pods.Items[i]) - result.Requeue = false + result.RequeueAfter = 0 } // An instance without a role label is not participating in the Patroni @@ -572,7 +572,7 @@ func (r *Reconciler) deleteInstances( // stop these as well. if err == nil && len(role) == 0 { err = stop(&pods.Items[i]) - result.Requeue = false + result.RequeueAfter = 0 } } @@ -1304,6 +1304,10 @@ func (r *Reconciler) reconcileInstance( err = patroni.InstancePod( ctx, cluster, clusterConfigMap, clusterPodService, patroniLeaderService, spec, instanceCertificates, instanceConfigMap, &instance.Spec.Template, initImage) // K8SPG-708 + if err != nil { + return errors.Wrap(err, "failed to populate pod") + } + } // Add pgMonitor resources to the instance Pod spec diff --git a/internal/controller/postgrescluster/instance_rollout_test.go b/internal/controller/postgrescluster/instance_rollout_test.go index 04d765baad..7156b1fbc5 100644 --- a/internal/controller/postgrescluster/instance_rollout_test.go +++ b/internal/controller/postgrescluster/instance_rollout_test.go @@ -23,9 +23,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcilerRolloutInstance(t *testing.T) { diff --git a/internal/controller/postgrescluster/instance_test.go b/internal/controller/postgrescluster/instance_test.go index 38f4886996..cea4bcf5fd 100644 --- a/internal/controller/postgrescluster/instance_test.go +++ b/internal/controller/postgrescluster/instance_test.go @@ -34,14 +34,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestInstanceIsRunning(t *testing.T) { @@ -1447,7 +1447,7 @@ func TestDeleteInstance(t *testing.T) { NamespacedName: client.ObjectKeyFromObject(cluster), }) assert.NilError(t, err) - assert.Assert(t, result.Requeue == false) + assert.Assert(t, result.RequeueAfter == 0) stsList := &appsv1.StatefulSetList{} assert.NilError(t, reconciler.Client.List(ctx, stsList, diff --git a/internal/controller/postgrescluster/patroni.go b/internal/controller/postgrescluster/patroni.go index d239845f28..c535b94ce4 100644 --- a/internal/controller/postgrescluster/patroni.go +++ b/internal/controller/postgrescluster/patroni.go @@ -15,14 +15,14 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="",resources="endpoints",verbs={deletecollection} @@ -38,7 +38,7 @@ func (r *Reconciler) deletePatroniArtifacts( if err == nil { err = errors.WithStack( r.Client.DeleteAllOf( - ctx, &corev1.Endpoints{}, + ctx, &corev1.Endpoints{}, //nolint:staticcheck // SA1019 client.InNamespace(cluster.Namespace), client.MatchingLabelsSelector{Selector: selector}, ), @@ -343,7 +343,7 @@ func (r *Reconciler) reconcilePatroniStatus( } } - dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(cluster)} + dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(cluster)} //nolint:staticcheck // SA1019 err := errors.WithStack(client.IgnoreNotFound( r.Client.Get(ctx, client.ObjectKeyFromObject(dcs), dcs), )) diff --git a/internal/controller/postgrescluster/patroni_test.go b/internal/controller/postgrescluster/patroni_test.go index 6ceb8069dc..f824b81984 100644 --- a/internal/controller/postgrescluster/patroni_test.go +++ b/internal/controller/postgrescluster/patroni_test.go @@ -24,10 +24,10 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGeneratePatroniLeaderLeaseService(t *testing.T) { @@ -106,12 +106,12 @@ ownerReferences: assert.NilError(t, err) // Annotations present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, service.Annotations, map[string]string{ "a": "v1", }) // Labels present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, service.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "postgres-operator.crunchydata.com/cluster": "pg2", "postgres-operator.crunchydata.com/patroni": "pg2-ha", @@ -134,13 +134,13 @@ ownerReferences: assert.NilError(t, err) // Annotations present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, service.Annotations, map[string]string{ "a": "v1", "c": "v3", }) // Labels present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, service.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "d": "v4", "postgres-operator.crunchydata.com/cluster": "pg2", @@ -477,12 +477,12 @@ func TestReconcilePatroniStatus(t *testing.T) { }, } - endpoints := &corev1.Endpoints{ + endpoints := &corev1.Endpoints{ //nolint:staticcheck // SA1019: matches production code ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster), } if writeAnnotation { - endpoints.ObjectMeta.Annotations = make(map[string]string) - endpoints.ObjectMeta.Annotations["initialize"] = systemIdentifier + endpoints.Annotations = make(map[string]string) + endpoints.Annotations["initialize"] = systemIdentifier } assert.NilError(t, tClient.Create(ctx, endpoints, &client.CreateOptions{})) diff --git a/internal/controller/postgrescluster/pgadmin.go b/internal/controller/postgrescluster/pgadmin.go index 9ab6ba9029..e86311d820 100644 --- a/internal/controller/postgrescluster/pgadmin.go +++ b/internal/controller/postgrescluster/pgadmin.go @@ -18,14 +18,14 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgadmin" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgadmin" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // reconcilePGAdmin writes the objects necessary to run a pgAdmin Pod. diff --git a/internal/controller/postgrescluster/pgadmin_test.go b/internal/controller/postgrescluster/pgadmin_test.go index a2cdd07001..5a313e2670 100644 --- a/internal/controller/postgrescluster/pgadmin_test.go +++ b/internal/controller/postgrescluster/pgadmin_test.go @@ -21,10 +21,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGeneratePGAdminConfigMap(t *testing.T) { @@ -110,12 +110,12 @@ ownerReferences: assert.Assert(t, specified) // Annotations present in the metadata. - assert.DeepEqual(t, configmap.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, configmap.Annotations, map[string]string{ "a": "v5", "b": "v2", "e": "v6", }) // Labels present in the metadata. - assert.DeepEqual(t, configmap.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, configmap.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "c": "v7", "d": "v4", "f": "v8", "postgres-operator.crunchydata.com/cluster": "pg1", "postgres-operator.crunchydata.com/role": "pgadmin", @@ -206,12 +206,12 @@ ownerReferences: assert.Assert(t, specified) // Annotations present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, service.Annotations, map[string]string{ "a": "v1", }) // Labels present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, service.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "postgres-operator.crunchydata.com/cluster": "my-cluster", "postgres-operator.crunchydata.com/role": "pgadmin", @@ -237,13 +237,13 @@ ownerReferences: assert.Assert(t, specified) // Annotations present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, service.Annotations, map[string]string{ "a": "v1", "c": "v3", }) // Labels present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, service.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "d": "v4", "postgres-operator.crunchydata.com/cluster": "my-cluster", diff --git a/internal/controller/postgrescluster/pgbackrest.go b/internal/controller/postgrescluster/pgbackrest.go index 2f3d64a640..f19ee36999 100644 --- a/internal/controller/postgrescluster/pgbackrest.go +++ b/internal/controller/postgrescluster/pgbackrest.go @@ -31,21 +31,21 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -846,7 +846,7 @@ func (r *Reconciler) generateRepoHostIntent(ctx context.Context, postgresCluster func (r *Reconciler) generateRepoVolumeIntent(postgresCluster *v1beta1.PostgresCluster, spec corev1.PersistentVolumeClaimSpec, repoName string, repoResources *RepoResources, -) (*corev1.PersistentVolumeClaim, error) { +) (*corev1.PersistentVolumeClaim, error) { //nolint:unparam annotations := naming.Merge( postgresCluster.Spec.Metadata.GetAnnotationsOrNil(), postgresCluster.Spec.Backups.PGBackRest.Metadata.GetAnnotationsOrNil()) @@ -1067,10 +1067,10 @@ func generateBackupJobSpecIntent(ctx context.Context, postgresCluster *v1beta1.P // restore Jobs and then updating pgBackRest restore status accordingly. func (r *Reconciler) observeRestoreEnv(ctx context.Context, cluster *v1beta1.PostgresCluster, -) ([]corev1.Endpoints, *batchv1.Job, error) { +) ([]corev1.Endpoints, *batchv1.Job, error) { //nolint:staticcheck // SA1019 // lookup the various patroni endpoints - leaderEP, dcsEP, failoverEP := corev1.Endpoints{}, corev1.Endpoints{}, corev1.Endpoints{} - currentEndpoints := []corev1.Endpoints{} + leaderEP, dcsEP, failoverEP := corev1.Endpoints{}, corev1.Endpoints{}, corev1.Endpoints{} //nolint:staticcheck // SA1019 + currentEndpoints := []corev1.Endpoints{} //nolint:staticcheck // SA1019 if err := r.Client.Get(ctx, naming.AsObjectKey(naming.PatroniLeaderEndpoints(cluster)), &leaderEP); err != nil { if !apierrors.IsNotFound(err) { @@ -1193,7 +1193,7 @@ func (r *Reconciler) observeRestoreEnv(ctx context.Context, // cluster to re-bootstrap using a restored data directory. func (r *Reconciler) prepareForRestore(ctx context.Context, cluster *v1beta1.PostgresCluster, observed *observedInstances, - currentEndpoints []corev1.Endpoints, restoreJob *batchv1.Job, restoreID string, + currentEndpoints []corev1.Endpoints, restoreJob *batchv1.Job, restoreID string, //nolint:staticcheck // SA1019 ) error { setPreparingClusterCondition := func(resource string) { meta.SetStatusCondition(&cluster.Status.Conditions, metav1.Condition{ @@ -1643,7 +1643,7 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, sa, err := r.reconcilePGBackRestRBAC(ctx, postgresCluster) if err != nil { log.Error(err, "unable to create replica creation backup") - result.Requeue = true + result.RequeueAfter = 1 * time.Second return result, nil } @@ -1653,14 +1653,14 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, repoHost, err = r.reconcileDedicatedRepoHost(ctx, postgresCluster, repoResources, instances) if err != nil { log.Error(err, "unable to reconcile pgBackRest repo host") - result.Requeue = true + result.RequeueAfter = 1 * time.Second return result, nil } repoHostName = repoHost.GetName() if err := r.reconcilePGBackRestSecret(ctx, postgresCluster, repoHost, rootCA); err != nil { log.Error(err, "unable to reconcile pgBackRest secret") - result.Requeue = true + result.RequeueAfter = 1 * time.Second } // calculate hashes for the external repository configurations in the spec (e.g. for Azure, @@ -1669,7 +1669,7 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, configHashes, configHash, err := pgbackrest.CalculateConfigHashes(postgresCluster) if err != nil { log.Error(err, "unable to calculate config hashes") - result.Requeue = true + result.RequeueAfter = 1 * time.Second return result, nil } @@ -1677,7 +1677,7 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, replicaCreateRepo, err := r.reconcileRepos(ctx, postgresCluster, configHashes, repoResources) if err != nil { log.Error(err, "unable to reconcile pgBackRest repo host") - result.Requeue = true + result.RequeueAfter = 1 * time.Second return result, nil } @@ -1692,7 +1692,7 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, configHash, naming.ClusterPodService(postgresCluster).Name, postgresCluster.GetNamespace(), instanceNames); err != nil { log.Error(err, "unable to reconcile pgBackRest configuration") - result.Requeue = true + result.RequeueAfter = 1 * time.Second } // reconcile the pgBackRest stanza for all configuration pgBackRest repos @@ -1736,7 +1736,7 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, if err := r.reconcileReplicaCreateBackup(ctx, postgresCluster, instances, repoResources.replicaCreateBackupJobs, sa, configHash, replicaCreateRepo); err != nil { log.Error(err, "unable to reconcile replica creation backup") - result.Requeue = true + result.RequeueAfter = 1 * time.Second } // Reconcile a manual backup as defined in the spec, and triggered by the end-user via @@ -1744,7 +1744,7 @@ func (r *Reconciler) reconcilePGBackRest(ctx context.Context, if err := r.reconcileManualBackup(ctx, postgresCluster, repoResources.manualBackupJobs, sa, instances); err != nil { log.Error(err, "unable to reconcile manual backup") - result.Requeue = true + result.RequeueAfter = 1 * time.Second } return result, nil @@ -2562,7 +2562,7 @@ func (r *Reconciler) reconcileDedicatedRepoHost(ctx context.Context, if isCreate { r.Recorder.Eventf(postgresCluster, corev1.EventTypeNormal, EventRepoHostCreated, - "created pgBackRest repository host %s/%s", repoHost.TypeMeta.Kind, repoHostName) + "created pgBackRest repository host %s/%s", repoHost.Kind, repoHostName) } return repoHost, nil @@ -2800,7 +2800,7 @@ func (r *Reconciler) reconcileManualBackup(ctx context.Context, backupJob := &batchv1.Job{} backupJob.ObjectMeta = naming.PGBackRestBackupJob(postgresCluster) if currentBackupJob != nil { - backupJob.ObjectMeta.Name = currentBackupJob.ObjectMeta.Name + backupJob.Name = currentBackupJob.Name // K8SPG-1125: Prevent restoring Job labels removed by finishBackup. backupJob.ResourceVersion = currentBackupJob.ResourceVersion } @@ -2816,8 +2816,8 @@ func (r *Reconciler) reconcileManualBackup(ctx context.Context, map[string]string{ naming.PGBackRestBackup: manualAnnotation, }) - backupJob.ObjectMeta.Labels = labels - backupJob.ObjectMeta.Annotations = annotations + backupJob.Labels = labels + backupJob.Annotations = annotations // K8SPG-703 backupJob.Finalizers = []string{pNaming.FinalizerKeepJob} @@ -2972,7 +2972,7 @@ func (r *Reconciler) reconcileReplicaCreateBackup(ctx context.Context, backupJob := &batchv1.Job{} backupJob.ObjectMeta = naming.PGBackRestBackupJob(postgresCluster) if job != nil { - backupJob.ObjectMeta.Name = job.ObjectMeta.Name + backupJob.Name = job.Name } var labels, annotations map[string]string @@ -2990,8 +2990,8 @@ func (r *Reconciler) reconcileReplicaCreateBackup(ctx context.Context, map[string]string{ naming.PGBackRestConfigHash: configHash, }) - backupJob.ObjectMeta.Labels = labels - backupJob.ObjectMeta.Annotations = annotations + backupJob.Labels = labels + backupJob.Annotations = annotations // K8SPG-613 initImage, err := k8s.InitImage(ctx, r.Client, postgresCluster, &postgresCluster.Spec.Backups.PGBackRest) diff --git a/internal/controller/postgrescluster/pgbackrest_test.go b/internal/controller/postgrescluster/pgbackrest_test.go index f6c5e2436f..46133a5a45 100644 --- a/internal/controller/postgrescluster/pgbackrest_test.go +++ b/internal/controller/postgrescluster/pgbackrest_test.go @@ -2,6 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 +//nolint:staticcheck // SA1019: uses deprecated APIs that match production code package postgrescluster import ( @@ -36,16 +37,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var testCronSchedule string = "*/15 * * * *" @@ -579,9 +580,10 @@ topologySpreadConstraints: var instanceConfFound, dedicatedRepoConfFound bool for k, v := range config.Data { if v != "" { - if k == pgbackrest.CMInstanceKey { + switch k { + case pgbackrest.CMInstanceKey: instanceConfFound = true - } else if k == pgbackrest.CMRepoKey { + case pgbackrest.CMRepoKey: dedicatedRepoConfFound = true } } @@ -3447,11 +3449,11 @@ func TestGenerateRestoreJobIntent(t *testing.T) { t.Run(fmt.Sprintf("openshift-%v", openshift), func(t *testing.T) { t.Run("ObjectMeta", func(t *testing.T) { t.Run("Name", func(t *testing.T) { - assert.Equal(t, job.ObjectMeta.Name, + assert.Equal(t, job.Name, naming.PGBackRestRestoreJob(cluster).Name) }) t.Run("Namespace", func(t *testing.T) { - assert.Equal(t, job.ObjectMeta.Namespace, + assert.Equal(t, job.Namespace, naming.PGBackRestRestoreJob(cluster).Namespace) }) t.Run("Annotations", func(t *testing.T) { @@ -3915,17 +3917,17 @@ func TestObserveRestoreEnv(t *testing.T) { }{{ desc: "restore job and all patroni endpoints exist", createResources: func(t *testing.T, cluster *v1beta1.PostgresCluster) { - fakeLeaderEP := &corev1.Endpoints{} + fakeLeaderEP := &corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeLeaderEP.ObjectMeta = naming.PatroniLeaderEndpoints(cluster) - fakeLeaderEP.ObjectMeta.Namespace = namespace + fakeLeaderEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, fakeLeaderEP)) - fakeDCSEP := &corev1.Endpoints{} + fakeDCSEP := &corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeDCSEP.ObjectMeta = naming.PatroniDistributedConfiguration(cluster) - fakeDCSEP.ObjectMeta.Namespace = namespace + fakeDCSEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, fakeDCSEP)) - fakeFailoverEP := &corev1.Endpoints{} + fakeFailoverEP := &corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeFailoverEP.ObjectMeta = naming.PatroniTrigger(cluster) - fakeFailoverEP.ObjectMeta.Namespace = namespace + fakeFailoverEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, fakeFailoverEP)) job := generateJob(cluster.Name, new(false), new(false)) @@ -3939,17 +3941,17 @@ func TestObserveRestoreEnv(t *testing.T) { }, { desc: "patroni endpoints only exist", createResources: func(t *testing.T, cluster *v1beta1.PostgresCluster) { - fakeLeaderEP := &corev1.Endpoints{} + fakeLeaderEP := &corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeLeaderEP.ObjectMeta = naming.PatroniLeaderEndpoints(cluster) - fakeLeaderEP.ObjectMeta.Namespace = namespace + fakeLeaderEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, fakeLeaderEP)) - fakeDCSEP := &corev1.Endpoints{} + fakeDCSEP := &corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeDCSEP.ObjectMeta = naming.PatroniDistributedConfiguration(cluster) - fakeDCSEP.ObjectMeta.Namespace = namespace + fakeDCSEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, fakeDCSEP)) - fakeFailoverEP := &corev1.Endpoints{} + fakeFailoverEP := &corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeFailoverEP.ObjectMeta = naming.PatroniTrigger(cluster) - fakeFailoverEP.ObjectMeta.Namespace = namespace + fakeFailoverEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, fakeFailoverEP)) }, result: testResult{ @@ -4093,14 +4095,14 @@ func TestPrepareForRestore(t *testing.T) { for _, dedicated := range []bool{true, false} { testCases := []struct { desc string - createResources func(t *testing.T, cluster *v1beta1.PostgresCluster) (*batchv1.Job, []corev1.Endpoints) + createResources func(t *testing.T, cluster *v1beta1.PostgresCluster) (*batchv1.Job, []corev1.Endpoints) //nolint:staticcheck // SA1019: matches production code fakeObserved *observedInstances result testResult }{{ desc: "remove restore jobs", createResources: func(t *testing.T, cluster *v1beta1.PostgresCluster, - ) (*batchv1.Job, []corev1.Endpoints) { + ) (*batchv1.Job, []corev1.Endpoints) { //nolint:staticcheck // SA1019: matches production code job := generateJob(cluster.Name) assert.NilError(t, r.Client.Create(ctx, job)) return job, nil @@ -4119,20 +4121,20 @@ func TestPrepareForRestore(t *testing.T) { desc: "remove patroni endpoints", createResources: func(t *testing.T, cluster *v1beta1.PostgresCluster, - ) (*batchv1.Job, []corev1.Endpoints) { - fakeLeaderEP := corev1.Endpoints{} + ) (*batchv1.Job, []corev1.Endpoints) { //nolint:staticcheck // SA1019: matches production code + fakeLeaderEP := corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeLeaderEP.ObjectMeta = naming.PatroniLeaderEndpoints(cluster) - fakeLeaderEP.ObjectMeta.Namespace = namespace + fakeLeaderEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, &fakeLeaderEP)) - fakeDCSEP := corev1.Endpoints{} + fakeDCSEP := corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeDCSEP.ObjectMeta = naming.PatroniDistributedConfiguration(cluster) - fakeDCSEP.ObjectMeta.Namespace = namespace + fakeDCSEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, &fakeDCSEP)) - fakeFailoverEP := corev1.Endpoints{} + fakeFailoverEP := corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code fakeFailoverEP.ObjectMeta = naming.PatroniTrigger(cluster) - fakeFailoverEP.ObjectMeta.Namespace = namespace + fakeFailoverEP.Namespace = namespace assert.NilError(t, r.Client.Create(ctx, &fakeFailoverEP)) - return nil, []corev1.Endpoints{fakeLeaderEP, fakeDCSEP, fakeFailoverEP} + return nil, []corev1.Endpoints{fakeLeaderEP, fakeDCSEP, fakeFailoverEP} //nolint:staticcheck // SA1019 }, result: testResult{ restoreJobExists: false, @@ -4148,8 +4150,8 @@ func TestPrepareForRestore(t *testing.T) { desc: "cluster fully prepared", createResources: func(t *testing.T, cluster *v1beta1.PostgresCluster, - ) (*batchv1.Job, []corev1.Endpoints) { - return nil, []corev1.Endpoints{} + ) (*batchv1.Job, []corev1.Endpoints) { //nolint:staticcheck // SA1019: matches production code + return nil, []corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code }, result: testResult{ restoreJobExists: false, @@ -4176,8 +4178,8 @@ func TestPrepareForRestore(t *testing.T) { }}, createResources: func(t *testing.T, cluster *v1beta1.PostgresCluster, - ) (*batchv1.Job, []corev1.Endpoints) { - return nil, []corev1.Endpoints{} + ) (*batchv1.Job, []corev1.Endpoints) { //nolint:staticcheck // SA1019: matches production code + return nil, []corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code }, result: testResult{ restoreJobExists: false, @@ -4239,8 +4241,8 @@ func TestPrepareForRestore(t *testing.T) { naming.GenerateStartupInstance(cluster, &cluster.Spec.InstanceSets[0]).Name) } - leaderEP, dcsEP, failoverEP := corev1.Endpoints{}, corev1.Endpoints{}, corev1.Endpoints{} - currentEndpoints := []corev1.Endpoints{} + leaderEP, dcsEP, failoverEP := corev1.Endpoints{}, corev1.Endpoints{}, corev1.Endpoints{} //nolint:staticcheck // SA1019: matches production code + currentEndpoints := []corev1.Endpoints{} //nolint:staticcheck // SA1019 if err := r.Client.Get(ctx, naming.AsObjectKey(naming.PatroniLeaderEndpoints(cluster)), &leaderEP); err != nil { assert.NilError(t, client.IgnoreNotFound(err)) diff --git a/internal/controller/postgrescluster/pgbouncer.go b/internal/controller/postgrescluster/pgbouncer.go index 93dc2f2cea..ec1caba06a 100644 --- a/internal/controller/postgrescluster/pgbouncer.go +++ b/internal/controller/postgrescluster/pgbouncer.go @@ -19,17 +19,17 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" - pgbruntime "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + pgbruntime "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // reconcilePGBouncer writes the objects necessary to run a PgBouncer Pod. diff --git a/internal/controller/postgrescluster/pgbouncer_test.go b/internal/controller/postgrescluster/pgbouncer_test.go index 076e354a30..161fc2b573 100644 --- a/internal/controller/postgrescluster/pgbouncer_test.go +++ b/internal/controller/postgrescluster/pgbouncer_test.go @@ -22,13 +22,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - pgbruntime "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime/pgbouncer" - pgbmock "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime/pgbouncer/mock" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + pgbruntime "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime/pgbouncer" + pgbmock "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime/pgbouncer/mock" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGetAdditionalTrustedCAs(t *testing.T) { @@ -261,12 +261,12 @@ ownerReferences: assert.Assert(t, specified) // Annotations present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, service.Annotations, map[string]string{ "a": "v1", }) // Labels present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, service.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "postgres-operator.crunchydata.com/cluster": "pg7", "postgres-operator.crunchydata.com/role": "pgbouncer", @@ -294,13 +294,13 @@ ownerReferences: assert.Assert(t, specified) // Annotations present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, service.Annotations, map[string]string{ "a": "v1", "c": "v3", }) // Labels present in the metadata. - assert.DeepEqual(t, service.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, service.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "d": "v4", "postgres-operator.crunchydata.com/cluster": "pg7", @@ -587,12 +587,12 @@ namespace: ns3 assert.Assert(t, specified) // Annotations present in the metadata. - assert.DeepEqual(t, deploy.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, deploy.Annotations, map[string]string{ "a": "v1", }) // Labels present in the metadata. - assert.DeepEqual(t, deploy.ObjectMeta.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ + assert.DeepEqual(t, deploy.Labels, map[string]string(naming.WithPerconaLabels(map[string]string{ "b": "v2", "postgres-operator.crunchydata.com/cluster": "test-cluster", "postgres-operator.crunchydata.com/role": "pgbouncer", diff --git a/internal/controller/postgrescluster/pgmonitor.go b/internal/controller/postgrescluster/pgmonitor.go index 5b08c1d08d..c3cb9ffa04 100644 --- a/internal/controller/postgrescluster/pgmonitor.go +++ b/internal/controller/postgrescluster/pgmonitor.go @@ -15,16 +15,16 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgmonitor" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - pgpassword "github.com/percona/percona-postgresql-operator/v2/internal/postgres/password" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgmonitor" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + pgpassword "github.com/percona/percona-postgresql-operator/v3/internal/postgres/password" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // If pgMonitor is enabled the pgMonitor sidecar(s) have been added to the @@ -346,7 +346,7 @@ func addPGMonitorExporterToInstancePodSpec( }, }, } - configVolume.VolumeSource.Projected.Sources = append(configVolume.VolumeSource.Projected.Sources, + configVolume.Projected.Sources = append(configVolume.Projected.Sources, defaultConfigVolumeProjection) } diff --git a/internal/controller/postgrescluster/pgmonitor_test.go b/internal/controller/postgrescluster/pgmonitor_test.go index 300926fbff..b7d4b5cc09 100644 --- a/internal/controller/postgrescluster/pgmonitor_test.go +++ b/internal/controller/postgrescluster/pgmonitor_test.go @@ -20,12 +20,12 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func testExporterCollectorsAnnotation(t *testing.T, ctx context.Context, cluster *v1beta1.PostgresCluster, queriesConfig, webConfig *corev1.ConfigMap) { diff --git a/internal/controller/postgrescluster/pgtde_test.go b/internal/controller/postgrescluster/pgtde_test.go index f9febc35f7..8f1df2202f 100644 --- a/internal/controller/postgrescluster/pgtde_test.go +++ b/internal/controller/postgrescluster/pgtde_test.go @@ -24,13 +24,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgtde" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgtde" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // execCall records a single invocation of Reconciler.PodExec. diff --git a/internal/controller/postgrescluster/pki.go b/internal/controller/postgrescluster/pki.go index b948d88335..45c058e54b 100644 --- a/internal/controller/postgrescluster/pki.go +++ b/internal/controller/postgrescluster/pki.go @@ -8,7 +8,6 @@ import ( "context" "strings" - gover "github.com/hashicorp/go-version" "github.com/pkg/errors" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -17,12 +16,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -268,20 +267,14 @@ func (r *Reconciler) reconcileRootCertificate( // K8SPG-555 intent := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: existing.Name, - Namespace: existing.Namespace, - }, + ObjectMeta: naming.PostgresRootCASecret(cluster), } intent.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("Secret")) intent.Data = make(map[string][]byte) - if cluster.Labels != nil { - currVersion, err := gover.NewVersion(cluster.Labels[naming.LabelVersion]) - if err == nil && currVersion.GreaterThanOrEqual(gover.Must(gover.NewVersion("2.6.0"))) && cluster.Spec.Metadata != nil { - intent.Labels = cluster.Spec.Metadata.Labels - intent.Annotations = cluster.Spec.Metadata.Annotations - } + if cluster.Spec.Metadata != nil { + intent.Labels = cluster.Spec.Metadata.Labels + intent.Annotations = cluster.Spec.Metadata.Annotations } if err == nil { @@ -426,6 +419,9 @@ func (r *Reconciler) reconcileInternalClusterCertificate( err := errors.WithStack(client.IgnoreNotFound( r.Client.Get(ctx, client.ObjectKeyFromObject(existing), existing), )) + if err != nil { + return nil, errors.Wrap(err, "get secret") + } leaf := &pki.LeafCertificate{} primaryServiceDNSNames, err := naming.ServiceDNSNames(ctx, primaryService, cluster.Spec.ClusterServiceDNSSuffix) @@ -455,7 +451,7 @@ func (r *Reconciler) reconcileInternalClusterCertificate( intent := &corev1.Secret{ObjectMeta: naming.PostgresTLSSecret(cluster)} intent.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("Secret")) intent.Data = make(map[string][]byte) - intent.ObjectMeta.OwnerReferences = existing.ObjectMeta.OwnerReferences + intent.OwnerReferences = existing.OwnerReferences intent.Annotations = naming.Merge(cluster.Spec.Metadata.GetAnnotationsOrNil()) intent.Labels = naming.Merge( diff --git a/internal/controller/postgrescluster/pki_test.go b/internal/controller/postgrescluster/pki_test.go index 3645f61519..4b52d0308a 100644 --- a/internal/controller/postgrescluster/pki_test.go +++ b/internal/controller/postgrescluster/pki_test.go @@ -26,13 +26,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileTLSCondition(t *testing.T) { @@ -276,7 +276,7 @@ func TestReconcileCerts(t *testing.T) { err := tClient.Get(ctx, client.ObjectKeyFromObject(cluster1CASecret), cluster1CASecret) assert.NilError(t, err) - assert.Check(t, len(cluster1CASecret.ObjectMeta.OwnerReferences) == 1, "first owner reference not set") + assert.Check(t, len(cluster1CASecret.OwnerReferences) == 1, "first owner reference not set") expectedOR := metav1.OwnerReference{ APIVersion: "upstream.pgv2.percona.com/v1beta1", @@ -287,11 +287,11 @@ func TestReconcileCerts(t *testing.T) { BlockOwnerDeletion: new(true), } - assert.Equal(t, cluster1CASecret.ObjectMeta.OwnerReferences[0].APIVersion, expectedOR.APIVersion) - assert.Equal(t, cluster1CASecret.ObjectMeta.OwnerReferences[0].Kind, expectedOR.Kind) - assert.Equal(t, cluster1CASecret.ObjectMeta.OwnerReferences[0].Name, expectedOR.Name) - assert.Equal(t, *cluster1CASecret.ObjectMeta.OwnerReferences[0].Controller, true) - assert.Equal(t, *cluster1CASecret.ObjectMeta.OwnerReferences[0].BlockOwnerDeletion, true) + assert.Equal(t, cluster1CASecret.OwnerReferences[0].APIVersion, expectedOR.APIVersion) + assert.Equal(t, cluster1CASecret.OwnerReferences[0].Kind, expectedOR.Kind) + assert.Equal(t, cluster1CASecret.OwnerReferences[0].Name, expectedOR.Name) + assert.Equal(t, *cluster1CASecret.OwnerReferences[0].Controller, true) + assert.Equal(t, *cluster1CASecret.OwnerReferences[0].BlockOwnerDeletion, true) }) t.Run("check root CA secret for cluster2", func(t *testing.T) { @@ -304,7 +304,7 @@ func TestReconcileCerts(t *testing.T) { clist := &v1beta1.PostgresClusterList{} assert.NilError(t, tClient.List(ctx, clist)) - assert.Check(t, len(cluster2CASecret.ObjectMeta.OwnerReferences) == 1, "should be single owner reference") + assert.Check(t, len(cluster2CASecret.OwnerReferences) == 1, "should be single owner reference") expectedOR := metav1.OwnerReference{ APIVersion: "upstream.pgv2.percona.com/v1beta1", @@ -315,11 +315,11 @@ func TestReconcileCerts(t *testing.T) { BlockOwnerDeletion: new(true), } - assert.Equal(t, cluster2CASecret.ObjectMeta.OwnerReferences[0].APIVersion, expectedOR.APIVersion) - assert.Equal(t, cluster2CASecret.ObjectMeta.OwnerReferences[0].Kind, expectedOR.Kind) - assert.Equal(t, cluster2CASecret.ObjectMeta.OwnerReferences[0].Name, expectedOR.Name) - assert.Equal(t, *cluster2CASecret.ObjectMeta.OwnerReferences[0].Controller, true) - assert.Equal(t, *cluster2CASecret.ObjectMeta.OwnerReferences[0].BlockOwnerDeletion, true) + assert.Equal(t, cluster2CASecret.OwnerReferences[0].APIVersion, expectedOR.APIVersion) + assert.Equal(t, cluster2CASecret.OwnerReferences[0].Kind, expectedOR.Kind) + assert.Equal(t, cluster2CASecret.OwnerReferences[0].Name, expectedOR.Name) + assert.Equal(t, *cluster2CASecret.OwnerReferences[0].Controller, true) + assert.Equal(t, *cluster2CASecret.OwnerReferences[0].BlockOwnerDeletion, true) }) t.Run("root certificate is returned correctly", func(t *testing.T) { @@ -495,7 +495,7 @@ func TestReconcileCerts(t *testing.T) { testSecret := &corev1.Secret{} testSecret.Namespace, testSecret.Name = namespace, "newcustomsecret" // simulate cluster spec update - cluster2.Spec.CustomTLSSecret.LocalObjectReference.Name = "newcustomsecret" + cluster2.Spec.CustomTLSSecret.Name = "newcustomsecret" // get the expected secret projection testSecretProjection := clusterCertSecretProjection(testSecret) diff --git a/internal/controller/postgrescluster/pod_disruption_budget.go b/internal/controller/postgrescluster/pod_disruption_budget.go index 508111cb62..c7c7b52ac4 100644 --- a/internal/controller/postgrescluster/pod_disruption_budget.go +++ b/internal/controller/postgrescluster/pod_disruption_budget.go @@ -15,7 +15,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // generatePodDisruptionBudget takes parameters required to fill out a PDB and diff --git a/internal/controller/postgrescluster/pod_disruption_budget_test.go b/internal/controller/postgrescluster/pod_disruption_budget_test.go index 07bc5b8915..1a4fd24e69 100644 --- a/internal/controller/postgrescluster/pod_disruption_budget_test.go +++ b/internal/controller/postgrescluster/pod_disruption_budget_test.go @@ -12,8 +12,8 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGeneratePodDisruptionBudget(t *testing.T) { diff --git a/internal/controller/postgrescluster/postgres.go b/internal/controller/postgrescluster/postgres.go index 0ee487c8a7..469bcb3891 100644 --- a/internal/controller/postgrescluster/postgres.go +++ b/internal/controller/postgrescluster/postgres.go @@ -31,25 +31,25 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgaudit" - "github.com/percona/percona-postgresql-operator/v2/internal/pgcron" - "github.com/percona/percona-postgresql-operator/v2/internal/pgrepack" - "github.com/percona/percona-postgresql-operator/v2/internal/pgstatmonitor" - "github.com/percona/percona-postgresql-operator/v2/internal/pgstatstatements" - "github.com/percona/percona-postgresql-operator/v2/internal/pgtde" - "github.com/percona/percona-postgresql-operator/v2/internal/pgvector" - "github.com/percona/percona-postgresql-operator/v2/internal/postgis" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - pgpassword "github.com/percona/percona-postgresql-operator/v2/internal/postgres/password" - "github.com/percona/percona-postgresql-operator/v2/internal/setuser" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgaudit" + "github.com/percona/percona-postgresql-operator/v3/internal/pgcron" + "github.com/percona/percona-postgresql-operator/v3/internal/pgrepack" + "github.com/percona/percona-postgresql-operator/v3/internal/pgstatmonitor" + "github.com/percona/percona-postgresql-operator/v3/internal/pgstatstatements" + "github.com/percona/percona-postgresql-operator/v3/internal/pgtde" + "github.com/percona/percona-postgresql-operator/v3/internal/pgvector" + "github.com/percona/percona-postgresql-operator/v3/internal/postgis" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + pgpassword "github.com/percona/percona-postgresql-operator/v3/internal/postgres/password" + "github.com/percona/percona-postgresql-operator/v3/internal/setuser" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // generatePostgresUserSecret returns a Secret containing a password and @@ -1064,7 +1064,7 @@ func (r *Reconciler) reconcilePostgresUserSecrets( // If both secrets have "pguser" or neither have "pguser", // sort by creation timestamp - return secrets.Items[i].CreationTimestamp.Time.After(secrets.Items[j].CreationTimestamp.Time) + return secrets.Items[i].CreationTimestamp.After(secrets.Items[j].CreationTimestamp.Time) }) // Index secrets by PostgreSQL user name and delete any that are not in the diff --git a/internal/controller/postgrescluster/postgres_test.go b/internal/controller/postgrescluster/postgres_test.go index d03d2733eb..4f2ab873be 100644 --- a/internal/controller/postgrescluster/postgres_test.go +++ b/internal/controller/postgrescluster/postgres_test.go @@ -23,15 +23,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGeneratePostgresUserSecret(t *testing.T) { diff --git a/internal/controller/postgrescluster/rbac.go b/internal/controller/postgrescluster/rbac.go index 73817e310e..c4b6311dc3 100644 --- a/internal/controller/postgrescluster/rbac.go +++ b/internal/controller/postgrescluster/rbac.go @@ -11,9 +11,9 @@ import ( corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // reconcileRBACResources creates Roles, RoleBindings, and ServiceAccounts for diff --git a/internal/controller/postgrescluster/snapshots.go b/internal/controller/postgrescluster/snapshots.go index 9db6f381dc..27af823c96 100644 --- a/internal/controller/postgrescluster/snapshots.go +++ b/internal/controller/postgrescluster/snapshots.go @@ -18,14 +18,14 @@ import ( volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="snapshot.storage.k8s.io",resources="volumesnapshots",verbs={get,list,create,patch,delete} diff --git a/internal/controller/postgrescluster/snapshots_test.go b/internal/controller/postgrescluster/snapshots_test.go index 29d84adf03..a30c4d5461 100644 --- a/internal/controller/postgrescluster/snapshots_test.go +++ b/internal/controller/postgrescluster/snapshots_test.go @@ -21,13 +21,13 @@ import ( "k8s.io/client-go/discovery" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileVolumeSnapshots(t *testing.T) { @@ -57,7 +57,7 @@ func TestReconcileVolumeSnapshots(t *testing.T) { // Create cluster (without snapshots spec) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" assert.NilError(t, r.Client.Create(ctx, cluster)) t.Cleanup(func() { assert.Check(t, r.Client.Delete(ctx, cluster)) }) @@ -194,7 +194,7 @@ func TestReconcileVolumeSnapshots(t *testing.T) { // Create a cluster with snapshots enabled cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" cluster.Spec.Backups.Snapshots = &v1beta1.VolumeSnapshots{ VolumeSnapshotClassName: volumeSnapshotClassName, } @@ -309,7 +309,7 @@ func TestReconcileVolumeSnapshots(t *testing.T) { // Create a cluster with snapshots enabled cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" cluster.Spec.Backups.Snapshots = &v1beta1.VolumeSnapshots{ VolumeSnapshotClassName: volumeSnapshotClassName, } @@ -371,7 +371,7 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" assert.NilError(t, r.Client.Create(ctx, cluster)) t.Cleanup(func() { assert.Check(t, r.Client.Delete(ctx, cluster)) }) @@ -428,7 +428,7 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" cluster.Spec.Backups.Snapshots = &v1beta1.VolumeSnapshots{ VolumeSnapshotClassName: "my-snapshotclass", } @@ -460,7 +460,7 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" cluster.Spec.Backups.Snapshots = &v1beta1.VolumeSnapshots{ VolumeSnapshotClassName: "my-snapshotclass", } @@ -524,7 +524,7 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" cluster.Spec.Backups.Snapshots = &v1beta1.VolumeSnapshots{ VolumeSnapshotClassName: "my-snapshotclass", } @@ -623,7 +623,7 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" cluster.Spec.Backups.Snapshots = &v1beta1.VolumeSnapshots{ VolumeSnapshotClassName: "my-snapshotclass", } @@ -725,7 +725,7 @@ func TestCreateDedicatedSnapshotVolume(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" labelMap := map[string]string{ naming.LabelCluster: cluster.Name, @@ -753,7 +753,7 @@ func TestDedicatedSnapshotVolumeRestore(t *testing.T) { ns := require.Namespace(t, cc) cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" pvc := &corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ @@ -839,7 +839,7 @@ func TestGenerateVolumeSnapshot(t *testing.T) { assert.Equal(t, *snapshot.Spec.VolumeSnapshotClassName, "my-snapshot") assert.Equal(t, *snapshot.Spec.Source.PersistentVolumeClaimName, "dedicated-snapshot-volume") assert.Equal(t, snapshot.Labels[naming.LabelCluster], "hippo") - assert.Equal(t, snapshot.ObjectMeta.OwnerReferences[0].Name, "hippo") + assert.Equal(t, snapshot.OwnerReferences[0].Name, "hippo") } func TestGetDedicatedSnapshotVolumeRestoreJob(t *testing.T) { @@ -1111,7 +1111,7 @@ func TestGetSnapshotWithLatestError(t *testing.T) { }, } snapshotWithLatestError := getSnapshotWithLatestError(snapshotList) - assert.Equal(t, snapshotWithLatestError.ObjectMeta.Name, "bad-snapshot") + assert.Equal(t, snapshotWithLatestError.Name, "bad-snapshot") }) t.Run("TwoSnapshotsWithErrors", func(t *testing.T) { @@ -1146,7 +1146,7 @@ func TestGetSnapshotWithLatestError(t *testing.T) { }, } snapshotWithLatestError := getSnapshotWithLatestError(snapshotList) - assert.Equal(t, snapshotWithLatestError.ObjectMeta.Name, "second-bad-snapshot") + assert.Equal(t, snapshotWithLatestError.Name, "second-bad-snapshot") }) } @@ -1342,7 +1342,7 @@ func TestGetLatestReadySnapshot(t *testing.T) { }, } latestReadySnapshot := getLatestReadySnapshot(snapshotList) - assert.Equal(t, latestReadySnapshot.ObjectMeta.Name, "good-snapshot") + assert.Equal(t, latestReadySnapshot.Name, "good-snapshot") }) t.Run("TwoReadySnapshots", func(t *testing.T) { @@ -1373,7 +1373,7 @@ func TestGetLatestReadySnapshot(t *testing.T) { }, } latestReadySnapshot := getLatestReadySnapshot(snapshotList) - assert.Equal(t, latestReadySnapshot.ObjectMeta.Name, "second-good-snapshot") + assert.Equal(t, latestReadySnapshot.Name, "second-good-snapshot") }) } @@ -1392,13 +1392,13 @@ func TestDeleteSnapshots(t *testing.T) { cluster := testCluster() cluster.Namespace = ns.Name - cluster.ObjectMeta.UID = "the-uid-123" + cluster.UID = "the-uid-123" assert.NilError(t, r.Client.Create(ctx, cluster)) rhinoCluster := testCluster() rhinoCluster.Name = "rhino" rhinoCluster.Namespace = ns.Name - rhinoCluster.ObjectMeta.UID = "the-uid-456" + rhinoCluster.UID = "the-uid-456" assert.NilError(t, r.Client.Create(ctx, rhinoCluster)) t.Cleanup(func() { diff --git a/internal/controller/postgrescluster/suite_test.go b/internal/controller/postgrescluster/suite_test.go index dc368d82f4..fa336e6192 100644 --- a/internal/controller/postgrescluster/suite_test.go +++ b/internal/controller/postgrescluster/suite_test.go @@ -20,10 +20,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) // K8SPG-992 diff --git a/internal/controller/postgrescluster/topology_test.go b/internal/controller/postgrescluster/topology_test.go index da0933e2e5..80506d36d3 100644 --- a/internal/controller/postgrescluster/topology_test.go +++ b/internal/controller/postgrescluster/topology_test.go @@ -10,7 +10,7 @@ import ( "gotest.tools/v3/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) func TestDefaultTopologySpreadConstraints(t *testing.T) { diff --git a/internal/controller/postgrescluster/util.go b/internal/controller/postgrescluster/util.go index d0492da14e..fa2c8a760e 100644 --- a/internal/controller/postgrescluster/util.go +++ b/internal/controller/postgrescluster/util.go @@ -12,13 +12,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) -var tmpDirSizeLimit = resource.MustParse("16Mi") - const ( // devSHMDir is the directory used for allocating shared memory segments, // which are needed by Postgres diff --git a/internal/controller/postgrescluster/util_test.go b/internal/controller/postgrescluster/util_test.go index a3f3733c6b..b487f96f22 100644 --- a/internal/controller/postgrescluster/util_test.go +++ b/internal/controller/postgrescluster/util_test.go @@ -13,9 +13,9 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestAddDevSHM(t *testing.T) { @@ -58,7 +58,7 @@ func TestAddDevSHM(t *testing.T) { // check there is an empty dir mounted under the dshm volume for _, v := range template.Spec.Volumes { - if v.Name == "dshm" && v.VolumeSource.EmptyDir != nil && v.VolumeSource.EmptyDir.Medium == corev1.StorageMediumMemory { + if v.Name == "dshm" && v.EmptyDir != nil && v.EmptyDir.Medium == corev1.StorageMediumMemory { found = true break } @@ -206,15 +206,14 @@ func TestAddNSSWrapper(t *testing.T) { // Each container that requires the nss_wrapper envs should be updated var actualUpdatedContainerCount int for i, c := range template.Spec.Containers { - if c.Name == naming.ContainerDatabase || - c.Name == naming.PGBackRestRepoContainerName || - c.Name == naming.PGBackRestRestoreContainerName { + switch c.Name { + case naming.ContainerDatabase, naming.PGBackRestRepoContainerName, naming.PGBackRestRestoreContainerName: assert.DeepEqual(t, expectedEnv, c.Env) actualUpdatedContainerCount++ - } else if c.Name == "pgadmin" { + case "pgadmin": assert.DeepEqual(t, expectedPGAdminEnv, c.Env) actualUpdatedContainerCount++ - } else { + default: assert.DeepEqual(t, beforeAddNSS[i], c) } } diff --git a/internal/controller/postgrescluster/volumes.go b/internal/controller/postgrescluster/volumes.go index 9e2221460c..3e6919ee15 100644 --- a/internal/controller/postgrescluster/volumes.go +++ b/internal/controller/postgrescluster/volumes.go @@ -20,12 +20,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="",resources="persistentvolumeclaims",verbs={list} @@ -128,6 +128,13 @@ func (r *Reconciler) observePersistentVolumeClaims( // - https://git.k8s.io/enhancements/keps/sig-storage/3751-volume-attributes-class corev1.PersistentVolumeClaimVolumeModifyingVolume, corev1.PersistentVolumeClaimVolumeModifyVolumeError: + + case + // These conditions are informational and do not require action + // from the operator. + corev1.PersistentVolumeClaimControllerResizeError, + corev1.PersistentVolumeClaimNodeResizeError, + corev1.PersistentVolumeClaimUnused: } } } @@ -220,7 +227,7 @@ func (r *Reconciler) configureExistingPGVolumes( Spec: cluster.Spec.InstanceSets[0].DataVolumeClaimSpec, } - volume.ObjectMeta.Labels = naming.WithPerconaLabels(map[string]string{ + volume.Labels = naming.WithPerconaLabels(map[string]string{ naming.LabelCluster: cluster.Name, naming.LabelInstanceSet: cluster.Spec.InstanceSets[0].Name, naming.LabelInstance: instanceName, @@ -275,7 +282,7 @@ func (r *Reconciler) configureExistingPGWALVolume( Spec: cluster.Spec.InstanceSets[0].DataVolumeClaimSpec, } - volume.ObjectMeta.Labels = naming.WithPerconaLabels(map[string]string{ + volume.Labels = naming.WithPerconaLabels(map[string]string{ naming.LabelCluster: cluster.Name, naming.LabelInstanceSet: cluster.Spec.InstanceSets[0].Name, naming.LabelInstance: instanceName, @@ -434,14 +441,14 @@ func (r *Reconciler) reconcileMovePGDataDir(ctx context.Context, // at this point, the Job either wasn't found or it has failed, so the it // should be created - moveDirJob.ObjectMeta.Annotations = naming.Merge(cluster.Spec.Metadata. + moveDirJob.Annotations = naming.Merge(cluster.Spec.Metadata. GetAnnotationsOrNil()) labels := naming.Merge(cluster.Spec.DataSource.Volumes.PGDataVolume.Labels, cluster.Spec.Metadata.GetLabelsOrNil(), naming.DirectoryMoveJobLabels(cluster.Name), map[string]string{ naming.LabelMovePGDataDir: "", }) - moveDirJob.ObjectMeta.Labels = labels + moveDirJob.Labels = labels // `patroni.dynamic.json` holds the previous state of the DCS. Since we are // migrating the volumes, we want to clear out any obsolete configuration info. @@ -558,14 +565,14 @@ func (r *Reconciler) reconcileMoveWALDir(ctx context.Context, } } - moveDirJob.ObjectMeta.Annotations = naming.Merge(cluster.Spec.Metadata. + moveDirJob.Annotations = naming.Merge(cluster.Spec.Metadata. GetAnnotationsOrNil()) labels := naming.Merge(cluster.Spec.DataSource.Volumes.PGWALVolume.Labels, cluster.Spec.Metadata.GetLabelsOrNil(), naming.DirectoryMoveJobLabels(cluster.Name), map[string]string{ naming.LabelMovePGWalDir: "", }) - moveDirJob.ObjectMeta.Labels = labels + moveDirJob.Labels = labels script := fmt.Sprintf(`echo "Preparing cluster %s volumes for PGO v5.x" echo "pg_wal_pvc=%s" @@ -580,7 +587,7 @@ func (r *Reconciler) reconcileMoveWALDir(ctx context.Context, cluster.Spec.DataSource.Volumes.PGWALVolume.PVCName, cluster.Spec.DataSource.Volumes.PGWALVolume.Directory, cluster.Spec.DataSource.Volumes.PGWALVolume.Directory, - cluster.ObjectMeta.Name) + cluster.Name) container := corev1.Container{ Command: []string{"bash", "-ceu", script}, @@ -678,14 +685,14 @@ func (r *Reconciler) reconcileMoveRepoDir(ctx context.Context, } } - moveDirJob.ObjectMeta.Annotations = naming.Merge( + moveDirJob.Annotations = naming.Merge( cluster.Spec.Metadata.GetAnnotationsOrNil()) labels := naming.Merge(cluster.Spec.Metadata.GetLabelsOrNil(), naming.DirectoryMoveJobLabels(cluster.Name), map[string]string{ naming.LabelMovePGBackRestRepoDir: "", }) - moveDirJob.ObjectMeta.Labels = labels + moveDirJob.Labels = labels script := fmt.Sprintf(`echo "Preparing cluster %s pgBackRest repo volume for PGO v5.x" echo "repo_pvc=%s" diff --git a/internal/controller/postgrescluster/volumes_test.go b/internal/controller/postgrescluster/volumes_test.go index 2c3abf6f9f..06acdac8da 100644 --- a/internal/controller/postgrescluster/volumes_test.go +++ b/internal/controller/postgrescluster/volumes_test.go @@ -20,12 +20,12 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestHandlePersistentVolumeClaimError(t *testing.T) { diff --git a/internal/controller/postgrescluster/watches.go b/internal/controller/postgrescluster/watches.go index d81a41ded4..789bd6c3a2 100644 --- a/internal/controller/postgrescluster/watches.go +++ b/internal/controller/postgrescluster/watches.go @@ -14,9 +14,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // watchClusterSecrets returns a handler.EventHandler for Secrets that are diff --git a/internal/controller/runtime/conversion_test.go b/internal/controller/runtime/conversion_test.go index 1e167645e1..cf8c922215 100644 --- a/internal/controller/runtime/conversion_test.go +++ b/internal/controller/runtime/conversion_test.go @@ -10,7 +10,7 @@ import ( "gotest.tools/v3/assert" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" ) func TestConvertUnstructured(t *testing.T) { diff --git a/internal/controller/runtime/reconcile_test.go b/internal/controller/runtime/reconcile_test.go index 0515a4bc35..3fcf3b1257 100644 --- a/internal/controller/runtime/reconcile_test.go +++ b/internal/controller/runtime/reconcile_test.go @@ -38,20 +38,17 @@ func TestErrorWithoutBackoff(t *testing.T) { func TestRequeueWithBackoff(t *testing.T) { result := RequeueWithBackoff() - assert.Assert(t, result.Requeue) + assert.Assert(t, !result.IsZero()) assert.Assert(t, result.RequeueAfter == 0) } func TestRequeueWithoutBackoff(t *testing.T) { result := RequeueWithoutBackoff(0) - assert.Assert(t, result.Requeue) assert.Assert(t, result.RequeueAfter > 0) result = RequeueWithoutBackoff(-1) - assert.Assert(t, result.Requeue) assert.Assert(t, result.RequeueAfter > 0) result = RequeueWithoutBackoff(time.Minute) - assert.Assert(t, result.Requeue) assert.Equal(t, result.RequeueAfter, time.Minute) } diff --git a/internal/controller/runtime/runtime.go b/internal/controller/runtime/runtime.go index 7ae99851ca..f7879c679f 100644 --- a/internal/controller/runtime/runtime.go +++ b/internal/controller/runtime/runtime.go @@ -18,8 +18,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/manager/signals" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type ( diff --git a/internal/controller/standalone_pgadmin/apply.go b/internal/controller/standalone_pgadmin/apply.go index 0eaa613df8..be72f04a75 100644 --- a/internal/controller/standalone_pgadmin/apply.go +++ b/internal/controller/standalone_pgadmin/apply.go @@ -8,6 +8,7 @@ import ( "context" "reflect" + "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -22,7 +23,7 @@ func (r *PGAdminReconciler) patch( patch client.Patch, options ...client.PatchOption, ) error { options = append([]client.PatchOption{r.Owner}, options...) - return r.Client.Patch(ctx, object, patch, options...) + return r.Patch(ctx, object, patch, options...) } // apply sends an apply patch to object's endpoint in the Kubernetes API and @@ -36,7 +37,7 @@ func (r *PGAdminReconciler) apply(ctx context.Context, object client.Object) err // Generate an apply-patch by comparing the object to its zero value. zero := reflect.New(reflect.TypeOf(object).Elem()).Interface() data, err := client.MergeFrom(zero.(client.Object)).Data(object) - apply := client.RawPatch(client.Apply.Type(), data) + apply := client.RawPatch(types.ApplyPatchType, data) // Send the apply-patch with force=true. if err == nil { diff --git a/internal/controller/standalone_pgadmin/configmap.go b/internal/controller/standalone_pgadmin/configmap.go index ff07a7c203..073e39ff03 100644 --- a/internal/controller/standalone_pgadmin/configmap.go +++ b/internal/controller/standalone_pgadmin/configmap.go @@ -17,9 +17,9 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="",resources="configmaps",verbs={get} diff --git a/internal/controller/standalone_pgadmin/configmap_test.go b/internal/controller/standalone_pgadmin/configmap_test.go index 2e2a6a8288..b54979c4d4 100644 --- a/internal/controller/standalone_pgadmin/configmap_test.go +++ b/internal/controller/standalone_pgadmin/configmap_test.go @@ -9,9 +9,9 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGenerateConfig(t *testing.T) { @@ -196,12 +196,12 @@ namespace: some-ns assert.NilError(t, err) // Annotations present in the metadata. - assert.DeepEqual(t, configmap.ObjectMeta.Annotations, map[string]string{ + assert.DeepEqual(t, configmap.Annotations, map[string]string{ "a": "v1", "b": "v2", }) // Labels present in the metadata. - assert.DeepEqual(t, configmap.ObjectMeta.Labels, map[string]string{ + assert.DeepEqual(t, configmap.Labels, map[string]string{ "c": "v3", "d": "v4", "postgres-operator.crunchydata.com/pgadmin": "pg1", "postgres-operator.crunchydata.com/role": "pgadmin", diff --git a/internal/controller/standalone_pgadmin/controller.go b/internal/controller/standalone_pgadmin/controller.go index cb7454f6e1..e249201f6c 100644 --- a/internal/controller/standalone_pgadmin/controller.go +++ b/internal/controller/standalone_pgadmin/controller.go @@ -17,9 +17,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - controllerruntime "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + controllerruntime "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // PGAdminReconciler reconciles a PGAdmin object @@ -158,7 +158,7 @@ func (r *PGAdminReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct func (r *PGAdminReconciler) setControllerReference( owner *v1beta1.PGAdmin, controlled client.Object, ) error { - return controllerutil.SetControllerReference(owner, controlled, r.Client.Scheme()) + return controllerutil.SetControllerReference(owner, controlled, r.Scheme()) } // deleteControlled safely deletes object when it is controlled by pgAdmin. @@ -170,7 +170,7 @@ func (r *PGAdminReconciler) deleteControlled( version := object.GetResourceVersion() exactly := client.Preconditions{UID: &uid, ResourceVersion: &version} - return r.Client.Delete(ctx, object, exactly) + return r.Delete(ctx, object, exactly) } return nil diff --git a/internal/controller/standalone_pgadmin/controller_test.go b/internal/controller/standalone_pgadmin/controller_test.go index 6f6eed14c3..37d20dad35 100644 --- a/internal/controller/standalone_pgadmin/controller_test.go +++ b/internal/controller/standalone_pgadmin/controller_test.go @@ -14,8 +14,8 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestDeleteControlled(t *testing.T) { diff --git a/internal/controller/standalone_pgadmin/helpers_test.go b/internal/controller/standalone_pgadmin/helpers_test.go index a4d9201639..5ccb71a549 100644 --- a/internal/controller/standalone_pgadmin/helpers_test.go +++ b/internal/controller/standalone_pgadmin/helpers_test.go @@ -15,7 +15,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) // Scale extends d according to PGO_TEST_TIMEOUT_SCALE. diff --git a/internal/controller/standalone_pgadmin/helpers_unit_test.go b/internal/controller/standalone_pgadmin/helpers_unit_test.go index cb210f27d6..67472a0d8f 100644 --- a/internal/controller/standalone_pgadmin/helpers_unit_test.go +++ b/internal/controller/standalone_pgadmin/helpers_unit_test.go @@ -9,7 +9,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // TODO(benjaminjb): This file is duplicated test help functions diff --git a/internal/controller/standalone_pgadmin/pod.go b/internal/controller/standalone_pgadmin/pod.go index 582d72dc79..8a111a6168 100644 --- a/internal/controller/standalone_pgadmin/pod.go +++ b/internal/controller/standalone_pgadmin/pod.go @@ -12,10 +12,10 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -170,7 +170,7 @@ func pod( // Check the configmap to see if we think TLS is enabled // If so, update the readiness check scheme to HTTPS if strings.Contains(gunicornData, "certfile") && strings.Contains(gunicornData, "keyfile") { - readinessProbe.ProbeHandler.HTTPGet.Scheme = corev1.URISchemeHTTPS + readinessProbe.HTTPGet.Scheme = corev1.URISchemeHTTPS } container.ReadinessProbe = readinessProbe diff --git a/internal/controller/standalone_pgadmin/pod_test.go b/internal/controller/standalone_pgadmin/pod_test.go index 87f1f892ea..e8b6655a50 100644 --- a/internal/controller/standalone_pgadmin/pod_test.go +++ b/internal/controller/standalone_pgadmin/pod_test.go @@ -12,8 +12,8 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPod(t *testing.T) { diff --git a/internal/controller/standalone_pgadmin/postgrescluster.go b/internal/controller/standalone_pgadmin/postgrescluster.go index 0c01935b77..6b8cbc8d5d 100644 --- a/internal/controller/standalone_pgadmin/postgrescluster.go +++ b/internal/controller/standalone_pgadmin/postgrescluster.go @@ -11,8 +11,8 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) //+kubebuilder:rbac:groups="upstream.pgv2.percona.com",resources="pgadmins",verbs={list} diff --git a/internal/controller/standalone_pgadmin/service.go b/internal/controller/standalone_pgadmin/service.go index e3588514c2..58096006ee 100644 --- a/internal/controller/standalone_pgadmin/service.go +++ b/internal/controller/standalone_pgadmin/service.go @@ -17,9 +17,9 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="",resources="services",verbs={get} @@ -38,7 +38,7 @@ func (r *PGAdminReconciler) reconcilePGAdminService( // need to delete any existing service(s). At the start of every reconcile // get all services that match the current pgAdmin labels. services := corev1.ServiceList{} - if err := r.Client.List(ctx, &services, + if err := r.List(ctx, &services, client.InNamespace(pgadmin.Namespace), client.MatchingLabels{ naming.LabelStandalonePGAdmin: pgadmin.Name, @@ -64,7 +64,7 @@ func (r *PGAdminReconciler) reconcilePGAdminService( if pgadmin.Spec.ServiceName != "" { // Look for an existing service with name ServiceName in the namespace existingService := &corev1.Service{} - err := r.Client.Get(ctx, types.NamespacedName{ + err := r.Get(ctx, types.NamespacedName{ Name: pgadmin.Spec.ServiceName, Namespace: pgadmin.GetNamespace(), }, existingService) diff --git a/internal/controller/standalone_pgadmin/service_test.go b/internal/controller/standalone_pgadmin/service_test.go index 2e0d0b0fdf..039255c6a6 100644 --- a/internal/controller/standalone_pgadmin/service_test.go +++ b/internal/controller/standalone_pgadmin/service_test.go @@ -9,8 +9,8 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestService(t *testing.T) { diff --git a/internal/controller/standalone_pgadmin/statefulset.go b/internal/controller/standalone_pgadmin/statefulset.go index 6ace91818a..34f7abdfb8 100644 --- a/internal/controller/standalone_pgadmin/statefulset.go +++ b/internal/controller/standalone_pgadmin/statefulset.go @@ -15,9 +15,9 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // reconcilePGAdminStatefulSet writes the StatefulSet that runs pgAdmin. @@ -33,7 +33,7 @@ func (r *PGAdminReconciler) reconcilePGAdminStatefulSet( // When we delete the StatefulSet, we will leave its Pods in place. They will be claimed by // the StatefulSet that gets created in the next reconcile. existing := &appsv1.StatefulSet{} - if err := errors.WithStack(r.Client.Get(ctx, client.ObjectKeyFromObject(sts), existing)); err != nil { + if err := errors.WithStack(r.Get(ctx, client.ObjectKeyFromObject(sts), existing)); err != nil { if !apierrors.IsNotFound(err) { return err } @@ -46,7 +46,7 @@ func (r *PGAdminReconciler) reconcilePGAdminStatefulSet( exactly := client.Preconditions{UID: &uid, ResourceVersion: &version} propagate := client.PropagationPolicy(metav1.DeletePropagationOrphan) - return errors.WithStack(client.IgnoreNotFound(r.Client.Delete(ctx, existing, exactly, propagate))) + return errors.WithStack(client.IgnoreNotFound(r.Delete(ctx, existing, exactly, propagate))) } } diff --git a/internal/controller/standalone_pgadmin/statefulset_test.go b/internal/controller/standalone_pgadmin/statefulset_test.go index cad9bb5f76..ab01adb38f 100644 --- a/internal/controller/standalone_pgadmin/statefulset_test.go +++ b/internal/controller/standalone_pgadmin/statefulset_test.go @@ -14,10 +14,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcilePGAdminStatefulSet(t *testing.T) { diff --git a/internal/controller/standalone_pgadmin/users.go b/internal/controller/standalone_pgadmin/users.go index 9e6582467e..d24045bcae 100644 --- a/internal/controller/standalone_pgadmin/users.go +++ b/internal/controller/standalone_pgadmin/users.go @@ -18,9 +18,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type Executor func( @@ -53,7 +53,7 @@ func (r *PGAdminReconciler) reconcilePGAdminUsers(ctx context.Context, pgadmin * pod := &corev1.Pod{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} pod.Name += "-0" - err := errors.WithStack(r.Client.Get(ctx, client.ObjectKeyFromObject(pod), pod)) + err := errors.WithStack(r.Get(ctx, client.ObjectKeyFromObject(pod), pod)) if err != nil { return client.IgnoreNotFound(err) } @@ -136,7 +136,7 @@ func (r *PGAdminReconciler) writePGAdminUsers(ctx context.Context, pgadmin *v1be existingUserSecret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} err := errors.WithStack( - r.Client.Get(ctx, client.ObjectKeyFromObject(existingUserSecret), existingUserSecret)) + r.Get(ctx, client.ObjectKeyFromObject(existingUserSecret), existingUserSecret)) if client.IgnoreNotFound(err) != nil { return err } @@ -183,10 +183,10 @@ cd $PGADMIN_DIR // Get password from secret userPasswordSecret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{ Namespace: pgadmin.Namespace, - Name: user.PasswordRef.LocalObjectReference.Name, + Name: user.PasswordRef.Name, }} err := errors.WithStack( - r.Client.Get(ctx, client.ObjectKeyFromObject(userPasswordSecret), userPasswordSecret)) + r.Get(ctx, client.ObjectKeyFromObject(userPasswordSecret), userPasswordSecret)) if err != nil { log.Error(err, "Could not get user password secret") continue @@ -293,7 +293,7 @@ cd $PGADMIN_DIR // to add a user, that user will not be in intentUsers. If errors occurred when attempting to // update a user, the user will be in intentUsers as it existed before. We now want to marshal the // intentUsers to json and write the users.json file to the secret. - intentUserSecret.Data["users.json"], _ = json.Marshal(intentUsers) + intentUserSecret.Data["users.json"], _ = json.Marshal(intentUsers) //nolint:gosec //TODO:investigate the security concern err = errors.WithStack(r.setControllerReference(pgadmin, intentUserSecret)) if err == nil { diff --git a/internal/controller/standalone_pgadmin/users_test.go b/internal/controller/standalone_pgadmin/users_test.go index 215523ed97..fa775f867c 100644 --- a/internal/controller/standalone_pgadmin/users_test.go +++ b/internal/controller/standalone_pgadmin/users_test.go @@ -19,11 +19,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcilePGAdminUsers(t *testing.T) { @@ -305,7 +305,7 @@ func TestWritePGAdminUsers(t *testing.T) { secret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -365,7 +365,7 @@ func TestWritePGAdminUsers(t *testing.T) { secret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -437,7 +437,7 @@ func TestWritePGAdminUsers(t *testing.T) { secret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -482,7 +482,7 @@ func TestWritePGAdminUsers(t *testing.T) { secret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -524,7 +524,7 @@ func TestWritePGAdminUsers(t *testing.T) { // User in users.json should be unchanged secret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -551,7 +551,7 @@ func TestWritePGAdminUsers(t *testing.T) { // User in users.json should be unchanged assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -604,7 +604,7 @@ func TestWritePGAdminUsers(t *testing.T) { // have succeeded secret := &corev1.Secret{ObjectMeta: naming.StandalonePGAdmin(pgadmin)} assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -632,7 +632,7 @@ func TestWritePGAdminUsers(t *testing.T) { // User in users.json should be unchanged and attempt to add user should not // have succeeded assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -660,7 +660,7 @@ func TestWritePGAdminUsers(t *testing.T) { // User in users.json should be unchanged and attempt to add user should not // have succeeded assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) @@ -689,7 +689,7 @@ func TestWritePGAdminUsers(t *testing.T) { // User in users.json should be unchanged and attempt to add user should not // have succeeded assert.NilError(t, - reconciler.Client.Get(ctx, client.ObjectKeyFromObject(secret), secret)) + reconciler.Get(ctx, client.ObjectKeyFromObject(secret), secret)) if assert.Check(t, secret.Data["users.json"] != nil) { var usersArr []pgAdminUserForJson assert.NilError(t, json.Unmarshal(secret.Data["users.json"], &usersArr)) diff --git a/internal/controller/standalone_pgadmin/volume.go b/internal/controller/standalone_pgadmin/volume.go index cb92fdd66d..0063f4e8d8 100644 --- a/internal/controller/standalone_pgadmin/volume.go +++ b/internal/controller/standalone_pgadmin/volume.go @@ -15,8 +15,8 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:groups="",resources="persistentvolumeclaims",verbs={create,patch} diff --git a/internal/controller/standalone_pgadmin/volume_test.go b/internal/controller/standalone_pgadmin/volume_test.go index f287850f83..7938ccbe3f 100644 --- a/internal/controller/standalone_pgadmin/volume_test.go +++ b/internal/controller/standalone_pgadmin/volume_test.go @@ -17,12 +17,12 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcilePGAdminDataVolume(t *testing.T) { diff --git a/internal/controller/standalone_pgadmin/watches.go b/internal/controller/standalone_pgadmin/watches.go index 779f5cfa49..5db21eb6f8 100644 --- a/internal/controller/standalone_pgadmin/watches.go +++ b/internal/controller/standalone_pgadmin/watches.go @@ -14,7 +14,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // watchPostgresClusters returns a [handler.EventHandler] for PostgresClusters. @@ -92,7 +92,7 @@ func (r *PGAdminReconciler) findPGAdminsForSecret( }); err == nil { for i := range pgadmins.Items { for j := range pgadmins.Items[i].Spec.Users { - if pgadmins.Items[i].Spec.Users[j].PasswordRef.LocalObjectReference.Name == secret.Name { + if pgadmins.Items[i].Spec.Users[j].PasswordRef.Name == secret.Name { matching = append(matching, &pgadmins.Items[i]) break } diff --git a/internal/controller/standalone_pgadmin/watches_test.go b/internal/controller/standalone_pgadmin/watches_test.go index ae20162470..0b1d61b7a8 100644 --- a/internal/controller/standalone_pgadmin/watches_test.go +++ b/internal/controller/standalone_pgadmin/watches_test.go @@ -12,8 +12,8 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestFindPGAdminsForSecret(t *testing.T) { diff --git a/internal/initialize/intstr_test.go b/internal/initialize/intstr_test.go index 25bea92895..93b5cbc7c1 100644 --- a/internal/initialize/intstr_test.go +++ b/internal/initialize/intstr_test.go @@ -21,7 +21,7 @@ import ( "gotest.tools/v3/assert" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" ) func TestIntOrStringInt32(t *testing.T) { diff --git a/internal/initialize/metadata_test.go b/internal/initialize/metadata_test.go index 1ad4016d10..50b4d463c0 100644 --- a/internal/initialize/metadata_test.go +++ b/internal/initialize/metadata_test.go @@ -10,7 +10,7 @@ import ( "gotest.tools/v3/assert" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" ) func TestAnnotations(t *testing.T) { diff --git a/internal/initialize/primitives_test.go b/internal/initialize/primitives_test.go index cf942c1a5b..0a480de96c 100644 --- a/internal/initialize/primitives_test.go +++ b/internal/initialize/primitives_test.go @@ -9,7 +9,7 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" ) func TestFromPointer(t *testing.T) { diff --git a/internal/initialize/security_test.go b/internal/initialize/security_test.go index 8a684e3ada..e8c2dcef39 100644 --- a/internal/initialize/security_test.go +++ b/internal/initialize/security_test.go @@ -11,7 +11,7 @@ import ( "gotest.tools/v3/assert" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" ) func TestPodSecurityContext(t *testing.T) { diff --git a/internal/logicalreplica/postgres.go b/internal/logicalreplica/postgres.go index 10fd1a1c03..25d4714d62 100644 --- a/internal/logicalreplica/postgres.go +++ b/internal/logicalreplica/postgres.go @@ -10,8 +10,8 @@ import ( "fmt" "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/logicalreplica/postgres_test.go b/internal/logicalreplica/postgres_test.go index 1830cd6a44..a3ae1b8a08 100644 --- a/internal/logicalreplica/postgres_test.go +++ b/internal/logicalreplica/postgres_test.go @@ -11,8 +11,8 @@ import ( pg_query "github.com/pganalyze/pg_query_go/v6" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func clusterWithReplicas(names ...string) *v1beta1.PostgresCluster { diff --git a/internal/naming/names.go b/internal/naming/names.go index 8c18aafa40..44ab417d56 100644 --- a/internal/naming/names.go +++ b/internal/naming/names.go @@ -13,8 +13,8 @@ import ( "k8s.io/apimachinery/pkg/util/rand" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/naming/names_test.go b/internal/naming/names_test.go index 0834d72d1f..ddd215a199 100644 --- a/internal/naming/names_test.go +++ b/internal/naming/names_test.go @@ -16,7 +16,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestAsObjectKey(t *testing.T) { diff --git a/internal/naming/selectors.go b/internal/naming/selectors.go index 5c11b0ee62..b3089967f2 100644 --- a/internal/naming/selectors.go +++ b/internal/naming/selectors.go @@ -8,7 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // AsSelector is a wrapper around metav1.LabelSelectorAsSelector() which converts diff --git a/internal/naming/selectors_test.go b/internal/naming/selectors_test.go index ebec6ef487..16a7875703 100644 --- a/internal/naming/selectors_test.go +++ b/internal/naming/selectors_test.go @@ -10,7 +10,7 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestAnyCluster(t *testing.T) { diff --git a/internal/naming/telemetry.go b/internal/naming/telemetry.go index 82bf0dcee3..212205ed0b 100644 --- a/internal/naming/telemetry.go +++ b/internal/naming/telemetry.go @@ -6,4 +6,4 @@ package naming import "go.opentelemetry.io/otel" -var tracer = otel.Tracer("github.com/percona/percona-postgresql-operator/v2/naming") +var tracer = otel.Tracer("github.com/percona/percona-postgresql-operator/v3/naming") diff --git a/internal/patroni/api.go b/internal/patroni/api.go index 9375337a73..37c8dc5c96 100644 --- a/internal/patroni/api.go +++ b/internal/patroni/api.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" ) // API defines a general interface for interacting with the Patroni API. diff --git a/internal/patroni/certificates_test.go b/internal/patroni/certificates_test.go index 534f977672..b0f9a2ff5f 100644 --- a/internal/patroni/certificates_test.go +++ b/internal/patroni/certificates_test.go @@ -11,7 +11,7 @@ import ( "gotest.tools/v3/assert" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) type funcMarshaler func() ([]byte, error) diff --git a/internal/patroni/config.go b/internal/patroni/config.go index 6853cb45a4..cfe2d456a2 100644 --- a/internal/patroni/config.go +++ b/internal/patroni/config.go @@ -15,10 +15,10 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/logicalreplica" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logicalreplica" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -531,7 +531,7 @@ func instanceYAML( }, } - postgresql := map[string]any{ + postgresql := map[string]any{ //nolint:gosec //TODO: investigate the security concern // TODO(cbandy): "bin_dir" // Missing here is "connect_address" which cannot be known until the diff --git a/internal/patroni/config_test.go b/internal/patroni/config_test.go index b37b005b1f..cf33224934 100644 --- a/internal/patroni/config_test.go +++ b/internal/patroni/config_test.go @@ -18,13 +18,13 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestClusterYAML(t *testing.T) { @@ -1360,7 +1360,7 @@ func TestPGBackRestCreateReplicaCommand(t *testing.T) { file := filepath.Join(dir, "command.sh") assert.NilError(t, os.WriteFile(file, []byte(command), 0o600)) - cmd := exec.Command(shellcheck, "--enable=all", "--shell=sh", file) + cmd := exec.CommandContext(context.Background(), shellcheck, "--enable=all", "--shell=sh", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) } @@ -1382,7 +1382,7 @@ func TestPGBackRestCreateReplicaCommand(t *testing.T) { file := filepath.Join(dir, "script.bash") assert.NilError(t, os.WriteFile(file, []byte(script), 0o600)) - cmd := exec.Command(shellcheck, "--enable=all", file) + cmd := exec.CommandContext(context.Background(), shellcheck, "--enable=all", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) } diff --git a/internal/patroni/rbac.go b/internal/patroni/rbac.go index 2e19339ed9..8856ffc65d 100644 --- a/internal/patroni/rbac.go +++ b/internal/patroni/rbac.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // "list", "patch", and "watch" are required. Include "get" for good measure. diff --git a/internal/patroni/rbac_test.go b/internal/patroni/rbac_test.go index 4b45aa1f94..53dcb1227a 100644 --- a/internal/patroni/rbac_test.go +++ b/internal/patroni/rbac_test.go @@ -10,8 +10,8 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func isUniqueAndSorted(slice []string) bool { diff --git a/internal/patroni/reconcile.go b/internal/patroni/reconcile.go index ece6cea757..538698d2ce 100644 --- a/internal/patroni/reconcile.go +++ b/internal/patroni/reconcile.go @@ -12,14 +12,14 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // ClusterBootstrapped returns a bool indicating whether or not Patroni has successfully diff --git a/internal/patroni/reconcile_test.go b/internal/patroni/reconcile_test.go index e7f2a239a5..29b9d53523 100644 --- a/internal/patroni/reconcile_test.go +++ b/internal/patroni/reconcile_test.go @@ -13,11 +13,11 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestClusterConfigMap(t *testing.T) { diff --git a/internal/pgadmin/config.go b/internal/pgadmin/config.go index d30b32c2ef..521828d232 100644 --- a/internal/pgadmin/config.go +++ b/internal/pgadmin/config.go @@ -9,7 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgadmin/config_test.go b/internal/pgadmin/config_test.go index f47cd1a024..748609e997 100644 --- a/internal/pgadmin/config_test.go +++ b/internal/pgadmin/config_test.go @@ -5,6 +5,7 @@ package pgadmin import ( + "context" "os" "os/exec" "path/filepath" @@ -14,9 +15,9 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPodConfigFiles(t *testing.T) { @@ -77,7 +78,7 @@ func TestStartupCommand(t *testing.T) { assert.NilError(t, os.WriteFile(file, []byte(command[3]), 0o600)) // Expect shellcheck to be happy. - cmd := exec.Command(shellcheck, "--enable=all", file) + cmd := exec.CommandContext(context.Background(), shellcheck, "--enable=all", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) }) @@ -94,7 +95,7 @@ func TestStartupCommand(t *testing.T) { // Expect flake8 to be happy. Ignore "E401 multiple imports on one line" // in addition to the defaults. The file contents appear in PodSpec, so // allow lines longer than the default to save some vertical space. - cmd := exec.Command(flake8, "--extend-ignore=E401", "--max-line-length=99", file) + cmd := exec.CommandContext(context.Background(), flake8, "--extend-ignore=E401", "--max-line-length=99", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) }) diff --git a/internal/pgadmin/reconcile.go b/internal/pgadmin/reconcile.go index a68725ada0..fd7e6e2047 100644 --- a/internal/pgadmin/reconcile.go +++ b/internal/pgadmin/reconcile.go @@ -12,10 +12,10 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // startupScript is the script for the configuration and startup of the pgAdmin service. diff --git a/internal/pgadmin/reconcile_test.go b/internal/pgadmin/reconcile_test.go index bfaee6d20b..60b680d0b4 100644 --- a/internal/pgadmin/reconcile_test.go +++ b/internal/pgadmin/reconcile_test.go @@ -12,9 +12,9 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestConfigMap(t *testing.T) { diff --git a/internal/pgadmin/users.go b/internal/pgadmin/users.go index dc95c1a29c..f32d0a080c 100644 --- a/internal/pgadmin/users.go +++ b/internal/pgadmin/users.go @@ -12,9 +12,9 @@ import ( "io" "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type Executor func( diff --git a/internal/pgadmin/users_test.go b/internal/pgadmin/users_test.go index dba8afd2fd..2315ee7d23 100644 --- a/internal/pgadmin/users_test.go +++ b/internal/pgadmin/users_test.go @@ -17,8 +17,8 @@ import ( "gotest.tools/v3/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestWriteUsersInPGAdmin(t *testing.T) { @@ -179,7 +179,7 @@ with create_app().app_context(): // Expect flake8 to be happy. Ignore "E402 module level import not // at top of file" in addition to the defaults. - cmd := exec.Command(flake8, "--extend-ignore=E402", file) + cmd := exec.CommandContext(context.Background(), flake8, "--extend-ignore=E402", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) diff --git a/internal/pgaudit/postgres.go b/internal/pgaudit/postgres.go index b4c5df8313..f4fff4d3aa 100644 --- a/internal/pgaudit/postgres.go +++ b/internal/pgaudit/postgres.go @@ -7,8 +7,8 @@ package pgaudit import ( "context" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) // When the pgAudit shared library is not loaded, the extension cannot be diff --git a/internal/pgaudit/postgres_test.go b/internal/pgaudit/postgres_test.go index d160e8034f..ee039ee525 100644 --- a/internal/pgaudit/postgres_test.go +++ b/internal/pgaudit/postgres_test.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func TestEnableInPostgreSQL(t *testing.T) { diff --git a/internal/pgbackrest/certificates_test.go b/internal/pgbackrest/certificates_test.go index 767d3048ca..cbd992dcdc 100644 --- a/internal/pgbackrest/certificates_test.go +++ b/internal/pgbackrest/certificates_test.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/uuid" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) type funcMarshaler func() ([]byte, error) diff --git a/internal/pgbackrest/config.go b/internal/pgbackrest/config.go index a95a49c9f2..7e236a914b 100644 --- a/internal/pgbackrest/config.go +++ b/internal/pgbackrest/config.go @@ -13,11 +13,11 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgbackrest/config_test.go b/internal/pgbackrest/config_test.go index 56900c5b56..e5a49da1be 100644 --- a/internal/pgbackrest/config_test.go +++ b/internal/pgbackrest/config_test.go @@ -16,10 +16,10 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestCreatePGBackRestConfigMapIntent(t *testing.T) { @@ -275,7 +275,7 @@ func TestReloadCommand(t *testing.T) { assert.NilError(t, os.WriteFile(file, []byte(command[3]), 0o600)) // Expect shellcheck to be happy. - cmd := exec.CommandContext(t.Context(), shellcheck, "--enable=all", file) + cmd := exec.CommandContext(t.Context(), shellcheck, "--enable=all", file) //nolint:noctx //test data output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) } diff --git a/internal/pgbackrest/pgbackrest.go b/internal/pgbackrest/pgbackrest.go index 95a8cc8cc5..b7b4691398 100644 --- a/internal/pgbackrest/pgbackrest.go +++ b/internal/pgbackrest/pgbackrest.go @@ -12,7 +12,7 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgbackrest/pgbackrest_test.go b/internal/pgbackrest/pgbackrest_test.go index d51f2d4675..5f9922df9e 100644 --- a/internal/pgbackrest/pgbackrest_test.go +++ b/internal/pgbackrest/pgbackrest_test.go @@ -16,8 +16,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestStanzaCreateOrUpgrade(t *testing.T) { @@ -92,7 +92,7 @@ fi assert.NilError(t, os.WriteFile(file, []byte(shellCheckScript), 0o600)) // Expect shellcheck to be happy. - cmd := exec.Command(shellcheck, "--enable=all", file) + cmd := exec.CommandContext(context.Background(), shellcheck, "--enable=all", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) } diff --git a/internal/pgbackrest/postgres.go b/internal/pgbackrest/postgres.go index b88a450b62..bb26bbf3be 100644 --- a/internal/pgbackrest/postgres.go +++ b/internal/pgbackrest/postgres.go @@ -7,8 +7,8 @@ package pgbackrest import ( "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // PostgreSQL populates outParameters with any settings needed to run pgBackRest. diff --git a/internal/pgbackrest/postgres_test.go b/internal/pgbackrest/postgres_test.go index 443b04ae27..40d2f67d7c 100644 --- a/internal/pgbackrest/postgres_test.go +++ b/internal/pgbackrest/postgres_test.go @@ -10,9 +10,9 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // K8SPG-911: the restore Job reuses this, so the escaping is asserted on its own. diff --git a/internal/pgbackrest/rbac.go b/internal/pgbackrest/rbac.go index d50f4ced03..5da98f4d6f 100644 --- a/internal/pgbackrest/rbac.go +++ b/internal/pgbackrest/rbac.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // +kubebuilder:rbac:namespace=pgbackrest,groups="",resources="pods",verbs={list} diff --git a/internal/pgbackrest/rbac_test.go b/internal/pgbackrest/rbac_test.go index cdc4da8c62..4775d75e37 100644 --- a/internal/pgbackrest/rbac_test.go +++ b/internal/pgbackrest/rbac_test.go @@ -10,8 +10,8 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func isUniqueAndSorted(slice []string) bool { diff --git a/internal/pgbackrest/reconcile.go b/internal/pgbackrest/reconcile.go index b8fd434741..817dc4d02f 100644 --- a/internal/pgbackrest/reconcile.go +++ b/internal/pgbackrest/reconcile.go @@ -12,13 +12,13 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // AddRepoVolumesToPod adds pgBackRest repository volumes to the provided Pod template spec, while @@ -573,7 +573,8 @@ func Secret(ctx context.Context, // The client verifies the "pg-host" or "repo-host" option it used is // present in the DNS names of the server certificate. leaf := &pki.LeafCertificate{} - dnsNames, err := naming.RepoHostPodDNSNames(ctx, inRepoHost, inCluster.Spec.ClusterServiceDNSSuffix) + var dnsNames []string + dnsNames, err = naming.RepoHostPodDNSNames(ctx, inRepoHost, inCluster.Spec.ClusterServiceDNSSuffix) if err != nil { return errors.Wrap(err, "failed to resolve repo host pod DNS names") } diff --git a/internal/pgbackrest/reconcile_test.go b/internal/pgbackrest/reconcile_test.go index b8c3c17617..cace9ece2a 100644 --- a/internal/pgbackrest/reconcile_test.go +++ b/internal/pgbackrest/reconcile_test.go @@ -18,11 +18,11 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestAddRepoVolumesToPod(t *testing.T) { @@ -129,7 +129,7 @@ func TestAddRepoVolumesToPod(t *testing.T) { for _, r := range tc.repos { var foundVolume bool for _, v := range template.Spec.Volumes { - if v.Name == r.Name && v.VolumeSource.PersistentVolumeClaim.ClaimName == + if v.Name == r.Name && v.PersistentVolumeClaim.ClaimName == naming.PGBackRestRepoVolume(postgresCluster, r.Name).Name { foundVolume = true break diff --git a/internal/pgbackrest/util.go b/internal/pgbackrest/util.go index 5059710b39..ffb6f36be0 100644 --- a/internal/pgbackrest/util.go +++ b/internal/pgbackrest/util.go @@ -12,7 +12,7 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/rand" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // maxPGBackrestRepos is the maximum number of repositories that can be configured according to the diff --git a/internal/pgbackrest/util_test.go b/internal/pgbackrest/util_test.go index 1eb6416bdf..5c66cf0f5f 100644 --- a/internal/pgbackrest/util_test.go +++ b/internal/pgbackrest/util_test.go @@ -13,7 +13,7 @@ import ( "gotest.tools/v3/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestCalculateConfigHashes(t *testing.T) { diff --git a/internal/pgbouncer/certificates_test.go b/internal/pgbouncer/certificates_test.go index 538e9ee1b6..02fbf62c78 100644 --- a/internal/pgbouncer/certificates_test.go +++ b/internal/pgbouncer/certificates_test.go @@ -10,7 +10,7 @@ import ( "gotest.tools/v3/assert" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) func TestBackendAuthority(t *testing.T) { diff --git a/internal/pgbouncer/config.go b/internal/pgbouncer/config.go index 5adb12c311..9fb8781fa7 100644 --- a/internal/pgbouncer/config.go +++ b/internal/pgbouncer/config.go @@ -13,11 +13,11 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer/startup" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer/startup" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgbouncer/config_test.go b/internal/pgbouncer/config_test.go index c194f2b7b6..000208acf9 100644 --- a/internal/pgbouncer/config_test.go +++ b/internal/pgbouncer/config_test.go @@ -18,9 +18,9 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPrettyYAML(t *testing.T) { @@ -555,7 +555,7 @@ func TestReloadCommand(t *testing.T) { assert.NilError(t, os.WriteFile(file, []byte(command[3]), 0o600)) // Expect shellcheck to be happy. - cmd := exec.Command(shellcheck, "--enable=all", file) + cmd := exec.CommandContext(context.Background(), shellcheck, "--enable=all", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) } diff --git a/internal/pgbouncer/postgres.go b/internal/pgbouncer/postgres.go index 9aa27475ff..04913848ee 100644 --- a/internal/pgbouncer/postgres.go +++ b/internal/pgbouncer/postgres.go @@ -10,10 +10,10 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres/password" - "github.com/percona/percona-postgresql-operator/v2/internal/util" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres/password" + "github.com/percona/percona-postgresql-operator/v3/internal/util" ) const ( diff --git a/internal/pgbouncer/reconcile.go b/internal/pgbouncer/reconcile.go index 085609e19a..0509dbd395 100644 --- a/internal/pgbouncer/reconcile.go +++ b/internal/pgbouncer/reconcile.go @@ -12,17 +12,17 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbouncer/startup" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbouncer/startup" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // crunchyBinVolumeMount is where the PgBouncer container finds the diff --git a/internal/pgbouncer/reconcile_test.go b/internal/pgbouncer/reconcile_test.go index 4339702785..ca4f9709bb 100644 --- a/internal/pgbouncer/reconcile_test.go +++ b/internal/pgbouncer/reconcile_test.go @@ -16,13 +16,13 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pki" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pki" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestConfigMap(t *testing.T) { diff --git a/internal/pgcron/postgres.go b/internal/pgcron/postgres.go index adf3d1e028..18a7ca9312 100644 --- a/internal/pgcron/postgres.go +++ b/internal/pgcron/postgres.go @@ -4,8 +4,8 @@ import ( "context" "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) // EnableInPostgreSQL installs pg_cron in the postgres database. diff --git a/internal/pgcron/postgres_test.go b/internal/pgcron/postgres_test.go index df7b497d92..7d9081c422 100644 --- a/internal/pgcron/postgres_test.go +++ b/internal/pgcron/postgres_test.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func TestEnableInPostgreSQL(t *testing.T) { diff --git a/internal/pgmonitor/api.go b/internal/pgmonitor/api.go index 2037b5f8c7..9469e76530 100644 --- a/internal/pgmonitor/api.go +++ b/internal/pgmonitor/api.go @@ -22,7 +22,7 @@ import ( "io" "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" ) type Executor func( @@ -52,7 +52,7 @@ func (exec Executor) GetExporterSetupSQL(ctx context.Context, version int) (stri "/opt/crunchy/bin/postgres/pgbackrest_info.sh") } - log.V(1).Info("updated pgMonitor default configration", "sql", sql) + log.V(1).Info("updated pgMonitor default configuration", "sql", sql) return sql, stderr.String(), err } diff --git a/internal/pgmonitor/exporter.go b/internal/pgmonitor/exporter.go index b6a4f35637..da1a36e109 100644 --- a/internal/pgmonitor/exporter.go +++ b/internal/pgmonitor/exporter.go @@ -10,8 +10,8 @@ import ( "os" "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgmonitor/exporter_test.go b/internal/pgmonitor/exporter_test.go index c88f265352..e2cb9eda77 100644 --- a/internal/pgmonitor/exporter_test.go +++ b/internal/pgmonitor/exporter_test.go @@ -13,8 +13,8 @@ import ( "gotest.tools/v3/assert" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGenerateDefaultExporterQueries(t *testing.T) { diff --git a/internal/pgmonitor/postgres.go b/internal/pgmonitor/postgres.go index 545377512d..d3708a7c12 100644 --- a/internal/pgmonitor/postgres.go +++ b/internal/pgmonitor/postgres.go @@ -9,9 +9,9 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgmonitor/postgres_test.go b/internal/pgmonitor/postgres_test.go index 5d5721567e..790d1db046 100644 --- a/internal/pgmonitor/postgres_test.go +++ b/internal/pgmonitor/postgres_test.go @@ -10,8 +10,8 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPostgreSQLHBA(t *testing.T) { diff --git a/internal/pgmonitor/util.go b/internal/pgmonitor/util.go index 90ed3837ad..7a233b9224 100644 --- a/internal/pgmonitor/util.go +++ b/internal/pgmonitor/util.go @@ -8,8 +8,8 @@ import ( "context" "os" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func GetQueriesConfigDir(ctx context.Context) string { diff --git a/internal/pgmonitor/util_test.go b/internal/pgmonitor/util_test.go index 23bb87dedd..27a11aa784 100644 --- a/internal/pgmonitor/util_test.go +++ b/internal/pgmonitor/util_test.go @@ -9,7 +9,7 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestExporterEnabled(t *testing.T) { diff --git a/internal/pgrepack/postgres.go b/internal/pgrepack/postgres.go index 401ca692ce..1762956969 100644 --- a/internal/pgrepack/postgres.go +++ b/internal/pgrepack/postgres.go @@ -3,8 +3,8 @@ package pgrepack import ( "context" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) // EnableInPostgreSQL installs pg_repack triggers into every database. diff --git a/internal/pgstatmonitor/pgstatmonitor.go b/internal/pgstatmonitor/pgstatmonitor.go index 1869cb0d80..af3c60cb8a 100644 --- a/internal/pgstatmonitor/pgstatmonitor.go +++ b/internal/pgstatmonitor/pgstatmonitor.go @@ -3,8 +3,8 @@ package pgstatmonitor import ( "context" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func EnableInPostgreSQL(ctx context.Context, exec postgres.Executor) error { diff --git a/internal/pgstatmonitor/pgstatmonitor_test.go b/internal/pgstatmonitor/pgstatmonitor_test.go index d913d91127..0c8295a25a 100644 --- a/internal/pgstatmonitor/pgstatmonitor_test.go +++ b/internal/pgstatmonitor/pgstatmonitor_test.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func TestEnableInPostgreSQL(t *testing.T) { diff --git a/internal/pgstatstatements/pgstatstatement.go b/internal/pgstatstatements/pgstatstatement.go index 0f033d3d3e..cb0cdc6e14 100644 --- a/internal/pgstatstatements/pgstatstatement.go +++ b/internal/pgstatstatements/pgstatstatement.go @@ -3,8 +3,8 @@ package pgstatstatements import ( "context" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func EnableInPostgreSQL(ctx context.Context, exec postgres.Executor) error { diff --git a/internal/pgstatstatements/pgstatstatement_test.go b/internal/pgstatstatements/pgstatstatement_test.go index bbe1a066e9..4003476c8c 100644 --- a/internal/pgstatstatements/pgstatstatement_test.go +++ b/internal/pgstatstatements/pgstatstatement_test.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func TestEnableInPostgreSQL(t *testing.T) { diff --git a/internal/pgtde/postgres.go b/internal/pgtde/postgres.go index d0439cc8b8..60e2bd9ca1 100644 --- a/internal/pgtde/postgres.go +++ b/internal/pgtde/postgres.go @@ -14,11 +14,11 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/pgtde/postgres_test.go b/internal/pgtde/postgres_test.go index 71d9a0e2ec..7ba9c10480 100644 --- a/internal/pgtde/postgres_test.go +++ b/internal/pgtde/postgres_test.go @@ -14,9 +14,9 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestEnableInPostgreSQL(t *testing.T) { diff --git a/internal/pgvector/postgres.go b/internal/pgvector/postgres.go index 34b5f4fc21..7e255d5af7 100644 --- a/internal/pgvector/postgres.go +++ b/internal/pgvector/postgres.go @@ -3,8 +3,8 @@ package pgvector import ( "context" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) // EnableInPostgreSQL installs pgvector triggers into every database. diff --git a/internal/pki/encoding_test.go b/internal/pki/encoding_test.go index db87d999f9..16b4b9dc68 100644 --- a/internal/pki/encoding_test.go +++ b/internal/pki/encoding_test.go @@ -14,7 +14,7 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) func TestCertificateTextMarshaling(t *testing.T) { @@ -103,6 +103,7 @@ func TestCertificateTextMarshaling(t *testing.T) { }) t.Run("ReadByOpenSSL", func(t *testing.T) { + ctx := t.Context() openssl := require.OpenSSL(t) dir := t.TempDir() @@ -112,7 +113,7 @@ func TestCertificateTextMarshaling(t *testing.T) { assert.NilError(t, os.WriteFile(certFile, certBytes, 0o600)) // The "openssl x509" command parses X.509 certificates. - cmd := exec.Command(openssl, "x509", + cmd := exec.CommandContext(ctx, openssl, "x509", "-in", certFile, "-inform", "PEM", "-noout", "-text") output, err := cmd.CombinedOutput() @@ -175,6 +176,7 @@ func TestPrivateKeyTextMarshaling(t *testing.T) { }) t.Run("ReadByOpenSSL", func(t *testing.T) { + ctx := t.Context() openssl := require.OpenSSL(t) dir := t.TempDir() @@ -184,7 +186,7 @@ func TestPrivateKeyTextMarshaling(t *testing.T) { assert.NilError(t, os.WriteFile(keyFile, keyBytes, 0o600)) // The "openssl pkey" command processes public and private keys. - cmd := exec.Command(openssl, "pkey", + cmd := exec.CommandContext(ctx, openssl, "pkey", "-in", keyFile, "-inform", "PEM", "-noout", "-text") output, err := cmd.CombinedOutput() @@ -195,12 +197,12 @@ func TestPrivateKeyTextMarshaling(t *testing.T) { "expected valid private key, got:\n%s", output) t.Run("Check", func(t *testing.T) { - output, _ := exec.Command(openssl, "pkey", "-help").CombinedOutput() + output, _ := exec.CommandContext(ctx, openssl, "pkey", "-help").CombinedOutput() if !strings.Contains(string(output), "-check") { t.Skip(`requires "-check" flag`) } - cmd := exec.Command(openssl, "pkey", + cmd := exec.CommandContext(ctx, openssl, "pkey", "-check", "-in", keyFile, "-inform", "PEM", "-noout", "-text") output, err := cmd.CombinedOutput() diff --git a/internal/pki/pki_test.go b/internal/pki/pki_test.go index 2eb5633961..46c5d0c6ea 100644 --- a/internal/pki/pki_test.go +++ b/internal/pki/pki_test.go @@ -5,6 +5,7 @@ package pki import ( + "context" "crypto/ecdsa" "crypto/x509" "os" @@ -16,7 +17,7 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) type StringSet map[string]struct{} @@ -194,7 +195,7 @@ func TestRootIsInvalid(t *testing.T) { t.Cleanup(func() { currentTime = original }) currentTime = func() time.Time { - return time.Date(2010, time.January, 1, 0, 0, 0, 0, time.Local) + return time.Date(2010, time.January, 1, 0, 0, 0, 0, time.Local) //nolint:gosmopolitan //test data } root, err := NewRootCertificateAuthority() @@ -395,7 +396,7 @@ func TestLeafIsInvalid(t *testing.T) { t.Cleanup(func() { currentTime = original }) currentTime = func() time.Time { - return time.Date(2010, time.January, 1, 0, 0, 0, 0, time.Local) + return time.Date(2010, time.January, 1, 0, 0, 0, 0, time.Local) //nolint:gosmopolitan //test data } leaf, err := root.GenerateLeafCertificate("", nil) @@ -439,7 +440,7 @@ func basicOpenSSLVerify(t *testing.T, openssl string, root, leaf Certificate) { verify := func(t testing.TB, args ...string) { t.Helper() // #nosec G204 -- args from this test - cmd := exec.Command(openssl, append([]string{"verify"}, args...)...) + cmd := exec.CommandContext(context.Background(), openssl, append([]string{"verify"}, args...)...) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) @@ -476,7 +477,7 @@ func basicOpenSSLVerify(t *testing.T, openssl string, root, leaf Certificate) { } func strictOpenSSLVerify(t *testing.T, openssl string, root, leaf Certificate) { - output, _ := exec.Command(openssl, "verify", "-help").CombinedOutput() + output, _ := exec.CommandContext(context.Background(), openssl, "verify", "-help").CombinedOutput() if !strings.Contains(string(output), "-x509_strict") { t.Skip(`requires "-x509_strict" flag`) } @@ -487,7 +488,7 @@ func strictOpenSSLVerify(t *testing.T, openssl string, root, leaf Certificate) { verify := func(t testing.TB, args ...string) { t.Helper() // #nosec G204 -- args from this test - cmd := exec.Command(openssl, append([]string{"verify", + cmd := exec.CommandContext(context.Background(), openssl, append([]string{"verify", // Do not use the default trusted CAs. "-no-CAfile", "-no-CApath", // Disable "non-compliant workarounds for broken certificates". diff --git a/internal/pmm/hba.go b/internal/pmm/hba.go index 4846757e6d..4ed6d86009 100644 --- a/internal/pmm/hba.go +++ b/internal/pmm/hba.go @@ -1,8 +1,8 @@ package pmm import ( - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/internal/postgis/postgis.go b/internal/postgis/postgis.go index 7b54a06395..85064abd9b 100644 --- a/internal/postgis/postgis.go +++ b/internal/postgis/postgis.go @@ -8,8 +8,8 @@ import ( "context" "strings" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) // EnableInPostgreSQL installs triggers for the following extensions into every database: diff --git a/internal/postgres/config.go b/internal/postgres/config.go index a897d6e0d2..19878459bb 100644 --- a/internal/postgres/config.go +++ b/internal/postgres/config.go @@ -11,9 +11,9 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -68,12 +68,12 @@ tdelink() ( exit 1 } fi - set -x; ln --no-dereference --force --symbolic "${keyring}" "${name}" + set -x; ln -snf "${keyring}" "${name}" ) tdeunlink() ( local name="$1" - if [[ -L "${name}" ]]; then set -x; rm --force "${name}"; fi + if [[ -L "${name}" ]]; then set -x; rm -f "${name}"; fi ) ` diff --git a/internal/postgres/config_test.go b/internal/postgres/config_test.go index 2c83b1345e..6bfd4a2bdf 100644 --- a/internal/postgres/config_test.go +++ b/internal/postgres/config_test.go @@ -19,9 +19,9 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestConfigDirectory(t *testing.T) { diff --git a/internal/postgres/databases.go b/internal/postgres/databases.go index 0129ce7ab6..7fd309c1ce 100644 --- a/internal/postgres/databases.go +++ b/internal/postgres/databases.go @@ -9,7 +9,7 @@ import ( "context" "encoding/json" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" ) // CreateDatabasesInPostgreSQL calls exec to create databases that do not exist diff --git a/internal/postgres/databases_test.go b/internal/postgres/databases_test.go index 9e4f3b11ac..24aa9cb1ee 100644 --- a/internal/postgres/databases_test.go +++ b/internal/postgres/databases_test.go @@ -13,7 +13,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) func TestCreateDatabasesInPostgreSQL(t *testing.T) { diff --git a/internal/postgres/exec_test.go b/internal/postgres/exec_test.go index 4bc31a6fcc..00890b9980 100644 --- a/internal/postgres/exec_test.go +++ b/internal/postgres/exec_test.go @@ -16,7 +16,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" ) // This example demonstrates how Executor can work with exec.Cmd. @@ -184,7 +184,7 @@ done <<< "${databases}" assert.NilError(t, os.WriteFile(file, []byte(script), 0o600)) // Expect shellcheck to be happy. - cmd := exec.Command(shellcheck, "--enable=all", file) + cmd := exec.CommandContext(context.Background(), shellcheck, "--enable=all", file) output, err := cmd.CombinedOutput() assert.NilError(t, err, "%q\n%s", cmd.Args, output) diff --git a/internal/postgres/hba_test.go b/internal/postgres/hba_test.go index 5e2900c853..1f1988c8ec 100644 --- a/internal/postgres/hba_test.go +++ b/internal/postgres/hba_test.go @@ -10,7 +10,7 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) func TestNewHBAs(t *testing.T) { diff --git a/internal/postgres/huge_pages.go b/internal/postgres/huge_pages.go index 003fa4beee..eba99af8b1 100644 --- a/internal/postgres/huge_pages.go +++ b/internal/postgres/huge_pages.go @@ -8,7 +8,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // This function looks for a valid huge_pages resource request. If it finds one, diff --git a/internal/postgres/huge_pages_test.go b/internal/postgres/huge_pages_test.go index 73b3d635c3..03b676f728 100644 --- a/internal/postgres/huge_pages_test.go +++ b/internal/postgres/huge_pages_test.go @@ -11,7 +11,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestSetHugePages(t *testing.T) { diff --git a/internal/postgres/parameters_test.go b/internal/postgres/parameters_test.go index 64538cbc12..a25e3c2ea2 100644 --- a/internal/postgres/parameters_test.go +++ b/internal/postgres/parameters_test.go @@ -21,7 +21,7 @@ func TestNewParameters(t *testing.T) { "unix_socket_directories": "/tmp/postgres", }) - assert.DeepEqual(t, parameters.Default.AsMap(), map[string]string{ + assert.DeepEqual(t, parameters.Default.AsMap(), map[string]string{ //nolint:gosec //test data "jit": "off", "password_encryption": "scram-sha-256", diff --git a/internal/postgres/password/md5.go b/internal/postgres/password/md5.go index 21afcaa2a5..c49eac9e9a 100644 --- a/internal/postgres/password/md5.go +++ b/internal/postgres/password/md5.go @@ -5,7 +5,7 @@ package password import ( - "crypto/md5" + "crypto/md5" //nolint:gosec "fmt" "github.com/pkg/errors" diff --git a/internal/postgres/password/scram_test.go b/internal/postgres/password/scram_test.go index 0552e519b7..17b61d289f 100644 --- a/internal/postgres/password/scram_test.go +++ b/internal/postgres/password/scram_test.go @@ -190,7 +190,7 @@ func TestSCRAMSASLPrep(t *testing.T) { tests := []stringStruct{ {password: "hippo", expected: "hippo"}, {password: "híppo", expected: "híppo"}, - {password: "こんにちは", expected: "こんにちは"}, + {password: "こんにちは", expected: "こんにちは"}, //nolint:gosec // test data {password: "hippo\u1680lake", expected: "hippo lake"}, {password: "hipp\ufe01o", expected: "hippo"}, {password: "hipp\u206ao", expected: "hipp\u206ao"}, diff --git a/internal/postgres/reconcile.go b/internal/postgres/reconcile.go index 82f18f514a..e468677bc3 100644 --- a/internal/postgres/reconcile.go +++ b/internal/postgres/reconcile.go @@ -10,11 +10,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var ( diff --git a/internal/postgres/reconcile_test.go b/internal/postgres/reconcile_test.go index ade4718fff..fe01a64995 100644 --- a/internal/postgres/reconcile_test.go +++ b/internal/postgres/reconcile_test.go @@ -12,11 +12,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestDataVolumeMount(t *testing.T) { diff --git a/internal/postgres/users.go b/internal/postgres/users.go index 5a097201d2..a654f57c05 100644 --- a/internal/postgres/users.go +++ b/internal/postgres/users.go @@ -13,10 +13,10 @@ import ( pg_query "github.com/pganalyze/pg_query_go/v6" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var RESERVED_SCHEMA_NAMES = map[string]bool{ diff --git a/internal/postgres/users_test.go b/internal/postgres/users_test.go index f7ae838b15..36281c022d 100644 --- a/internal/postgres/users_test.go +++ b/internal/postgres/users_test.go @@ -14,8 +14,8 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestSanitizeAlterRoleOptions(t *testing.T) { diff --git a/internal/postgres/validation.go b/internal/postgres/validation.go index 81d19033bb..d536cb9f1a 100644 --- a/internal/postgres/validation.go +++ b/internal/postgres/validation.go @@ -12,7 +12,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/record" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // truncateAt returns s truncated to n bytes, or s unchanged when len(s) <= n. diff --git a/internal/postgres/validation_test.go b/internal/postgres/validation_test.go index cbbe9cf335..76fd3fe9c7 100644 --- a/internal/postgres/validation_test.go +++ b/internal/postgres/validation_test.go @@ -10,10 +10,10 @@ import ( "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestSanitizeLogDirectory(t *testing.T) { diff --git a/internal/registration/interface.go b/internal/registration/interface.go index 75ff2e45b7..1e115abf04 100644 --- a/internal/registration/interface.go +++ b/internal/registration/interface.go @@ -14,7 +14,7 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type Registration interface { diff --git a/internal/registration/runner.go b/internal/registration/runner.go index b0e47aff52..0757d08b61 100644 --- a/internal/registration/runner.go +++ b/internal/registration/runner.go @@ -20,8 +20,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // Runner implements [Registration] by loading and validating the token at a diff --git a/internal/registration/runner_test.go b/internal/registration/runner_test.go index 1143667746..bc132edb84 100644 --- a/internal/registration/runner_test.go +++ b/internal/registration/runner_test.go @@ -23,7 +23,7 @@ import ( "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/events" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/events" ) func TestNewRunner(t *testing.T) { diff --git a/internal/setuser/postgres.go b/internal/setuser/postgres.go index 7b59a6e352..3e6132dcfb 100644 --- a/internal/setuser/postgres.go +++ b/internal/setuser/postgres.go @@ -3,8 +3,8 @@ package setuser import ( "context" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) // EnableInPostgreSQL installs set_user in every database. diff --git a/internal/setuser/postgres_test.go b/internal/setuser/postgres_test.go index deaab00a59..05c3e5b8b9 100644 --- a/internal/setuser/postgres_test.go +++ b/internal/setuser/postgres_test.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "gotest.tools/v3/assert" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" ) func TestEnableInPostgreSQL(t *testing.T) { diff --git a/internal/testing/require/exec.go b/internal/testing/require/exec.go index c182e84996..ad5ef9428f 100644 --- a/internal/testing/require/exec.go +++ b/internal/testing/require/exec.go @@ -38,7 +38,7 @@ func executable(name string, args ...string) func(testing.TB) string { t.Helper() once.Do(func() { path, err := exec.LookPath(name) - cmd := exec.Command(path, args...) // #nosec G204 -- args from init() + cmd := exec.Command(path, args...) //nolint:noctx // #nosec G204 -- args from init() if err != nil { result = func(t testing.TB) string { diff --git a/internal/testing/require/kubernetes.go b/internal/testing/require/kubernetes.go index f06a7318f3..04e58ede27 100644 --- a/internal/testing/require/kubernetes.go +++ b/internal/testing/require/kubernetes.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" ) type TestingT interface { diff --git a/internal/testing/validation/postgrescluster_test.go b/internal/testing/validation/postgrescluster_test.go index dc5353595c..081bf28010 100644 --- a/internal/testing/validation/postgrescluster_test.go +++ b/internal/testing/validation/postgrescluster_test.go @@ -14,9 +14,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPostgresUserOptions(t *testing.T) { diff --git a/internal/upgradecheck/header.go b/internal/upgradecheck/header.go index 7ba344b05e..e9060a252d 100644 --- a/internal/upgradecheck/header.go +++ b/internal/upgradecheck/header.go @@ -13,16 +13,17 @@ import ( googleuuid "github.com/google/uuid" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/client-go/discovery" "k8s.io/client-go/rest" crclient "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -150,7 +151,7 @@ func applyConfigMap(ctx context.Context, crClient crclient.Client, data, err := crclient.MergeFrom(zero).Data(object) if err == nil { - apply := crclient.RawPatch(crclient.Apply.Type(), data) + apply := crclient.RawPatch(types.ApplyPatchType, data) err = crClient.Patch(ctx, object, apply, []crclient.PatchOption{crclient.ForceOwnership, crclient.FieldOwner(owner)}...) } diff --git a/internal/upgradecheck/header_test.go b/internal/upgradecheck/header_test.go index 763071d0d8..25ad181234 100644 --- a/internal/upgradecheck/header_test.go +++ b/internal/upgradecheck/header_test.go @@ -20,12 +20,12 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "k8s.io/client-go/rest" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/require" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/require" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGenerateHeader(t *testing.T) { diff --git a/internal/upgradecheck/helpers_test.go b/internal/upgradecheck/helpers_test.go index 7cfedca07c..4d8655732e 100644 --- a/internal/upgradecheck/helpers_test.go +++ b/internal/upgradecheck/helpers_test.go @@ -20,9 +20,9 @@ import ( crclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type fakeClientWithError struct { @@ -47,8 +47,8 @@ func (f *fakeClientWithError) Get(ctx context.Context, key types.NamespacedName, func (f *fakeClientWithError) Patch(ctx context.Context, obj crclient.Object, patch crclient.Patch, opts ...crclient.PatchOption, ) error { - switch { - case f.errorType == "patch error": + switch f.errorType { + case "patch error": return errors.New("patch error") default: return f.Client.Patch(ctx, obj, patch, opts...) @@ -77,7 +77,7 @@ func setupDeploymentID(t *testing.T) string { // setupFakeClientWithPGOScheme returns a fake client with the PGO scheme added; // if `includeCluster` is true, also adds some empty PostgresCluster and CrunchyBridgeCluster // items to the client -func setupFakeClientWithPGOScheme(t *testing.T, includeCluster bool) crclient.Client { +func setupFakeClientWithPGOScheme(t *testing.T, includeCluster bool) crclient.Client { //nolint:unparam t.Helper() if includeCluster { pc := &v1beta1.PostgresClusterList{ diff --git a/internal/upgradecheck/http.go b/internal/upgradecheck/http.go index a65501cf5a..d09b4ff95d 100644 --- a/internal/upgradecheck/http.go +++ b/internal/upgradecheck/http.go @@ -17,7 +17,7 @@ import ( crclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" ) var ( @@ -72,7 +72,7 @@ func checkForUpgrades(ctx context.Context, url, versionString string, backoff wa var headerPayloadStruct *clientUpgradeData // Prep request - req, err := http.NewRequest("GET", url, nil) + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) if err == nil { // generateHeader always returns some sort of struct, using defaults/nil values // in case some of the checks return errors diff --git a/internal/upgradecheck/http_test.go b/internal/upgradecheck/http_test.go index aeea7e20c1..a2a1e24809 100644 --- a/internal/upgradecheck/http_test.go +++ b/internal/upgradecheck/http_test.go @@ -20,9 +20,9 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/testing/cmp" ) func init() { @@ -157,7 +157,7 @@ func TestCheckForUpgrades(t *testing.T) { // TODO(benjaminjb): Replace `fake` with envtest func TestCheckForUpgradesScheduler(t *testing.T) { t.Skip("This test fails when run with 'go test ./...', but passes when run on its own.") // TODO: remove - fakeClient := setupFakeClientWithPGOScheme(t, false) + fakeClient := setupFakeClientWithPGOScheme(t, true) _, server := setupVersionServer(t, true) defer server.Close() cfg := &rest.Config{Host: server.URL} diff --git a/internal/util/secrets_test.go b/internal/util/secrets_test.go index 187852bf5c..1831433621 100644 --- a/internal/util/secrets_test.go +++ b/internal/util/secrets_test.go @@ -20,7 +20,7 @@ func TestAccumulate(t *testing.T) { called := 0 result, err := accumulate(10, func() (byte, error) { called++ - return byte('A' + called), nil + return byte('A' + called), nil //nolint:gosec //test data }) assert.NilError(t, err) @@ -33,7 +33,7 @@ func TestAccumulate(t *testing.T) { result, err := accumulate(10, func() (byte, error) { called++ if called < 5 { - return byte('A' + called), nil + return byte('A' + called), nil //nolint:gosec //test data } else { return 'Z', expected } diff --git a/percona/certmanager/certmanager.go b/percona/certmanager/certmanager.go index 3d7bd3e314..4d4504aca3 100644 --- a/percona/certmanager/certmanager.go +++ b/percona/certmanager/certmanager.go @@ -20,8 +20,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type Controller interface { diff --git a/percona/certmanager/certmanager_test.go b/percona/certmanager/certmanager_test.go index 0d6469c8eb..3a985bc7c7 100644 --- a/percona/certmanager/certmanager_test.go +++ b/percona/certmanager/certmanager_test.go @@ -2,7 +2,6 @@ package certmanager import ( "context" - "fmt" "testing" "time" @@ -22,8 +21,8 @@ import ( sigs "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func setupFakeClient(t *testing.T, objs ...sigs.Object) sigs.Client { @@ -100,7 +99,7 @@ func TestCheck(t *testing.T) { cl := setupFakeClient(t) ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { - return nil, fmt.Errorf("failed to create checker") + return nil, errors.Errorf("failed to create checker") } err := ctrl.Check(t.Context(), &rest.Config{}, "default") @@ -113,7 +112,7 @@ func TestCheck(t *testing.T) { ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { return &mockChecker{ - err: fmt.Errorf(`no matches for kind "CertificateRequest" in group "cert-manager.io"`), + err: errors.Errorf(`no matches for kind "CertificateRequest" in group "cert-manager.io"`), }, nil } @@ -126,7 +125,7 @@ func TestCheck(t *testing.T) { ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { return &mockChecker{ - err: fmt.Errorf("error finding the scope of the object: failed to get restmapping: unable to retrieve the complete list of server APIs: cert-manager.io/v1: no matches for cert-manager.io/v1, Resource="), + err: errors.Errorf("error finding the scope of the object: failed to get restmapping: unable to retrieve the complete list of server APIs: cert-manager.io/v1: no matches for cert-manager.io/v1, Resource="), }, nil } @@ -139,7 +138,7 @@ func TestCheck(t *testing.T) { ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { return &mockChecker{ - err: fmt.Errorf(`Post "https://cert-manager-webhook.cert-manager.svc:443/mutate?timeout=10s": service "cert-manager-webhook" not found`), + err: errors.Errorf(`Post "https://cert-manager-webhook.cert-manager.svc:443/mutate?timeout=10s": service "cert-manager-webhook" not found`), }, nil } @@ -152,7 +151,7 @@ func TestCheck(t *testing.T) { ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { return &mockChecker{ - err: fmt.Errorf(`Post "https://cert-manager-webhook.cert-manager.svc:443/mutate?timeout=10s": dial tcp 10.96.38.90:443: connect: connection refused`), + err: errors.Errorf(`Post "https://cert-manager-webhook.cert-manager.svc:443/mutate?timeout=10s": dial tcp 10.96.38.90:443: connect: connection refused`), }, nil } @@ -165,7 +164,7 @@ func TestCheck(t *testing.T) { ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { return &mockChecker{ - err: fmt.Errorf(`Post "https://cert-manager-webhook.cert-manager.svc:443/mutate?timeout=10s": x509: certificate signed by unknown authority`), + err: errors.Errorf(`Post "https://cert-manager-webhook.cert-manager.svc:443/mutate?timeout=10s": x509: certificate signed by unknown authority`), }, nil } @@ -178,7 +177,7 @@ func TestCheck(t *testing.T) { ctrl := NewController(cl, cl.Scheme(), false).(*controller) ctrl.newChecker = func(_ *rest.Config, _ string) (cmapichecker.Interface, error) { return &mockChecker{ - err: fmt.Errorf("some unexpected error"), + err: errors.Errorf("some unexpected error"), }, nil } diff --git a/percona/certmanager/names.go b/percona/certmanager/names.go index 999e3c5c50..fe226a9bd9 100644 --- a/percona/certmanager/names.go +++ b/percona/certmanager/names.go @@ -5,8 +5,8 @@ package certmanager import ( - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // Names of the cert-manager Certificate CRs that this controller manages. diff --git a/percona/controller/pgbackup/controller.go b/percona/controller/pgbackup/controller.go index 0b2656ff86..ef24f2d446 100644 --- a/percona/controller/pgbackup/controller.go +++ b/percona/controller/pgbackup/controller.go @@ -27,18 +27,18 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/controller" - "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgbackup/snapshots" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/percona/watcher" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/controller" + "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgbackup/snapshots" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/percona/watcher" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/percona/controller/pgbackup/controller_test.go b/percona/controller/pgbackup/controller_test.go index 7c236be7f4..29ae806538 100644 --- a/percona/controller/pgbackup/controller_test.go +++ b/percona/controller/pgbackup/controller_test.go @@ -18,12 +18,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/pgbackrest" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/pgbackrest" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileFailsBackupWhenClusterIsUnavailable(t *testing.T) { diff --git a/percona/controller/pgbackup/snapshots/offline.go b/percona/controller/pgbackup/snapshots/offline.go index a435fa0b52..ee70788042 100644 --- a/percona/controller/pgbackup/snapshots/offline.go +++ b/percona/controller/pgbackup/snapshots/offline.go @@ -11,12 +11,12 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - perconaPG "github.com/percona/percona-postgresql-operator/v2/percona/postgres" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + perconaPG "github.com/percona/percona-postgresql-operator/v3/percona/postgres" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/controller/pgbackup/snapshots/reconcile.go b/percona/controller/pgbackup/snapshots/reconcile.go index b287740a72..0dea12b5d7 100644 --- a/percona/controller/pgbackup/snapshots/reconcile.go +++ b/percona/controller/pgbackup/snapshots/reconcile.go @@ -17,12 +17,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/controller/pgbackup/snapshots/reconcile_test.go b/percona/controller/pgbackup/snapshots/reconcile_test.go index c796c2ca21..777e0ea256 100644 --- a/percona/controller/pgbackup/snapshots/reconcile_test.go +++ b/percona/controller/pgbackup/snapshots/reconcile_test.go @@ -15,10 +15,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func TestShouldFailSnapshot(t *testing.T) { diff --git a/percona/controller/pgbackup/testutils_test.go b/percona/controller/pgbackup/testutils_test.go index c3851a0fa5..d7fadad447 100644 --- a/percona/controller/pgbackup/testutils_test.go +++ b/percona/controller/pgbackup/testutils_test.go @@ -11,10 +11,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type fakeClient struct { @@ -41,7 +41,7 @@ func buildFakeClient(ctx context.Context, cr *v2.PerconaPGCluster, objs ...clien } objs = append(objs, postgresCluster) - dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster)} + dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster)} //nolint:staticcheck // SA1019: matches production code dcs.Annotations = map[string]string{ "initialize": "system-identifier", } diff --git a/percona/controller/pgcluster/backup.go b/percona/controller/pgcluster/backup.go index 1e05ed2a2d..722b153384 100644 --- a/percona/controller/pgcluster/backup.go +++ b/percona/controller/pgcluster/backup.go @@ -15,13 +15,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/controller" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/pgbackrest" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/controller" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/pgbackrest" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func (r *PGClusterReconciler) reconcileBackups(ctx context.Context, cr *v2.PerconaPGCluster) error { diff --git a/percona/controller/pgcluster/backup_test.go b/percona/controller/pgcluster/backup_test.go index 45e24d885a..6c1e6e6b53 100644 --- a/percona/controller/pgcluster/backup_test.go +++ b/percona/controller/pgcluster/backup_test.go @@ -17,25 +17,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) -func compareMaps(x map[string]string, y map[string]string) bool { - if len(x) != len(y) { - return false - } - - for k, v := range x { - if y[k] != v { - return false - } - } - return true -} - func TestBackupOwnerReference(t *testing.T) { // The test is disabled, because there are problems with the fake client // diff --git a/percona/controller/pgcluster/controller.go b/percona/controller/pgcluster/controller.go index 61e483b2f4..c9dd66ef2e 100644 --- a/percona/controller/pgcluster/controller.go +++ b/percona/controller/pgcluster/controller.go @@ -2,7 +2,7 @@ package pgcluster import ( "context" - "crypto/md5" + "crypto/md5" //nolint:gosec "fmt" "io" "reflect" @@ -34,23 +34,23 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/internal/util" - perconaController "github.com/percona/percona-postgresql-operator/v2/percona/controller" - "github.com/percona/percona-postgresql-operator/v2/percona/extensions" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/percona/logcollector" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/pmm" - perconaPG "github.com/percona/percona-postgresql-operator/v2/percona/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/utils/registry" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - "github.com/percona/percona-postgresql-operator/v2/percona/watcher" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/internal/util" + perconaController "github.com/percona/percona-postgresql-operator/v3/percona/controller" + "github.com/percona/percona-postgresql-operator/v3/percona/extensions" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/percona/logcollector" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/pmm" + perconaPG "github.com/percona/percona-postgresql-operator/v3/percona/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/utils/registry" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + "github.com/percona/percona-postgresql-operator/v3/percona/watcher" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -541,9 +541,6 @@ func (r *PGClusterReconciler) reconcileTLS(ctx context.Context, cr *v2.PerconaPG if err := r.validateTLS(ctx, cr); err != nil { return errors.Wrap(err, "validate TLS") } - if err := r.reconcileOldCACert(ctx, cr); err != nil { - return errors.Wrap(err, "reconcile old CA") - } return nil } @@ -599,81 +596,6 @@ func (r *PGClusterReconciler) validateTLS(ctx context.Context, cr *v2.PerconaPGC return nil } -func (r *PGClusterReconciler) reconcileOldCACert(ctx context.Context, cr *v2.PerconaPGCluster) error { - if cr.Spec.Secrets.CustomRootCATLSSecret != nil { - return nil - } - - oldCASecret := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: naming.RootCertSecret, - Namespace: cr.Namespace, - }, - } - err := r.Client.Get(ctx, client.ObjectKeyFromObject(oldCASecret), oldCASecret) - if client.IgnoreNotFound(err) != nil { - return errors.Wrap(err, "failed to get old ca secret") - } - - if cr.CompareVersion("2.5.0") < 0 { - if k8serrors.IsNotFound(err) { - // K8SPG-555: We should create an empty secret with old name, so that crunchy part can populate it - // instead of creating secrets unique to the cluster - // TODO: remove when 2.4.0 will become unsupported - - if err := r.Client.Create(ctx, oldCASecret); err != nil { - return errors.Wrap(err, "failed to create ca secret") - } - } - return nil - } - if k8serrors.IsNotFound(err) { - return nil - } - - // K8SPG-555: Previously we used a single CA secret for all clusters in a namespace. - // We should copy the contents of the old CA secret, if it exists, to the new one, which is unique for each cluster. - // TODO: remove when 2.4.0 will become unsupported - newCASecret := &corev1.Secret{ - ObjectMeta: naming.PostgresRootCASecret( - &v1beta1.PostgresCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: cr.Name, - Namespace: cr.Namespace, - }, - }), - } - err = r.Client.Get(ctx, client.ObjectKeyFromObject(newCASecret), new(corev1.Secret)) - if client.IgnoreNotFound(err) != nil { - return errors.Wrap(err, "failed to get new ca secret") - } - - if k8serrors.IsNotFound(err) { - err := r.Client.Get(ctx, types.NamespacedName{ - Name: cr.Name, - Namespace: cr.Namespace, - }, new(v1beta1.PostgresCluster)) - if client.IgnoreNotFound(err) != nil { - return errors.Wrap(err, "failed to get crunchy cluster") - } - // If the cluster is new, we should not copy the old CA secret. - // We should create an empty secret instead, so that crunchy part can populate it. - if !k8serrors.IsNotFound(err) { - newCASecret.Data = oldCASecret.Data - } - - if cr.CompareVersion("2.6.0") >= 0 && cr.Spec.Metadata != nil { - newCASecret.Annotations = cr.Spec.Metadata.Annotations - newCASecret.Labels = cr.Spec.Metadata.Labels - } - - if err := r.Client.Create(ctx, newCASecret); err != nil { - return errors.Wrap(err, "failed to create updated CA secret") - } - } - return nil -} - // reportPMMMisconfiguration surfaces a PMM misconfiguration to the user: PMM // stays disabled, but the cluster keeps running, so the problem is reported // via a warning event and the PMMReady status condition instead of an error. diff --git a/percona/controller/pgcluster/controller_test.go b/percona/controller/pgcluster/controller_test.go index ce17f7e054..195b8cc46e 100644 --- a/percona/controller/pgcluster/controller_test.go +++ b/percona/controller/pgcluster/controller_test.go @@ -24,12 +24,12 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var _ = Describe("PG Cluster", Ordered, func() { @@ -280,7 +280,7 @@ var _ = Describe("PMM sidecar", Ordered, func() { It("should have PMM secret hash", func() { Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(&sts), &sts)).Should(Succeed()) - Expect(sts.Spec.Template.ObjectMeta.Annotations).To(HaveKey(pNaming.AnnotationPMMSecretHash)) + Expect(sts.Spec.Template.Annotations).To(HaveKey(pNaming.AnnotationPMMSecretHash)) }) It("should label PMM secret", func() { @@ -464,13 +464,13 @@ var _ = Describe("Monitor user password change", Ordered, func() { }) // tracerWithCounter is a tracer that counts the number of times the Reconcile is called. It should be used for crunchy reconciler. -type tracerWithCounter struct { +type tracerWithCounter struct { //nolint:unused noop.Tracer counter int t trace.Tracer } -func (t *tracerWithCounter) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) { +func (t *tracerWithCounter) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) { //nolint:unused ctx, span := t.t.Start(ctx, spanName, opts...) if spanName == "Reconcile" { t.counter++ diff --git a/percona/controller/pgcluster/finalizer.go b/percona/controller/pgcluster/finalizer.go index a34f8c6aad..ce162adcad 100644 --- a/percona/controller/pgcluster/finalizer.go +++ b/percona/controller/pgcluster/finalizer.go @@ -14,11 +14,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/controller" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/controller" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func (r *PGClusterReconciler) deletePVC(ctx context.Context, cr *v2.PerconaPGCluster) error { @@ -85,7 +85,6 @@ func (r *PGClusterReconciler) deleteTLSSecrets(ctx context.Context, cr *v2.Perco naming.ClusterPGBouncer(crunchyCluster), } if cr.Spec.Secrets.CustomRootCATLSSecret == nil { - secretsMeta = append(secretsMeta, metav1.ObjectMeta{Namespace: crunchyCluster.Namespace, Name: naming.RootCertSecret}) secretsMeta = append(secretsMeta, naming.PostgresRootCASecret(crunchyCluster)) } if cr.Spec.Secrets.CustomTLSSecret == nil { diff --git a/percona/controller/pgcluster/finalizer_test.go b/percona/controller/pgcluster/finalizer_test.go index 35a71f0c56..ba34b99979 100644 --- a/percona/controller/pgcluster/finalizer_test.go +++ b/percona/controller/pgcluster/finalizer_test.go @@ -19,9 +19,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var _ = Describe("Finalizers", Ordered, func() { diff --git a/percona/controller/pgcluster/gethost_test.go b/percona/controller/pgcluster/gethost_test.go index 63910566f6..331c028c96 100644 --- a/percona/controller/pgcluster/gethost_test.go +++ b/percona/controller/pgcluster/gethost_test.go @@ -12,8 +12,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGetHost(t *testing.T) { diff --git a/percona/controller/pgcluster/logicalreplica.go b/percona/controller/pgcluster/logicalreplica.go index 4fea2db840..82eace9bb1 100644 --- a/percona/controller/pgcluster/logicalreplica.go +++ b/percona/controller/pgcluster/logicalreplica.go @@ -24,19 +24,19 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/logicalreplica" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/patroni" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - perconaController "github.com/percona/percona-postgresql-operator/v2/percona/controller" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - perconaPG "github.com/percona/percona-postgresql-operator/v2/percona/postgres" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/logicalreplica" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/patroni" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + perconaController "github.com/percona/percona-postgresql-operator/v3/percona/controller" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + perconaPG "github.com/percona/percona-postgresql-operator/v3/percona/postgres" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/percona/controller/pgcluster/logicalreplica_envtest_test.go b/percona/controller/pgcluster/logicalreplica_envtest_test.go index 0581fdea36..edce007fbc 100644 --- a/percona/controller/pgcluster/logicalreplica_envtest_test.go +++ b/percona/controller/pgcluster/logicalreplica_envtest_test.go @@ -14,9 +14,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/logicalreplica" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/logicalreplica" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) var _ = Describe("Logical replicas", Ordered, func() { diff --git a/percona/controller/pgcluster/logicalreplica_restore.go b/percona/controller/pgcluster/logicalreplica_restore.go index 3ee2293f78..7ce0ff0d16 100644 --- a/percona/controller/pgcluster/logicalreplica_restore.go +++ b/percona/controller/pgcluster/logicalreplica_restore.go @@ -13,11 +13,11 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) type suspension struct { diff --git a/percona/controller/pgcluster/logicalreplica_restore_test.go b/percona/controller/pgcluster/logicalreplica_restore_test.go index 32eea09f32..954bb15662 100644 --- a/percona/controller/pgcluster/logicalreplica_restore_test.go +++ b/percona/controller/pgcluster/logicalreplica_restore_test.go @@ -20,11 +20,11 @@ import ( "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // restoreTestCluster is a cluster that uses the logical replica feature, with no diff --git a/percona/controller/pgcluster/logicalreplica_test.go b/percona/controller/pgcluster/logicalreplica_test.go index 02bec3b987..c84dceca7c 100644 --- a/percona/controller/pgcluster/logicalreplica_test.go +++ b/percona/controller/pgcluster/logicalreplica_test.go @@ -20,12 +20,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/logicalreplica" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/pgbackrest" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logicalreplica" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/pgbackrest" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func testLogicalReplicaCluster() *v2.PerconaPGCluster { diff --git a/percona/controller/pgcluster/owner_ref_migration.go b/percona/controller/pgcluster/owner_ref_migration.go index ce7e388d44..5357046c8c 100644 --- a/percona/controller/pgcluster/owner_ref_migration.go +++ b/percona/controller/pgcluster/owner_ref_migration.go @@ -11,11 +11,11 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" "github.com/pkg/errors" ) diff --git a/percona/controller/pgcluster/patroniversion.go b/percona/controller/pgcluster/patroniversion.go index 9b346797ee..2be434299b 100644 --- a/percona/controller/pgcluster/patroniversion.go +++ b/percona/controller/pgcluster/patroniversion.go @@ -19,12 +19,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/initialize" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/clientcmd" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/initialize" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/clientcmd" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func (r *PGClusterReconciler) reconcilePatroniVersionFromCluster(ctx context.Context, cr *v2.PerconaPGCluster) error { diff --git a/percona/controller/pgcluster/patroniversion_distribution_test.go b/percona/controller/pgcluster/patroniversion_distribution_test.go index f77eb9411d..3666bdf31f 100644 --- a/percona/controller/pgcluster/patroniversion_distribution_test.go +++ b/percona/controller/pgcluster/patroniversion_distribution_test.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func TestGetPostgresDistribution(t *testing.T) { diff --git a/percona/controller/pgcluster/patroniversion_test.go b/percona/controller/pgcluster/patroniversion_test.go index 34cc03c920..2e92701974 100644 --- a/percona/controller/pgcluster/patroniversion_test.go +++ b/percona/controller/pgcluster/patroniversion_test.go @@ -10,8 +10,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) var _ = Describe("patroni version check", Ordered, func() { diff --git a/percona/controller/pgcluster/pvc.go b/percona/controller/pgcluster/pvc.go index 0d8f505edf..ad0c32993d 100644 --- a/percona/controller/pgcluster/pvc.go +++ b/percona/controller/pgcluster/pvc.go @@ -10,9 +10,9 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func (r *PGClusterReconciler) reconcilePVCs(ctx context.Context, cr *v2.PerconaPGCluster) error { diff --git a/percona/controller/pgcluster/restore.go b/percona/controller/pgcluster/restore.go index 2a3d7fd11e..dec83eb893 100644 --- a/percona/controller/pgcluster/restore.go +++ b/percona/controller/pgcluster/restore.go @@ -6,9 +6,9 @@ import ( k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) // createBootstrapRestoreObject creates a PerconaPGRestore object for the bootstrap restore diff --git a/percona/controller/pgcluster/schedule.go b/percona/controller/pgcluster/schedule.go index 38f0d2beab..d767f05c31 100644 --- a/percona/controller/pgcluster/schedule.go +++ b/percona/controller/pgcluster/schedule.go @@ -11,13 +11,13 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func (r *PGClusterReconciler) reconcileScheduledBackups(ctx context.Context, cr *v2.PerconaPGCluster) error { diff --git a/percona/controller/pgcluster/secret.go b/percona/controller/pgcluster/secret.go index ae1b483e75..fb8191d60b 100644 --- a/percona/controller/pgcluster/secret.go +++ b/percona/controller/pgcluster/secret.go @@ -10,7 +10,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func getEnvFromSecrets(ctx context.Context, cl client.Client, cr *v2.PerconaPGCluster, envFromSource []corev1.EnvFromSource) ([]corev1.Secret, error) { @@ -32,7 +32,7 @@ func getSecretHash(secrets ...corev1.Secret) string { var data strings.Builder for _, secret := range secrets { - data.WriteString(fmt.Sprintln(secret.Data)) + fmt.Fprintln(&data, secret.Data) } return fmt.Sprintf("%x", md5.Sum([]byte(data.String()))) //nolint:gosec diff --git a/percona/controller/pgcluster/standby.go b/percona/controller/pgcluster/standby.go index e24133d9e3..afd3462126 100644 --- a/percona/controller/pgcluster/standby.go +++ b/percona/controller/pgcluster/standby.go @@ -15,13 +15,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - perconaPG "github.com/percona/percona-postgresql-operator/v2/percona/postgres" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + perconaPG "github.com/percona/percona-postgresql-operator/v3/percona/postgres" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( diff --git a/percona/controller/pgcluster/standby_test.go b/percona/controller/pgcluster/standby_test.go index f56a922787..ddfadde920 100644 --- a/percona/controller/pgcluster/standby_test.go +++ b/percona/controller/pgcluster/standby_test.go @@ -16,9 +16,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileStandbyLag(t *testing.T) { diff --git a/percona/controller/pgcluster/status.go b/percona/controller/pgcluster/status.go index e39584fc10..7eb93493fe 100644 --- a/percona/controller/pgcluster/status.go +++ b/percona/controller/pgcluster/status.go @@ -12,12 +12,12 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/retry" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func (r *PGClusterReconciler) getHost(ctx context.Context, cr *v2.PerconaPGCluster) (string, error) { diff --git a/percona/controller/pgcluster/status_test.go b/percona/controller/pgcluster/status_test.go index e032346b86..d3fac7da29 100644 --- a/percona/controller/pgcluster/status_test.go +++ b/percona/controller/pgcluster/status_test.go @@ -19,10 +19,10 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var _ = Describe("PG Cluster status", Ordered, func() { diff --git a/percona/controller/pgcluster/suite_test.go b/percona/controller/pgcluster/suite_test.go index b5d7a53a9e..33c6c6fe5e 100644 --- a/percona/controller/pgcluster/suite_test.go +++ b/percona/controller/pgcluster/suite_test.go @@ -19,8 +19,8 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to diff --git a/percona/controller/pgcluster/testutils_test.go b/percona/controller/pgcluster/testutils_test.go index e4eed392af..6d148d8b54 100644 --- a/percona/controller/pgcluster/testutils_test.go +++ b/percona/controller/pgcluster/testutils_test.go @@ -18,15 +18,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/postgrescluster" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/certmanager" - "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgbackup" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/utils/registry" - "github.com/percona/percona-postgresql-operator/v2/percona/watcher" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/postgrescluster" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/certmanager" + "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgbackup" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/utils/registry" + "github.com/percona/percona-postgresql-operator/v3/percona/watcher" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var k8sClient client.Client @@ -153,23 +153,6 @@ func readDefaultOperator(name, namespace string) (*appsv1.Deployment, error) { return cr, nil } -func readDefaultBackup(name, namespace string) (*v2.PerconaPGBackup, error) { - data, err := os.ReadFile(filepath.Join("..", "..", "..", "deploy", "backup.yaml")) - if err != nil { - return nil, err - } - - bcp := &v2.PerconaPGBackup{} - - if err := yaml.Unmarshal(data, bcp); err != nil { - return nil, err - } - - bcp.Name = name - bcp.Namespace = namespace - return bcp, nil -} - type fakeClient struct { client.Client } @@ -181,7 +164,7 @@ func (f *fakeClient) Patch(ctx context.Context, obj client.Object, patch client. if !k8serrors.IsNotFound(err) { return err } - if err := f.Client.Create(ctx, obj); err != nil { + if err := f.Create(ctx, obj); err != nil { return err } return f.Client.Patch(ctx, obj, patch, options...) @@ -205,7 +188,7 @@ func buildFakeClient(ctx context.Context, cr *v2.PerconaPGCluster, objs ...clien } objs = append(objs, postgresCluster) - dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster)} + dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster)} //nolint:staticcheck // SA1019: matches production code dcs.Annotations = map[string]string{ "initialize": "system-identifier", } diff --git a/percona/controller/pgcluster/unmanaged_test.go b/percona/controller/pgcluster/unmanaged_test.go index 860a88a3d8..79bac1a70b 100644 --- a/percona/controller/pgcluster/unmanaged_test.go +++ b/percona/controller/pgcluster/unmanaged_test.go @@ -12,8 +12,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/percona/utils/registry" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/percona/utils/registry" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileSkipsUnmanagedCluster(t *testing.T) { diff --git a/percona/controller/pgcluster/version.go b/percona/controller/pgcluster/version.go index 3f83c42712..78b2d9fb08 100644 --- a/percona/controller/pgcluster/version.go +++ b/percona/controller/pgcluster/version.go @@ -11,11 +11,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/percona/extensions" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/percona/extensions" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func (r *PGClusterReconciler) reconcileVersion(ctx context.Context, cr *v2.PerconaPGCluster) error { diff --git a/percona/controller/pgcluster/version_test.go b/percona/controller/pgcluster/version_test.go index dd401dd26c..f7dc5652e7 100644 --- a/percona/controller/pgcluster/version_test.go +++ b/percona/controller/pgcluster/version_test.go @@ -24,8 +24,8 @@ import ( "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) var _ = Describe("Ensure Version", Ordered, func() { @@ -227,7 +227,7 @@ func (vs *fakeVS) Start(t *testing.T) error { Handler: gwmux, ReadHeaderTimeout: time.Second * 10, } - gwLis, err := net.Listen("tcp", gwServer.Addr) + gwLis, err := new(net.ListenConfig).Listen(context.Background(), "tcp", gwServer.Addr) if err != nil { return errors.Wrap(err, "failed to listen gateway") } diff --git a/percona/controller/pgrestore/controller.go b/percona/controller/pgrestore/controller.go index 937b6533e8..de75f1ced6 100644 --- a/percona/controller/pgrestore/controller.go +++ b/percona/controller/pgrestore/controller.go @@ -17,13 +17,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/percona/controller" - "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgrestore/snapshot" - restoreutils "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgrestore/utils" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/percona/controller" + "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgrestore/snapshot" + restoreutils "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgrestore/utils" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/controller/pgrestore/controller_test.go b/percona/controller/pgrestore/controller_test.go index a4ceffc2af..ff12731e39 100644 --- a/percona/controller/pgrestore/controller_test.go +++ b/percona/controller/pgrestore/controller_test.go @@ -17,10 +17,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileSkipsUnmanagedCluster(t *testing.T) { diff --git a/percona/controller/pgrestore/snapshot/reconcile.go b/percona/controller/pgrestore/snapshot/reconcile.go index 451740cd64..46aae3ffe7 100644 --- a/percona/controller/pgrestore/snapshot/reconcile.go +++ b/percona/controller/pgrestore/snapshot/reconcile.go @@ -23,16 +23,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/controller" - restoreutils "github.com/percona/percona-postgresql-operator/v2/percona/controller/pgrestore/utils" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - perconaPG "github.com/percona/percona-postgresql-operator/v2/percona/postgres" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/controller" + restoreutils "github.com/percona/percona-postgresql-operator/v3/percona/controller/pgrestore/utils" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + perconaPG "github.com/percona/percona-postgresql-operator/v3/percona/postgres" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type snapshotRestorer struct { diff --git a/percona/controller/pgrestore/snapshot/reconcile_test.go b/percona/controller/pgrestore/snapshot/reconcile_test.go index 471269611a..3d32f207ed 100644 --- a/percona/controller/pgrestore/snapshot/reconcile_test.go +++ b/percona/controller/pgrestore/snapshot/reconcile_test.go @@ -21,12 +21,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestGeneratePrepareJob(t *testing.T) { diff --git a/percona/controller/pgrestore/utils/pgbackrest.go b/percona/controller/pgrestore/utils/pgbackrest.go index 527904f64f..340353c2bc 100644 --- a/percona/controller/pgrestore/utils/pgbackrest.go +++ b/percona/controller/pgrestore/utils/pgbackrest.go @@ -8,9 +8,9 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type PGBackRestRestore struct { diff --git a/percona/controller/pgrestore/utils/pgbackrest_test.go b/percona/controller/pgrestore/utils/pgbackrest_test.go index ed5edb78d6..33f51bb601 100644 --- a/percona/controller/pgrestore/utils/pgbackrest_test.go +++ b/percona/controller/pgrestore/utils/pgbackrest_test.go @@ -11,8 +11,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPGBackRestRestoreStartTolerations(t *testing.T) { diff --git a/percona/controller/pgupgrade/controller.go b/percona/controller/pgupgrade/controller.go index 042a5803a4..3adc237b2c 100644 --- a/percona/controller/pgupgrade/controller.go +++ b/percona/controller/pgupgrade/controller.go @@ -18,10 +18,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/percona/extensions" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/percona/extensions" + pgv3 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const ( @@ -36,7 +36,7 @@ type PGUpgradeReconciler struct { // SetupWithManager adds the PerconaPerconaPGUpgrade controller to the provided runtime manager func (r *PGUpgradeReconciler) SetupWithManager(mgr manager.Manager) error { - return builder.ControllerManagedBy(mgr).For(&pgv2.PerconaPGUpgrade{}).Complete(r) + return builder.ControllerManagedBy(mgr).For(&pgv3.PerconaPGUpgrade{}).Complete(r) } // +kubebuilder:rbac:groups=pgv2.percona.com,resources=perconapgupgrades,verbs=get;list;create;update;patch;watch @@ -51,7 +51,7 @@ var errLegacyUpgradeFinalized = errors.New("legacy upgrade is already finished") func (r *PGUpgradeReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { log := logging.FromContext(ctx).WithValues("request", request) - perconaPGUpgrade := &pgv2.PerconaPGUpgrade{} + perconaPGUpgrade := &pgv3.PerconaPGUpgrade{} if err := r.Client.Get(ctx, request.NamespacedName, perconaPGUpgrade); err != nil { // NotFound cannot be fixed by requeuing so ignore it. During background // deletion, we receive delete events from cluster's dependents after @@ -70,7 +70,7 @@ func (r *PGUpgradeReconciler) Reconcile(ctx context.Context, request reconcile.R return reconcile.Result{}, errors.Wrap(err, "check legacy upgrade") } - pgCluster := &pgv2.PerconaPGCluster{ + pgCluster := &pgv3.PerconaPGCluster{ ObjectMeta: metav1.ObjectMeta{ Name: perconaPGUpgrade.Spec.PostgresClusterName, Namespace: perconaPGUpgrade.Namespace, @@ -166,7 +166,7 @@ func (r *PGUpgradeReconciler) Reconcile(ctx context.Context, request reconcile.R return reconcile.Result{}, nil } -func (r *PGUpgradeReconciler) createPGUpgrade(ctx context.Context, cluster *pgv2.PerconaPGCluster, pgUpgrade *crunchyv1beta1.PGUpgrade, perconaPGUpgrade *pgv2.PerconaPGUpgrade) error { +func (r *PGUpgradeReconciler) createPGUpgrade(ctx context.Context, cluster *pgv3.PerconaPGCluster, pgUpgrade *crunchyv1beta1.PGUpgrade, perconaPGUpgrade *pgv3.PerconaPGUpgrade) error { pgUpgrade.Spec.Metadata = perconaPGUpgrade.Spec.Metadata pgUpgrade.Spec.PostgresClusterName = perconaPGUpgrade.Spec.PostgresClusterName @@ -217,7 +217,7 @@ func (r *PGUpgradeReconciler) createPGUpgrade(ctx context.Context, cluster *pgv2 return r.Client.Create(ctx, pgUpgrade) } -func (r *PGUpgradeReconciler) pauseCluster(ctx context.Context, pgCluster *pgv2.PerconaPGCluster) error { +func (r *PGUpgradeReconciler) pauseCluster(ctx context.Context, pgCluster *pgv3.PerconaPGCluster) error { orig := pgCluster.DeepCopy() t := true @@ -226,7 +226,7 @@ func (r *PGUpgradeReconciler) pauseCluster(ctx context.Context, pgCluster *pgv2. return r.Client.Patch(ctx, pgCluster.DeepCopy(), client.MergeFrom(orig)) } -func (r *PGUpgradeReconciler) resumeCluster(ctx context.Context, pgCluster *pgv2.PerconaPGCluster) error { +func (r *PGUpgradeReconciler) resumeCluster(ctx context.Context, pgCluster *pgv3.PerconaPGCluster) error { orig := pgCluster.DeepCopy() pgCluster.Spec.Pause = nil @@ -234,24 +234,24 @@ func (r *PGUpgradeReconciler) resumeCluster(ctx context.Context, pgCluster *pgv2 return r.Client.Patch(ctx, pgCluster.DeepCopy(), client.MergeFrom(orig)) } -func (r *PGUpgradeReconciler) annotateCluster(ctx context.Context, pgCluster *pgv2.PerconaPGCluster, pgUpgrade *pgv2.PerconaPGUpgrade) error { +func (r *PGUpgradeReconciler) annotateCluster(ctx context.Context, pgCluster *pgv3.PerconaPGCluster, pgUpgrade *pgv3.PerconaPGUpgrade) error { orig := pgCluster.DeepCopy() if pgCluster.Annotations == nil { pgCluster.Annotations = make(map[string]string) } - pgCluster.Annotations[pgv2.AnnotationAllowUpgrade] = pgUpgrade.Name + pgCluster.Annotations[pgv3.AnnotationAllowUpgrade] = pgUpgrade.Name return r.Client.Patch(ctx, pgCluster.DeepCopy(), client.MergeFrom(orig)) } -func (r *PGUpgradeReconciler) finalizeUpgrade(ctx context.Context, pgCluster *pgv2.PerconaPGCluster, pgUpgrade *pgv2.PerconaPGUpgrade) error { +func (r *PGUpgradeReconciler) finalizeUpgrade(ctx context.Context, pgCluster *pgv3.PerconaPGCluster, pgUpgrade *pgv3.PerconaPGUpgrade) error { log := logging.FromContext(ctx) orig := pgCluster.DeepCopy() - delete(pgCluster.Annotations, pgv2.AnnotationAllowUpgrade) + delete(pgCluster.Annotations, pgv3.AnnotationAllowUpgrade) pgCluster.Spec.PostgresVersion = pgUpgrade.Spec.ToPostgresVersion pgCluster.Spec.Image = pgUpgrade.Spec.ToPostgresImage diff --git a/percona/controller/pgupgrade/controller_test.go b/percona/controller/pgupgrade/controller_test.go index f28c0aaa20..7138a00f5f 100644 --- a/percona/controller/pgupgrade/controller_test.go +++ b/percona/controller/pgupgrade/controller_test.go @@ -12,8 +12,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + pgv2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileSkipsUnmanagedCluster(t *testing.T) { diff --git a/percona/controller/utils.go b/percona/controller/utils.go index d355db10ce..09f0cfcdd0 100644 --- a/percona/controller/utils.go +++ b/percona/controller/utils.go @@ -14,9 +14,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" ) // jobCompleted returns "true" if the Job provided completed successfully. Otherwise it returns diff --git a/percona/controller/utils_test.go b/percona/controller/utils_test.go index 099e6a138f..39690e27d6 100644 --- a/percona/controller/utils_test.go +++ b/percona/controller/utils_test.go @@ -10,7 +10,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" ) func TestGetReadyInstancePod(t *testing.T) { diff --git a/percona/extensions/containers.go b/percona/extensions/containers.go index 7ca5b5a9cb..222c3732b5 100644 --- a/percona/extensions/containers.go +++ b/percona/extensions/containers.go @@ -6,8 +6,8 @@ import ( corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/percona/naming" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/percona/naming" + pgv3 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func GetExtensionKey(pgMajor int, name, version string) string { @@ -16,7 +16,7 @@ func GetExtensionKey(pgMajor int, name, version string) string { // RelocatorContainer returns a container that will relocate extensions from the base image (i.e. pg_stat_monitor, pg_audit) // to the data directory so we don't lose them when user adds a custom extension. -func RelocatorContainer(cr *pgv2.PerconaPGCluster, image string, imagePullPolicy corev1.PullPolicy, postgresVersion int) corev1.Container { +func RelocatorContainer(cr *pgv3.PerconaPGCluster, image string, imagePullPolicy corev1.PullPolicy, postgresVersion int) corev1.Container { mounts := []corev1.VolumeMount{ { Name: "postgres-data", @@ -49,7 +49,7 @@ func RelocatorContainer(cr *pgv2.PerconaPGCluster, image string, imagePullPolicy } } -func InstallerContainer(cr *pgv2.PerconaPGCluster, postgresVersion int, spec *pgv2.ExtensionsSpec, extensions string, openshift *bool) corev1.Container { +func InstallerContainer(cr *pgv3.PerconaPGCluster, postgresVersion int, spec *pgv3.ExtensionsSpec, extensions string, openshift *bool) corev1.Container { mounts := []corev1.VolumeMount{ { Name: "postgres-data", diff --git a/percona/extensions/s3.go b/percona/extensions/s3.go index 4c1d4ed376..31dd83ad48 100644 --- a/percona/extensions/s3.go +++ b/percona/extensions/s3.go @@ -3,9 +3,9 @@ package extensions import ( "io" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/s3" + "github.com/aws/aws-sdk-go/aws" //nolint:staticcheck //TODO:https://perconadev.atlassian.net/browse/K8SPG-1098 + "github.com/aws/aws-sdk-go/aws/session" //nolint:staticcheck + "github.com/aws/aws-sdk-go/service/s3" //nolint:staticcheck ) type S3 struct { diff --git a/percona/k8s/backup.go b/percona/k8s/backup.go index e77fec939b..4573df237b 100644 --- a/percona/k8s/backup.go +++ b/percona/k8s/backup.go @@ -9,7 +9,7 @@ import ( "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + pgv2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) var ( diff --git a/percona/k8s/testutils_test.go b/percona/k8s/testutils_test.go index 33d72bb51a..452da56fad 100644 --- a/percona/k8s/testutils_test.go +++ b/percona/k8s/testutils_test.go @@ -13,10 +13,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type fakeClient struct { @@ -54,7 +54,7 @@ func buildFakeClient(ctx context.Context, cr *v2.PerconaPGCluster, objs ...clien } objs = append(objs, postgresCluster) - dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster)} + dcs := &corev1.Endpoints{ObjectMeta: naming.PatroniDistributedConfiguration(postgresCluster)} //nolint:staticcheck // SA1019: production code still uses corev1.Endpoints for Patroni DCS dcs.Annotations = map[string]string{ "initialize": "system-identifier", } diff --git a/percona/k8s/util.go b/percona/k8s/util.go index 8c6d0d2ffc..e5045c4551 100644 --- a/percona/k8s/util.go +++ b/percona/k8s/util.go @@ -17,9 +17,9 @@ import ( "k8s.io/client-go/discovery" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) const WatchNamespaceEnvVar = "WATCH_NAMESPACE" diff --git a/percona/k8s/util_test.go b/percona/k8s/util_test.go index 0a2989a35b..529a550244 100644 --- a/percona/k8s/util_test.go +++ b/percona/k8s/util_test.go @@ -11,7 +11,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type testGetCluster func() *v1beta1.PostgresCluster diff --git a/percona/logcollector/logcollector.go b/percona/logcollector/logcollector.go index c607ab7ebe..2acfb84d61 100644 --- a/percona/logcollector/logcollector.go +++ b/percona/logcollector/logcollector.go @@ -6,11 +6,11 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/logcollector/logrotate" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/logcollector/logrotate" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/logcollector/logcollector_test.go b/percona/logcollector/logcollector_test.go index 7edb656dcb..1bca7a6ca1 100644 --- a/percona/logcollector/logcollector_test.go +++ b/percona/logcollector/logcollector_test.go @@ -9,13 +9,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - "github.com/percona/percona-postgresql-operator/v2/percona/logcollector/logrotate" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + "github.com/percona/percona-postgresql-operator/v3/percona/logcollector/logrotate" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) type builderFn func(cr *v2.PerconaPGCluster) ([]corev1.Container, error) diff --git a/percona/logcollector/logrotate/logrotate.go b/percona/logcollector/logrotate/logrotate.go index 606acc30bc..479605d256 100644 --- a/percona/logcollector/logrotate/logrotate.go +++ b/percona/logcollector/logrotate/logrotate.go @@ -4,8 +4,8 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/logcollector/reconcile.go b/percona/logcollector/reconcile.go index b866082a4a..6330568f1c 100644 --- a/percona/logcollector/reconcile.go +++ b/percona/logcollector/reconcile.go @@ -15,11 +15,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/logcollector/logrotate" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/logcollector/logrotate" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) // Reconcile wires the log collector sidecars, volumes, and backing ConfigMaps for the given cluster. diff --git a/percona/logcollector/reconcile_test.go b/percona/logcollector/reconcile_test.go index 1063b3bae6..af5ee8611a 100644 --- a/percona/logcollector/reconcile_test.go +++ b/percona/logcollector/reconcile_test.go @@ -13,12 +13,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/logcollector/logrotate" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/logcollector/logrotate" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestReconcileLogRotate(t *testing.T) { diff --git a/percona/pgbackrest/pgbackrest.go b/percona/pgbackrest/pgbackrest.go index fec4cbd6bb..b3a50d1fd7 100644 --- a/percona/pgbackrest/pgbackrest.go +++ b/percona/pgbackrest/pgbackrest.go @@ -10,9 +10,9 @@ import ( "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/clientcmd" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/clientcmd" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) type InfoOutput []InfoStanza diff --git a/percona/pmm/pmm.go b/percona/pmm/pmm.go index 190e6d82ab..167837d9ba 100644 --- a/percona/pmm/pmm.go +++ b/percona/pmm/pmm.go @@ -8,8 +8,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" - "github.com/percona/percona-postgresql-operator/v2/internal/postgres" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/postgres" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/pmm/pmm_test.go b/percona/pmm/pmm_test.go index 51def6d6b2..12e6c59420 100644 --- a/percona/pmm/pmm_test.go +++ b/percona/pmm/pmm_test.go @@ -10,8 +10,8 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func TestContainer(t *testing.T) { diff --git a/percona/postgres/common.go b/percona/postgres/common.go index da6cba7371..370e42586a 100644 --- a/percona/postgres/common.go +++ b/percona/postgres/common.go @@ -11,9 +11,9 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/postgres/common_test.go b/percona/postgres/common_test.go index 8570e9d41a..85cfc562d1 100644 --- a/percona/postgres/common_test.go +++ b/percona/postgres/common_test.go @@ -10,9 +10,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + v2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) func TestGetPrimaryPod(t *testing.T) { diff --git a/percona/runtime/runtime.go b/percona/runtime/runtime.go index 0041172ad3..81965b64e8 100644 --- a/percona/runtime/runtime.go +++ b/percona/runtime/runtime.go @@ -11,9 +11,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - r "github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/feature" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" + r "github.com/percona/percona-postgresql-operator/v3/internal/controller/runtime" + "github.com/percona/percona-postgresql-operator/v3/internal/feature" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" ) // default refresh interval in minutes diff --git a/percona/testutils/client.go b/percona/testutils/client.go index f523333325..0c82ba9f42 100644 --- a/percona/testutils/client.go +++ b/percona/testutils/client.go @@ -5,22 +5,22 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + pgv3 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func BuildFakeClient(initObjs ...client.Object) client.Client { scheme := runtime.NewScheme() perconaTypes := []runtime.Object{ - new(pgv2.PerconaPGCluster), - new(pgv2.PerconaPGClusterList), - new(pgv2.PerconaPGBackup), - new(pgv2.PerconaPGBackupList), - new(pgv2.PerconaPGRestore), - new(pgv2.PerconaPGRestoreList), - new(pgv2.PerconaPGUpgrade), - new(pgv2.PerconaPGUpgradeList), + new(pgv3.PerconaPGCluster), + new(pgv3.PerconaPGClusterList), + new(pgv3.PerconaPGBackup), + new(pgv3.PerconaPGBackupList), + new(pgv3.PerconaPGRestore), + new(pgv3.PerconaPGRestoreList), + new(pgv3.PerconaPGUpgrade), + new(pgv3.PerconaPGUpgradeList), } crunchyTypes := []runtime.Object{ @@ -30,12 +30,12 @@ func BuildFakeClient(initObjs ...client.Object) client.Client { new(crunchyv1beta1.PGUpgradeList), } - scheme.AddKnownTypes(pgv2.GroupVersion, perconaTypes...) + scheme.AddKnownTypes(pgv3.GroupVersion, perconaTypes...) scheme.AddKnownTypes(crunchyv1beta1.GroupVersion, crunchyTypes...) return fake.NewClientBuilder(). WithScheme(scheme). WithObjects(initObjs...). - WithIndex(new(pgv2.PerconaPGBackup), pgv2.IndexFieldPGCluster, pgv2.PGClusterIndexerFunc). + WithIndex(new(pgv3.PerconaPGBackup), pgv3.IndexFieldPGCluster, pgv3.PGClusterIndexerFunc). Build() } diff --git a/percona/version/service/client/api_version_proto_client.go b/percona/version/service/client/api_version_proto_client.go index 5b524bd421..b22a9a26f5 100644 --- a/percona/version/service/client/api_version_proto_client.go +++ b/percona/version/service/client/api_version_proto_client.go @@ -10,7 +10,7 @@ import ( httptransport "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/percona/percona-postgresql-operator/v2/percona/version/service/client/version_service" + "github.com/percona/percona-postgresql-operator/v3/percona/version/service/client/version_service" ) // Default API version proto HTTP client. diff --git a/percona/version/service/client/version_service/version_service_apply_responses.go b/percona/version/service/client/version_service/version_service_apply_responses.go index 5a19d36520..6edcdb694a 100644 --- a/percona/version/service/client/version_service/version_service_apply_responses.go +++ b/percona/version/service/client/version_service/version_service_apply_responses.go @@ -12,7 +12,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/percona/percona-postgresql-operator/v2/percona/version/service/client/models" + "github.com/percona/percona-postgresql-operator/v3/percona/version/service/client/models" ) // VersionServiceApplyReader is a Reader for the VersionServiceApply structure. diff --git a/percona/version/service/client/version_service/version_service_operator_responses.go b/percona/version/service/client/version_service/version_service_operator_responses.go index 5625dae723..f99913f9de 100644 --- a/percona/version/service/client/version_service/version_service_operator_responses.go +++ b/percona/version/service/client/version_service/version_service_operator_responses.go @@ -12,7 +12,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/percona/percona-postgresql-operator/v2/percona/version/service/client/models" + "github.com/percona/percona-postgresql-operator/v3/percona/version/service/client/models" ) // VersionServiceOperatorReader is a Reader for the VersionServiceOperator structure. diff --git a/percona/version/service/client/version_service/version_service_product_responses.go b/percona/version/service/client/version_service/version_service_product_responses.go index 8bd92d59d8..35a7481578 100644 --- a/percona/version/service/client/version_service/version_service_product_responses.go +++ b/percona/version/service/client/version_service/version_service_product_responses.go @@ -12,7 +12,7 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/percona/percona-postgresql-operator/v2/percona/version/service/client/models" + "github.com/percona/percona-postgresql-operator/v3/percona/version/service/client/models" ) // VersionServiceProductReader is a Reader for the VersionServiceProduct structure. diff --git a/percona/version/version.go b/percona/version/version.go index 0b6a968abd..bd8903a103 100644 --- a/percona/version/version.go +++ b/percona/version/version.go @@ -12,8 +12,8 @@ import ( "github.com/pkg/errors" - "github.com/percona/percona-postgresql-operator/v2/percona/version/service/client" - "github.com/percona/percona-postgresql-operator/v2/percona/version/service/client/version_service" + "github.com/percona/percona-postgresql-operator/v3/percona/version/service/client" + "github.com/percona/percona-postgresql-operator/v3/percona/version/service/client/version_service" ) //go:generate sh -c "yq -i '.metadata.labels.\"pgv2.percona.com/version\" = \"v\" + load(\"version.txt\")' ../../config/crd/patches/versionlabel_in_perconapgclusters.yaml" diff --git a/percona/version/version_test.go b/percona/version/version_test.go index c2edd5f6e5..1e15e5713c 100644 --- a/percona/version/version_test.go +++ b/percona/version/version_test.go @@ -11,8 +11,8 @@ import ( "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "sigs.k8s.io/yaml" - "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" + "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" ) func TestCRDVersionLabel(t *testing.T) { diff --git a/percona/watcher/wal.go b/percona/watcher/wal.go index c7693fdf7c..867628d113 100644 --- a/percona/watcher/wal.go +++ b/percona/watcher/wal.go @@ -12,12 +12,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/percona/clientcmd" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/percona/pgbackrest" - perconaPG "github.com/percona/percona-postgresql-operator/v2/percona/postgres" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/percona/clientcmd" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/percona/pgbackrest" + perconaPG "github.com/percona/percona-postgresql-operator/v3/percona/postgres" + pgv2 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) const ( diff --git a/percona/watcher/wal_test.go b/percona/watcher/wal_test.go index 57df9997f4..ccc49b0c62 100644 --- a/percona/watcher/wal_test.go +++ b/percona/watcher/wal_test.go @@ -11,13 +11,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/percona/percona-postgresql-operator/v2/percona/k8s" - "github.com/percona/percona-postgresql-operator/v2/percona/testutils" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - pgv2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2" + "github.com/percona/percona-postgresql-operator/v3/percona/k8s" + "github.com/percona/percona-postgresql-operator/v3/percona/testutils" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + pgv3 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/pgv2.percona.com/v2" ) -func mustParseTime(layout string, value string) time.Time { +func mustParseTime(layout string, value string) time.Time { //nolint:unparam time, err := time.Parse(layout, value) if err != nil { panic(err) @@ -41,7 +41,7 @@ func TestGetLatestBackup(t *testing.T) { { name: "single backup", backups: []client.Object{ - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", @@ -49,11 +49,11 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T21:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T21:23:38Z"), }, @@ -66,7 +66,7 @@ func TestGetLatestBackup(t *testing.T) { { name: "multiple backups, same cluster", backups: []client.Object{ - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", @@ -74,17 +74,17 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T21:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T21:23:38Z"), }, }, }, - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup2", Namespace: "test-ns", @@ -92,11 +92,11 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T22:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T22:24:12Z"), }, @@ -109,7 +109,7 @@ func TestGetLatestBackup(t *testing.T) { { name: "multiple backups, different clusters", backups: []client.Object{ - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", @@ -117,17 +117,17 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T21:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T21:23:38Z"), }, }, }, - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup2", Namespace: "test-ns", @@ -135,17 +135,17 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T22:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T22:24:12Z"), }, }, }, - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup-from-different-cluster", Namespace: "test-ns", @@ -153,11 +153,11 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T22:10:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "different-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T22:14:12Z"), }, @@ -170,7 +170,7 @@ func TestGetLatestBackup(t *testing.T) { { name: "single running backup", backups: []client.Object{ - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", @@ -178,11 +178,11 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T21:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupRunning, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupRunning, }, }, }, @@ -192,7 +192,7 @@ func TestGetLatestBackup(t *testing.T) { { name: "running backup but a backup is already succeeded", backups: []client.Object{ - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", @@ -200,17 +200,17 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T21:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T21:23:38Z"), }, }, }, - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup2", Namespace: "test-ns", @@ -218,11 +218,11 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T22:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupRunning, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupRunning, }, }, }, @@ -232,7 +232,7 @@ func TestGetLatestBackup(t *testing.T) { { name: "K8SPG-772: multiple backups, some has no CompletedAt", backups: []client.Object{ - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", @@ -240,17 +240,17 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T21:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T21:24:12Z"), }, }, }, - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup2", Namespace: "test-ns", @@ -258,14 +258,14 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T22:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, }, }, - &pgv2.PerconaPGBackup{ + &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup3", Namespace: "test-ns", @@ -273,11 +273,11 @@ func TestGetLatestBackup(t *testing.T) { Time: mustParseTime(time.RFC3339, "2024-02-04T23:00:57Z"), }, }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", }, - Status: pgv2.PerconaPGBackupStatus{ - State: pgv2.BackupSucceeded, + Status: pgv3.PerconaPGBackupStatus{ + State: pgv3.BackupSucceeded, CompletedAt: &metav1.Time{ Time: mustParseTime(time.RFC3339, "2024-02-04T23:24:12Z"), }, @@ -294,7 +294,7 @@ func TestGetLatestBackup(t *testing.T) { t.Run(tt.name, func(t *testing.T) { client := testutils.BuildFakeClient(tt.backups...) - cluster := &pgv2.PerconaPGCluster{ + cluster := &pgv3.PerconaPGCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", Namespace: "test-ns", @@ -319,33 +319,33 @@ func TestGetLatestCommitTimestamp(t *testing.T) { tests := map[string]struct { pods []client.Object - backup *pgv2.PerconaPGBackup - cluster *pgv2.PerconaPGCluster + backup *pgv3.PerconaPGBackup + cluster *pgv3.PerconaPGCluster expectedErr error }{ "primary pod not found due to invalid patroni version": { pods: []client.Object{}, - backup: &pgv2.PerconaPGBackup{ + backup: &pgv3.PerconaPGBackup{ ObjectMeta: metav1.ObjectMeta{ Name: "backup1", Namespace: "test-ns", }, - Spec: pgv2.PerconaPGBackupSpec{ + Spec: pgv3.PerconaPGBackupSpec{ PGCluster: "test-cluster", RepoName: new("repo1"), }, }, - cluster: &pgv2.PerconaPGCluster{ + cluster: &pgv3.PerconaPGCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test-cluster", Namespace: "test-ns", }, - Status: pgv2.PerconaPGClusterStatus{ - Patroni: pgv2.Patroni{ + Status: pgv3.PerconaPGClusterStatus{ + Patroni: pgv3.Patroni{ Version: "error", }, }, - Spec: pgv2.PerconaPGClusterSpec{ + Spec: pgv3.PerconaPGClusterSpec{ CRVersion: version.Version(), }, }, diff --git a/pkg/apis/pgv2.percona.com/v2/groupversion_info.go b/pkg/apis/pgv2.percona.com/v2/groupversion_info.go index c7b59aa43f..7fe15f60e6 100644 --- a/pkg/apis/pgv2.percona.com/v2/groupversion_info.go +++ b/pkg/apis/pgv2.percona.com/v2/groupversion_info.go @@ -12,7 +12,7 @@ var ( GroupVersion = schema.GroupVersion{Group: "pgv2.percona.com", Version: "v2"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} //nolint:staticcheck // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme diff --git a/pkg/apis/pgv2.percona.com/v2/logicalreplica_types_test.go b/pkg/apis/pgv2.percona.com/v2/logicalreplica_types_test.go index 1b6a5f65bf..f2d781e7e5 100644 --- a/pkg/apis/pgv2.percona.com/v2/logicalreplica_types_test.go +++ b/pkg/apis/pgv2.percona.com/v2/logicalreplica_types_test.go @@ -10,8 +10,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func logicalReplicaCR(replicas ...LogicalReplicaSpec) *PerconaPGCluster { diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go index 204a077a27..e2028cb36b 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgbackup_types.go @@ -12,7 +12,7 @@ import ( "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func init() { @@ -140,7 +140,7 @@ type SnapshotStatus struct { } // +kubebuilder:validation:Type=string -type PITRestoreDateTime struct { +type PITRestoreDateTime struct { //nolint:recvcheck *metav1.Time `json:",inline"` } @@ -184,7 +184,7 @@ func (t PITRestoreDateTime) MarshalJSON() ([]byte, error) { return []byte("null"), nil } - return json.Marshal(t.Time.Format("2006-01-02 15:04:05.000000-0700")) + return json.Marshal(t.Format("2006-01-02 15:04:05.000000-0700")) } type PGBackupStorageType string diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index e681eaea62..c3ac339934 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -16,12 +16,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "github.com/percona/percona-postgresql-operator/v2/internal/config" - "github.com/percona/percona-postgresql-operator/v2/internal/logging" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/config" + "github.com/percona/percona-postgresql-operator/v3/internal/logging" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) var allowedWALLevels = []string{"logical", "replica"} @@ -43,7 +43,7 @@ func init() { // +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1},{Secret,v1},{Service,v1},{CronJob,v1beta1},{Deployment,v1},{Job,v1},{StatefulSet,v1},{PersistentVolumeClaim,v1}} // // PerconaPGCluster is the CRD that defines a Percona PG Cluster -type PerconaPGCluster struct { +type PerconaPGCluster struct { //nolint:recvcheck metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata"` @@ -983,7 +983,7 @@ type Patroni struct { // Backups struct. // +kubebuilder:validation:XValidation:rule="(has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos) && size(self.pgbackrest.repos) > 0)",message="At least one repository must be configured when backups are enabled" -type Backups struct { +type Backups struct { //nolint:recvcheck // Enabled controls whether backups are enabled for the cluster. // Defaulted to true by the operator for crVersion >= 3.1.0. // +optional @@ -1425,7 +1425,7 @@ func (p PGInstanceSets) ToCrunchy() []crunchyv1beta1.PostgresInstanceSetSpec { return set } -type PGInstanceSetSpec struct { +type PGInstanceSetSpec struct { //nolint:recvcheck // +optional Metadata *crunchyv1beta1.Metadata `json:"metadata,omitempty"` diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go index 788b90bf4a..aca730ef01 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go @@ -14,9 +14,9 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/percona/percona-postgresql-operator/v2/internal/naming" - "github.com/percona/percona-postgresql-operator/v2/percona/version" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/internal/naming" + "github.com/percona/percona-postgresql-operator/v3/percona/version" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func TestPerconaPGCluster_Default(t *testing.T) { diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgupgrade_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgupgrade_types.go index 3d2348eae6..89cd0138f9 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgupgrade_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgupgrade_types.go @@ -4,7 +4,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + crunchyv1beta1 "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" ) func init() { diff --git a/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go b/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go index 350284d905..4140b84a59 100644 --- a/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go +++ b/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go @@ -9,7 +9,7 @@ package v2 import ( - "github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1" + "github.com/percona/percona-postgresql-operator/v3/pkg/apis/upstream.pgv2.percona.com/v1beta1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/apis/upstream.pgv2.percona.com/v1beta1/groupversion_info.go b/pkg/apis/upstream.pgv2.percona.com/v1beta1/groupversion_info.go index d821dc4512..c55078c4d3 100644 --- a/pkg/apis/upstream.pgv2.percona.com/v1beta1/groupversion_info.go +++ b/pkg/apis/upstream.pgv2.percona.com/v1beta1/groupversion_info.go @@ -17,7 +17,7 @@ var ( GroupVersion = schema.GroupVersion{Group: "upstream.pgv2.percona.com", Version: "v1beta1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} //nolint:staticcheck // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme diff --git a/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_test.go b/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_test.go index 12223a733a..d7c8eeb9c9 100644 --- a/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_test.go +++ b/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_test.go @@ -16,7 +16,7 @@ import ( ) func TestPostgresClusterWebhooks(t *testing.T) { - var _ webhook.CustomDefaulter = &PostgresCluster{} + var _ webhook.CustomDefaulter = &PostgresCluster{} //nolint:staticcheck } func TestPostgresClusterHasReplicas(t *testing.T) { diff --git a/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_types.go b/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_types.go index 3361915c4c..ac0c1b1a5b 100644 --- a/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_types.go +++ b/pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_types.go @@ -18,7 +18,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" - pNaming "github.com/percona/percona-postgresql-operator/v2/percona/naming" + pNaming "github.com/percona/percona-postgresql-operator/v3/percona/naming" ) // PostgresClusterSpec defines the desired state of PostgresCluster diff --git a/pkg/apis/upstream.pgv2.percona.com/v1beta1/shared_types.go b/pkg/apis/upstream.pgv2.percona.com/v1beta1/shared_types.go index 9176596d15..99db9cca72 100644 --- a/pkg/apis/upstream.pgv2.percona.com/v1beta1/shared_types.go +++ b/pkg/apis/upstream.pgv2.percona.com/v1beta1/shared_types.go @@ -57,13 +57,13 @@ type ServiceSpec struct { // // +optional // +kubebuilder:validation:Enum={Cluster,Local} - InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicyType `json:"internalTrafficPolicy,omitempty"` + InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicy `json:"internalTrafficPolicy,omitempty"` // More info: https://kubernetes.io/docs/concepts/services-networking/service/#traffic-policies // // +optional // +kubebuilder:validation:Enum={Cluster,Local} - ExternalTrafficPolicy *corev1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty"` + ExternalTrafficPolicy *corev1.ServiceExternalTrafficPolicy `json:"externalTrafficPolicy,omitempty"` } // Sidecar defines the configuration of a sidecar container diff --git a/pkg/apis/upstream.pgv2.percona.com/v1beta1/zz_generated.deepcopy.go b/pkg/apis/upstream.pgv2.percona.com/v1beta1/zz_generated.deepcopy.go index 3e3d364913..508413d9d4 100644 --- a/pkg/apis/upstream.pgv2.percona.com/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/upstream.pgv2.percona.com/v1beta1/zz_generated.deepcopy.go @@ -2692,12 +2692,12 @@ func (in *ServiceSpec) DeepCopyInto(out *ServiceSpec) { } if in.InternalTrafficPolicy != nil { in, out := &in.InternalTrafficPolicy, &out.InternalTrafficPolicy - *out = new(corev1.ServiceInternalTrafficPolicyType) + *out = new(corev1.ServiceInternalTrafficPolicy) **out = **in } if in.ExternalTrafficPolicy != nil { in, out := &in.ExternalTrafficPolicy, &out.ExternalTrafficPolicy - *out = new(corev1.ServiceExternalTrafficPolicyType) + *out = new(corev1.ServiceExternalTrafficPolicy) **out = **in } }