Skip to content

Commit b3211a0

Browse files
committed
add test
1 parent 1d24337 commit b3211a0

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

internal/controller/postgrescluster/controller_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,31 @@ spec:
512512
Expect(icm.Data["patroni.yaml"]).ToNot(BeZero())
513513
})
514514

515+
It("doesn't reconcile ConfigMap with override annotation", func() {
516+
icm := &corev1.ConfigMap{}
517+
Expect(suite.Client.Get(context.Background(), client.ObjectKey{
518+
Namespace: test.Namespace.Name, Name: instance.Name + "-config",
519+
}, icm)).To(Succeed())
520+
521+
Expect(icm.Labels[naming.LabelCluster]).To(Equal("carlos"))
522+
Expect(icm.Labels[naming.LabelInstance]).To(Equal(instance.Name))
523+
Expect(icm.Data["patroni.yaml"]).ToNot(BeZero())
524+
525+
icm.SetAnnotations(map[string]string{
526+
naming.OverrideConfigAnnotation: "true",
527+
})
528+
icm.Data["patroni.yaml"] = ""
529+
530+
Expect(suite.Client.Update(context.Background(), icm)).To(Succeed())
531+
532+
Expect(suite.Client.Get(context.Background(), client.ObjectKey{
533+
Namespace: test.Namespace.Name, Name: instance.Name + "-config",
534+
}, icm)).To(Succeed())
535+
536+
Expect(icm.Annotations[naming.OverrideConfigAnnotation]).To(Equal("true"))
537+
Expect(icm.Data["patroni.yaml"]).To(BeZero())
538+
})
539+
515540
Specify("Instance StatefulSet", func() {
516541
Expect(instance.Labels[naming.LabelCluster]).To(Equal("carlos"))
517542
Expect(instance.Labels[naming.LabelInstanceSet]).To(Equal("samba"))

internal/naming/annotations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const (
7070
// touch cloud-based backups.
7171
AuthorizeBackupRemovalAnnotation = annotationPrefix + "authorizeBackupRemoval"
7272

73+
// K8SPG-712
7374
// OverrideConfigAnnotation is an annotation used to prevent the controller from reconciling
7475
// ConfigMaps when a user wants to manually override their contents. When this annotation
7576
// is present, the controller will not update the ConfigMap, allowing users to make custom

0 commit comments

Comments
 (0)