Skip to content

Commit 5d48239

Browse files
committed
K8SPG-1019 Apply Go 1.26 code improvements using go fix
1 parent c7d5883 commit 5d48239

90 files changed

Lines changed: 381 additions & 430 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

internal/bridge/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type ClusterApiResource struct {
7070
Network string `json:"network_id,omitempty"`
7171
Parent string `json:"parent_id,omitempty"`
7272
Plan string `json:"plan_id,omitempty"`
73-
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
73+
PostgresVersion intstr.IntOrString `json:"postgres_version_id"`
7474
Provider string `json:"provider_id,omitempty"`
7575
Region string `json:"region_id,omitempty"`
7676
Replicas []*ClusterApiResource `json:"replicas,omitempty"`
@@ -187,7 +187,7 @@ type PostClustersRequestPayload struct {
187187
IsHA bool `json:"is_ha,omitempty"`
188188
Keychain string `json:"keychain_id,omitempty"`
189189
Network string `json:"network_id,omitempty"`
190-
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
190+
PostgresVersion intstr.IntOrString `json:"postgres_version_id"`
191191
Provider string `json:"provider_id,omitempty"`
192192
Region string `json:"region_id,omitempty"`
193193
Storage int64 `json:"storage,omitempty"`
@@ -197,7 +197,7 @@ type PostClustersRequestPayload struct {
197197
// changing its plan, upgrading its major version, or increasing its storage size.
198198
type PostClustersUpgradeRequestPayload struct {
199199
Plan string `json:"plan_id,omitempty"`
200-
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
200+
PostgresVersion intstr.IntOrString `json:"postgres_version_id"`
201201
UpgradeStartTime string `json:"starting_from,omitempty"`
202202
Storage int64 `json:"storage,omitempty"`
203203
}
@@ -206,7 +206,7 @@ type PostClustersUpgradeRequestPayload struct {
206206
// TODO: Implement the ability to update an upgrade (this isn't currently being used)
207207
type PutClustersUpgradeRequestPayload struct {
208208
Plan string `json:"plan_id,omitempty"`
209-
PostgresVersion intstr.IntOrString `json:"postgres_version_id,omitempty"`
209+
PostgresVersion intstr.IntOrString `json:"postgres_version_id"`
210210
UpgradeStartTime string `json:"starting_from,omitempty"`
211211
Storage int64 `json:"storage,omitempty"`
212212
UseMaintenanceWindow *bool `json:"use_cluster_maintenance_window,omitempty"`

internal/bridge/client_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
gocmpopts "github.com/google/go-cmp/cmp/cmpopts"
1919
"gotest.tools/v3/assert"
2020
"k8s.io/apimachinery/pkg/util/intstr"
21-
22-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
2321
)
2422

2523
var testApiKey = "9012"
@@ -1155,7 +1153,7 @@ func TestUpdateCluster(t *testing.T) {
11551153
ClusterName: "new-cluster-name",
11561154
}
11571155
clusterUpdateRequestPayload := &PatchClustersRequestPayload{
1158-
IsProtected: initialize.Bool(true),
1156+
IsProtected: new(true),
11591157
}
11601158

11611159
t.Run("WeSendCorrectData", func(t *testing.T) {

internal/bridge/crunchybridgecluster/crunchybridgecluster_controller_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"sigs.k8s.io/controller-runtime/pkg/client"
2121

2222
"github.com/percona/percona-postgresql-operator/v2/internal/bridge"
23-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
2423
"github.com/percona/percona-postgresql-operator/v2/internal/naming"
2524
"github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp"
2625
"github.com/percona/percona-postgresql-operator/v2/internal/testing/require"
@@ -558,8 +557,8 @@ func TestHandleUpgradeHA(t *testing.T) {
558557
ns := setupNamespace(t, tClient).Name
559558
clusterInBridgeWithHaDisabled := testClusterApiResource()
560559
clusterInBridgeWithHaEnabled := testClusterApiResource()
561-
clusterInBridgeWithHaEnabled.ID = "2345" // originally "1234"
562-
clusterInBridgeWithHaEnabled.IsHA = initialize.Bool(true) // originally "false"
560+
clusterInBridgeWithHaEnabled.ID = "2345" // originally "1234"
561+
clusterInBridgeWithHaEnabled.IsHA = new(true) // originally "false"
563562

564563
reconciler := &CrunchyBridgeClusterReconciler{
565564
Client: tClient,

internal/bridge/crunchybridgecluster/delete.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1313

1414
"github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime"
15-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
1615
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1716
)
1817

@@ -49,7 +48,7 @@ func (r *CrunchyBridgeClusterReconciler) handleDelete(
4948
}
5049

5150
if !deletedAlready {
52-
return initialize.Pointer(runtime.RequeueWithoutBackoff(time.Second)), err
51+
return new(runtime.RequeueWithoutBackoff(time.Second)), err
5352
}
5453

5554
// Remove finalizer if deleted already

internal/bridge/crunchybridgecluster/helpers_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"sigs.k8s.io/yaml"
1919

2020
"github.com/percona/percona-postgresql-operator/v2/internal/bridge"
21-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
2221
"github.com/percona/percona-postgresql-operator/v2/internal/testing/require"
2322
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2423
)
@@ -105,8 +104,8 @@ func testClusterApiResource() *bridge.ClusterApiResource {
105104
cluster := bridge.ClusterApiResource{
106105
ID: "1234",
107106
Host: "example.com",
108-
IsHA: initialize.Bool(false),
109-
IsProtected: initialize.Bool(false),
107+
IsHA: new(false),
108+
IsProtected: new(false),
110109
MajorVersion: 15,
111110
ClusterName: "hippo-cluster",
112111
Plan: "standard-8",

internal/bridge/crunchybridgecluster/mock_bridge_api.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"k8s.io/apimachinery/pkg/util/intstr"
1313

1414
"github.com/percona/percona-postgresql-operator/v2/internal/bridge"
15-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
1615
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1716
)
1817

@@ -165,7 +164,7 @@ func (tbc *TestBridgeClient) CreateCluster(ctx context.Context, apiKey string,
165164
cluster := &bridge.ClusterApiResource{
166165
ID: fmt.Sprint(len(tbc.Clusters)),
167166
Host: "example.com",
168-
IsHA: initialize.Bool(clusterRequestPayload.IsHA),
167+
IsHA: new(clusterRequestPayload.IsHA),
169168
MajorVersion: clusterRequestPayload.PostgresVersion.IntValue(),
170169
ClusterName: clusterRequestPayload.Name,
171170
Plan: clusterRequestPayload.Plan,

internal/controller/pgupgrade/jobs_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"sigs.k8s.io/yaml"
1818

1919
"github.com/percona/percona-postgresql-operator/v2/internal/feature"
20-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
2120
"github.com/percona/percona-postgresql-operator/v2/internal/testing/cmp"
2221
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2322
)
@@ -103,7 +102,7 @@ func TestGenerateUpgradeJob(t *testing.T) {
103102
upgrade.Namespace = "ns1"
104103
upgrade.Name = "pgu2"
105104
upgrade.UID = "uid3"
106-
upgrade.Spec.Image = initialize.Pointer("img4")
105+
upgrade.Spec.Image = new("img4")
107106
upgrade.Spec.PostgresClusterName = "pg5"
108107
upgrade.Spec.FromPostgresVersion = 19
109108
upgrade.Spec.ToPostgresVersion = 25
@@ -265,7 +264,7 @@ func TestGenerateRemoveDataJob(t *testing.T) {
265264
upgrade.Namespace = "ns1"
266265
upgrade.Name = "pgu2"
267266
upgrade.UID = "uid3"
268-
upgrade.Spec.Image = initialize.Pointer("img4")
267+
upgrade.Spec.Image = new("img4")
269268
upgrade.Spec.PostgresClusterName = "pg5"
270269
upgrade.Spec.FromPostgresVersion = 19
271270
upgrade.Spec.ToPostgresVersion = 25

internal/controller/pgupgrade/utils.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"sigs.k8s.io/controller-runtime/pkg/client"
1313
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1414

15-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
1615
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1716
)
1817

@@ -39,8 +38,8 @@ func (r *PGUpgradeReconciler) setControllerReference(
3938
Kind: "PGUpgrade",
4039
Name: owner.GetName(),
4140
UID: owner.GetUID(),
42-
BlockOwnerDeletion: initialize.Pointer(true),
43-
Controller: initialize.Pointer(true),
41+
BlockOwnerDeletion: new(true),
42+
Controller: new(true),
4443
},
4544
))
4645
}

internal/controller/pgupgrade/world_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1616

1717
"github.com/percona/percona-postgresql-operator/v2/internal/controller/runtime"
18-
"github.com/percona/percona-postgresql-operator/v2/internal/initialize"
1918
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2019
)
2120

@@ -102,7 +101,7 @@ func TestPopulateShutdown(t *testing.T) {
102101

103102
t.Run("NotShutdown", func(t *testing.T) {
104103
cluster := v1beta1.NewPostgresCluster()
105-
cluster.Spec.Shutdown = initialize.Bool(false)
104+
cluster.Spec.Shutdown = new(false)
106105

107106
world := NewWorld()
108107
world.Cluster = cluster
@@ -114,7 +113,7 @@ func TestPopulateShutdown(t *testing.T) {
114113
t.Run("OldStatus", func(t *testing.T) {
115114
cluster := v1beta1.NewPostgresCluster()
116115
cluster.SetGeneration(99)
117-
cluster.Spec.Shutdown = initialize.Bool(true)
116+
cluster.Spec.Shutdown = new(true)
118117
cluster.Status.ObservedGeneration = 21
119118

120119
world := NewWorld()
@@ -127,7 +126,7 @@ func TestPopulateShutdown(t *testing.T) {
127126
t.Run("InstancesRunning", func(t *testing.T) {
128127
cluster := v1beta1.NewPostgresCluster()
129128
cluster.SetGeneration(99)
130-
cluster.Spec.Shutdown = initialize.Bool(true)
129+
cluster.Spec.Shutdown = new(true)
131130
cluster.Status.ObservedGeneration = 99
132131
cluster.Status.InstanceSets = []v1beta1.PostgresInstanceSetStatus{{Replicas: 2}}
133132

@@ -141,7 +140,7 @@ func TestPopulateShutdown(t *testing.T) {
141140
t.Run("InstancesStopped", func(t *testing.T) {
142141
cluster := v1beta1.NewPostgresCluster()
143142
cluster.SetGeneration(99)
144-
cluster.Spec.Shutdown = initialize.Bool(true)
143+
cluster.Spec.Shutdown = new(true)
145144
cluster.Status.ObservedGeneration = 99
146145
cluster.Status.InstanceSets = []v1beta1.PostgresInstanceSetStatus{{Replicas: 0}}
147146

internal/controller/postgrescluster/controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ spec:
358358
MatchFields(IgnoreExtras, Fields{
359359
"Manager": Equal(string(test.Reconciler.Owner)),
360360
"FieldsV1": PointTo(MatchAllFields(Fields{
361-
"Raw": WithTransform(func(in []byte) (out map[string]interface{}) {
361+
"Raw": WithTransform(func(in []byte) (out map[string]any) {
362362
Expect(yaml.Unmarshal(in, &out)).To(Succeed())
363363
return out
364364
}, MatchAllKeys(Keys{
@@ -376,7 +376,7 @@ spec:
376376
MatchFields(IgnoreExtras, Fields{
377377
"Manager": Equal(string(test.Reconciler.Owner)),
378378
"FieldsV1": PointTo(MatchAllFields(Fields{
379-
"Raw": WithTransform(func(in []byte) (out map[string]interface{}) {
379+
"Raw": WithTransform(func(in []byte) (out map[string]any) {
380380
Expect(yaml.Unmarshal(in, &out)).To(Succeed())
381381
return out
382382
}, MatchAllKeys(Keys{
@@ -389,7 +389,7 @@ spec:
389389
MatchFields(IgnoreExtras, Fields{
390390
"Manager": Equal(string(test.Reconciler.Owner)),
391391
"FieldsV1": PointTo(MatchAllFields(Fields{
392-
"Raw": WithTransform(func(in []byte) (out map[string]interface{}) {
392+
"Raw": WithTransform(func(in []byte) (out map[string]any) {
393393
Expect(yaml.Unmarshal(in, &out)).To(Succeed())
394394
return out
395395
}, MatchAllKeys(Keys{

0 commit comments

Comments
 (0)