From 2f804788f8e017e7d9bcd5322e8178aaadcec9f8 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Wed, 11 Dec 2024 19:00:08 +0100 Subject: [PATCH] Check for custom user names uniqueness. --- pkg/apis/pxc/v1/pxc_types.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/apis/pxc/v1/pxc_types.go b/pkg/apis/pxc/v1/pxc_types.go index fa23e5b90..160e62b39 100644 --- a/pkg/apis/pxc/v1/pxc_types.go +++ b/pkg/apis/pxc/v1/pxc_types.go @@ -417,6 +417,14 @@ func (cr *PerconaXtraDBCluster) Validate() error { return errors.Errorf("ProxySQL or HAProxy should be enabled if SmartUpdate set") } + customUsers := make(map[string]int8, len(c.Users)) + for _, user := range c.Users { + customUsers[user.Name]++ + if customUsers[user.Name] > 1 { + return errors.Errorf("user %s is duplicated", user.Name) + } + } + return nil }