Skip to content

Commit 74b9009

Browse files
add nil check before assigning to map (#1437)
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
1 parent 5eed221 commit 74b9009

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

percona/controller/pgcluster/patroniversion.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ func (r *PGClusterReconciler) handleCustomPatroniVersionAnnotation(ctx context.C
283283

284284
func (r *PGClusterReconciler) patchPatroniVersionAnnotation(ctx context.Context, cr *v2.PerconaPGCluster, patroniVersion string) error {
285285
orig := cr.DeepCopy()
286+
if cr.Annotations == nil {
287+
cr.Annotations = make(map[string]string)
288+
}
286289
cr.Annotations[pNaming.AnnotationPatroniVersion] = patroniVersion
287290
if err := r.Client.Patch(ctx, cr.DeepCopy(), client.MergeFrom(orig)); err != nil {
288291
return errors.Wrap(err, "failed to patch the pg cluster")

0 commit comments

Comments
 (0)