Skip to content

Commit bd82c08

Browse files
committed
Make the Backups field a pointer for client.Create
1 parent 612a8b0 commit bd82c08

File tree

12 files changed

+31
-32
lines changed

12 files changed

+31
-32
lines changed

internal/controller/postgrescluster/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func testCluster() *v1beta1.PostgresCluster {
120120
Replicas: initialize.Int32(1),
121121
DataVolumeClaimSpec: testVolumeClaimSpec(),
122122
}},
123-
Backups: v1beta1.Backups{
123+
Backups: &v1beta1.Backups{
124124
PGBackRest: v1beta1.PGBackRestArchive{
125125
Image: CrunchyPGBackRestImage,
126126
Repos: []v1beta1.PGBackRestRepo{{

internal/controller/postgrescluster/pgadmin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ func pgAdminTestCluster(ns corev1.Namespace) *v1beta1.PostgresCluster {
848848
InstanceSets: []v1beta1.PostgresInstanceSetSpec{{
849849
DataVolumeClaimSpec: testVolumeClaimSpec(),
850850
}},
851-
Backups: v1beta1.Backups{
851+
Backups: &v1beta1.Backups{
852852
PGBackRest: v1beta1.PGBackRestArchive{
853853
Repos: []v1beta1.PGBackRestRepo{{
854854
Name: "repo1",

internal/controller/postgrescluster/pgbackrest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,7 @@ func (r *Reconciler) ObserveBackupUniverse(ctx context.Context,
30623062
) {
30633063

30643064
// Does the cluster have a blank Backups section
3065-
backupsSpecFound = !reflect.DeepEqual(postgresCluster.Spec.Backups, v1beta1.Backups{PGBackRest: v1beta1.PGBackRestArchive{}})
3065+
backupsSpecFound = !reflect.DeepEqual(postgresCluster.Spec.Backups, &v1beta1.Backups{PGBackRest: v1beta1.PGBackRestArchive{}})
30663066

30673067
// Does the repo-host StatefulSet exist?
30683068
name := fmt.Sprintf("%s-%s", postgresCluster.GetName(), "repo-host")

internal/controller/postgrescluster/pgbackrest_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func fakePostgresCluster(clusterName, namespace, clusterUID string,
7373
},
7474
},
7575
}},
76-
Backups: v1beta1.Backups{
76+
Backups: &v1beta1.Backups{
7777
PGBackRest: v1beta1.PGBackRestArchive{
7878
Image: "example.com/crunchy-pgbackrest:test",
7979
Jobs: &v1beta1.BackupJobs{
@@ -597,7 +597,7 @@ topologySpreadConstraints:
597597
ns := setupNamespace(t, tClient)
598598
// create a PostgresCluster without backups to test with
599599
postgresCluster := fakePostgresCluster(clusterName, ns.GetName(), clusterUID, true)
600-
postgresCluster.Spec.Backups = v1beta1.Backups{}
600+
postgresCluster.Spec.Backups = &v1beta1.Backups{}
601601

602602
// create the 'observed' instances and set the leader
603603
instances := &observedInstances{
@@ -1489,7 +1489,7 @@ func TestGetPGBackRestResources(t *testing.T) {
14891489
UID: types.UID(clusterUID),
14901490
},
14911491
Spec: v1beta1.PostgresClusterSpec{
1492-
Backups: v1beta1.Backups{
1492+
Backups: &v1beta1.Backups{
14931493
PGBackRest: v1beta1.PGBackRestArchive{
14941494
Repos: []v1beta1.PGBackRestRepo{{Name: "repo1"}},
14951495
},
@@ -1526,7 +1526,7 @@ func TestGetPGBackRestResources(t *testing.T) {
15261526
UID: types.UID(clusterUID),
15271527
},
15281528
Spec: v1beta1.PostgresClusterSpec{
1529-
Backups: v1beta1.Backups{
1529+
Backups: &v1beta1.Backups{
15301530
PGBackRest: v1beta1.PGBackRestArchive{
15311531
Repos: []v1beta1.PGBackRestRepo{{Name: "repo4"}},
15321532
},
@@ -1562,7 +1562,7 @@ func TestGetPGBackRestResources(t *testing.T) {
15621562
UID: types.UID(clusterUID),
15631563
},
15641564
Spec: v1beta1.PostgresClusterSpec{
1565-
Backups: v1beta1.Backups{
1565+
Backups: &v1beta1.Backups{
15661566
PGBackRest: v1beta1.PGBackRestArchive{
15671567
Repos: []v1beta1.PGBackRestRepo{{
15681568
Name: "repo1",
@@ -1601,7 +1601,7 @@ func TestGetPGBackRestResources(t *testing.T) {
16011601
UID: types.UID(clusterUID),
16021602
},
16031603
Spec: v1beta1.PostgresClusterSpec{
1604-
Backups: v1beta1.Backups{
1604+
Backups: &v1beta1.Backups{
16051605
PGBackRest: v1beta1.PGBackRestArchive{
16061606
Repos: []v1beta1.PGBackRestRepo{{
16071607
Name: "repo4",
@@ -1642,7 +1642,7 @@ func TestGetPGBackRestResources(t *testing.T) {
16421642
UID: types.UID(clusterUID),
16431643
},
16441644
Spec: v1beta1.PostgresClusterSpec{
1645-
Backups: v1beta1.Backups{
1645+
Backups: &v1beta1.Backups{
16461646
PGBackRest: v1beta1.PGBackRestArchive{
16471647
Repos: []v1beta1.PGBackRestRepo{{Volume: &v1beta1.RepoPVC{}}},
16481648
},
@@ -1680,7 +1680,7 @@ func TestGetPGBackRestResources(t *testing.T) {
16801680
UID: types.UID(clusterUID),
16811681
},
16821682
Spec: v1beta1.PostgresClusterSpec{
1683-
Backups: v1beta1.Backups{
1683+
Backups: &v1beta1.Backups{
16841684
PGBackRest: v1beta1.PGBackRestArchive{},
16851685
},
16861686
},
@@ -2233,7 +2233,7 @@ func TestCopyConfigurationResources(t *testing.T) {
22332233
},
22342234
},
22352235
}},
2236-
Backups: v1beta1.Backups{
2236+
Backups: &v1beta1.Backups{
22372237
PGBackRest: v1beta1.PGBackRestArchive{
22382238
Configuration: []corev1.VolumeProjection{{
22392239
Secret: &corev1.SecretProjection{
@@ -2285,7 +2285,7 @@ func TestCopyConfigurationResources(t *testing.T) {
22852285
},
22862286
},
22872287
}},
2288-
Backups: v1beta1.Backups{
2288+
Backups: &v1beta1.Backups{
22892289
PGBackRest: v1beta1.PGBackRestArchive{
22902290
Image: "example.com/crunchy-pgbackrest:test",
22912291
Repos: []v1beta1.PGBackRestRepo{{
@@ -2518,7 +2518,7 @@ volumes:
25182518
cluster := &v1beta1.PostgresCluster{}
25192519

25202520
t.Run("Resources not defined in jobs", func(t *testing.T) {
2521-
cluster.Spec.Backups = v1beta1.Backups{
2521+
cluster.Spec.Backups = &v1beta1.Backups{
25222522
PGBackRest: v1beta1.PGBackRestArchive{},
25232523
}
25242524
job := generateBackupJobSpecIntent(ctx,
@@ -2568,7 +2568,7 @@ volumes:
25682568

25692569
cluster := &v1beta1.PostgresCluster{
25702570
Spec: v1beta1.PostgresClusterSpec{
2571-
Backups: v1beta1.Backups{
2571+
Backups: &v1beta1.Backups{
25722572
PGBackRest: v1beta1.PGBackRestArchive{
25732573
Jobs: &v1beta1.BackupJobs{
25742574
Affinity: affinity,
@@ -2775,7 +2775,7 @@ func TestGenerateRestoreJobIntent(t *testing.T) {
27752775
Labels: map[string]string{"Global": "test"},
27762776
Annotations: map[string]string{"Global": "test"},
27772777
},
2778-
Backups: v1beta1.Backups{PGBackRest: v1beta1.PGBackRestArchive{
2778+
Backups: &v1beta1.Backups{PGBackRest: v1beta1.PGBackRestArchive{
27792779
Metadata: &v1beta1.Metadata{
27802780
Labels: map[string]string{"Backrest": "test"},
27812781
Annotations: map[string]string{"Backrest": "test"},
@@ -3786,7 +3786,7 @@ func TestBackupsEnabled(t *testing.T) {
37863786
ns := setupNamespace(t, tClient)
37873787

37883788
postgresCluster := fakePostgresCluster(clusterName, ns.GetName(), clusterUID, true)
3789-
postgresCluster.Spec.Backups = v1beta1.Backups{}
3789+
postgresCluster.Spec.Backups = &v1beta1.Backups{}
37903790

37913791
backupsSpecFound, backupsReconciliationAllowed, err := r.BackupsEnabled(ctx, postgresCluster)
37923792

@@ -3822,7 +3822,7 @@ func TestBackupsEnabled(t *testing.T) {
38223822
_, err = r.reconcilePGBackRest(ctx, postgresCluster, instances, rootCA, true)
38233823
assert.NilError(t, err)
38243824

3825-
postgresCluster.Spec.Backups = v1beta1.Backups{}
3825+
postgresCluster.Spec.Backups = &v1beta1.Backups{}
38263826

38273827
backupsSpecFound, backupsReconciliationAllowed, err := r.BackupsEnabled(ctx, postgresCluster)
38283828

@@ -3858,7 +3858,7 @@ func TestBackupsEnabled(t *testing.T) {
38583858
_, err = r.reconcilePGBackRest(ctx, postgresCluster, instances, rootCA, true)
38593859
assert.NilError(t, err)
38603860

3861-
postgresCluster.Spec.Backups = v1beta1.Backups{}
3861+
postgresCluster.Spec.Backups = &v1beta1.Backups{}
38623862
annotations := map[string]string{
38633863
naming.AuthorizeBackupRemovalAnnotation: "true",
38643864
}

internal/controller/postgrescluster/volumes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func TestReconcileConfigureExistingPVCs(t *testing.T) {
401401
},
402402
},
403403
}},
404-
Backups: v1beta1.Backups{
404+
Backups: &v1beta1.Backups{
405405
PGBackRest: v1beta1.PGBackRestArchive{
406406
Image: "example.com/crunchy-pgbackrest:test",
407407
Repos: []v1beta1.PGBackRestRepo{{
@@ -684,7 +684,7 @@ func TestReconcileMoveDirectories(t *testing.T) {
684684
},
685685
},
686686
}},
687-
Backups: v1beta1.Backups{
687+
Backups: &v1beta1.Backups{
688688
PGBackRest: v1beta1.PGBackRestArchive{
689689
Image: "example.com/crunchy-pgbackrest:test",
690690
RepoHost: &v1beta1.PGBackRestRepoHost{

internal/controller/standalone_pgadmin/helpers_unit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func testCluster() *v1beta1.PostgresCluster {
4242
Replicas: initialize.Int32(1),
4343
DataVolumeClaimSpec: testVolumeClaimSpec(),
4444
}},
45-
Backups: v1beta1.Backups{
45+
Backups: &v1beta1.Backups{
4646
PGBackRest: v1beta1.PGBackRestArchive{
4747
Image: CrunchyPGBackRestImage,
4848
Repos: []v1beta1.PGBackRestRepo{{

internal/pgbackrest/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func TestMakePGBackrestLogDir(t *testing.T) {
262262
cluster := &v1beta1.PostgresCluster{
263263
Spec: v1beta1.PostgresClusterSpec{
264264
ImagePullPolicy: corev1.PullAlways,
265-
Backups: v1beta1.Backups{
265+
Backups: &v1beta1.Backups{
266266
PGBackRest: v1beta1.PGBackRestArchive{
267267
Image: "test-image",
268268
Repos: []v1beta1.PGBackRestRepo{

internal/pgbackrest/pgbackrest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fi
5656
}
5757
postgresCluster := &v1beta1.PostgresCluster{
5858
Spec: v1beta1.PostgresClusterSpec{
59-
Backups: v1beta1.Backups{
59+
Backups: &v1beta1.Backups{
6060
PGBackRest: v1beta1.PGBackRestArchive{
6161
Repos: []v1beta1.PGBackRestRepo{{
6262
Name: "repo1",

internal/pgbackrest/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestCalculateConfigHashes(t *testing.T) {
4747
Namespace: "calculate-config-hashes",
4848
},
4949
Spec: v1beta1.PostgresClusterSpec{
50-
Backups: v1beta1.Backups{
50+
Backups: &v1beta1.Backups{
5151
PGBackRest: v1beta1.PGBackRestArchive{
5252
Repos: []v1beta1.PGBackRestRepo{{
5353
Name: "repo1",

internal/testing/validation/postgrescluster_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ func TestPostgresUserOptions(t *testing.T) {
3030
// Start with a bunch of required fields.
3131
assert.NilError(t, yaml.Unmarshal([]byte(`{
3232
postgresVersion: 16,
33-
backups: {
34-
pgbackrest: {
35-
repos: [{ name: repo1 }],
36-
},
37-
},
3833
instances: [{
3934
dataVolumeClaimSpec: {
4035
accessModes: [ReadWriteOnce],

0 commit comments

Comments
 (0)