mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 10:39:43 +02:00
Fix an issue when not assigning the merge result.
Add some tests.
This commit is contained in:
@@ -610,12 +610,12 @@ func (c *Cluster) initSystemUsers() {
|
||||
func (c *Cluster) initRobotUsers() error {
|
||||
for username, userFlags := range c.Spec.Users {
|
||||
if !isValidUsername(username) {
|
||||
return fmt.Errorf("invalid username: '%v'", username)
|
||||
return fmt.Errorf("invalid username: %q", username)
|
||||
}
|
||||
|
||||
flags, err := normalizeUserFlags(userFlags)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid flags for user '%v': %v", username, err)
|
||||
return fmt.Errorf("invalid flags for user %q: %v", username, err)
|
||||
}
|
||||
if _, present := c.pgUsers[username]; !present {
|
||||
c.pgUsers[username] = spec.PgUser{
|
||||
@@ -630,6 +630,7 @@ func (c *Cluster) initRobotUsers() error {
|
||||
c.logger.Debugf("merging user %q data", username)
|
||||
user := c.pgUsers[username]
|
||||
user.Flags = flags
|
||||
c.pgUsers[username] = user
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/zalando-incubator/postgres-operator/pkg/util"
|
||||
"github.com/zalando-incubator/postgres-operator/pkg/util/constants"
|
||||
"github.com/zalando-incubator/postgres-operator/pkg/util/retryutil"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func isValidUsername(username string) bool {
|
||||
@@ -77,7 +78,7 @@ func normalizeUserFlags(userFlags []string) ([]string, error) {
|
||||
if addLogin {
|
||||
flags = append(flags, constants.RoleFlagLogin)
|
||||
}
|
||||
|
||||
sort.Strings(flags)
|
||||
return flags, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user