@@ -715,12 +715,16 @@ func (c *Cluster) updateSecret(
715715 } else if secretUsername == c .systemUsers [constants .ReplicationUserKeyName ].Name {
716716 userKey = constants .ReplicationUserKeyName
717717 userMap = c .systemUsers
718- } else if secretUsername == constants .ConnectionPoolerUserName {
719- userKey = constants .ConnectionPoolerUserName
720- userMap = c .systemUsers
721- } else if secretUsername == constants .EventStreamSourceSlotPrefix + constants .UserRoleNameSuffix {
722- userKey = constants .EventStreamSourceSlotPrefix + constants .UserRoleNameSuffix
723- userMap = c .systemUsers
718+ } else if _ , exists := c .systemUsers [constants .ConnectionPoolerUserKeyName ]; exists {
719+ if secretUsername == c .systemUsers [constants .ConnectionPoolerUserKeyName ].Name {
720+ userKey = constants .ConnectionPoolerUserName
721+ userMap = c .systemUsers
722+ }
723+ } else if _ , exists := c .systemUsers [constants .EventStreamUserKeyName ]; exists {
724+ if secretUsername == c .systemUsers [constants .EventStreamUserKeyName ].Name {
725+ userKey = fmt .Sprintf ("%s%s" , constants .EventStreamSourceSlotPrefix , constants .UserRoleNameSuffix )
726+ userMap = c .systemUsers
727+ }
724728 } else {
725729 userKey = secretUsername
726730 userMap = c .pgUsers
@@ -816,7 +820,7 @@ func (c *Cluster) rotatePasswordInSecret(
816820 // create rotation user if role is not listed for in-place password update
817821 if ! util .SliceContains (c .Spec .UsersWithInPlaceSecretRotation , secretUsername ) {
818822 rotationUser := secretPgUser
819- newRotationUsername := secretUsername + currentTime .Format ("060102" )
823+ newRotationUsername := fmt . Sprintf ( "%s%s" , secretUsername , currentTime .Format ("060102" ) )
820824 rotationUser .Name = newRotationUsername
821825 rotationUser .MemberOf = []string {secretUsername }
822826 (* rotationUsers )[newRotationUsername ] = rotationUser
@@ -976,7 +980,7 @@ func (c *Cluster) syncDatabases() error {
976980 for preparedDatabaseName := range c .Spec .PreparedDatabases {
977981 _ , exists := currentDatabases [preparedDatabaseName ]
978982 if ! exists {
979- createDatabases [preparedDatabaseName ] = preparedDatabaseName + constants .OwnerRoleNameSuffix
983+ createDatabases [preparedDatabaseName ] = fmt . Sprintf ( "%s%s" , preparedDatabaseName , constants .OwnerRoleNameSuffix )
980984 preparedDatabases = append (preparedDatabases , preparedDatabaseName )
981985 }
982986 }
@@ -1077,9 +1081,9 @@ func (c *Cluster) syncPreparedSchemas(databaseName string, preparedSchemas map[s
10771081 if createPreparedSchemas , equal := util .SubstractStringSlices (schemas , currentSchemas ); ! equal {
10781082 for _ , schemaName := range createPreparedSchemas {
10791083 owner := constants .OwnerRoleNameSuffix
1080- dbOwner := databaseName + owner
1084+ dbOwner := fmt . Sprintf ( "%s%s" , databaseName , owner )
10811085 if preparedSchemas [schemaName ].DefaultRoles == nil || * preparedSchemas [schemaName ].DefaultRoles {
1082- owner = databaseName + "_" + schemaName + owner
1086+ owner = fmt . Sprintf ( "%s_%s%s" , databaseName , schemaName , owner )
10831087 } else {
10841088 owner = dbOwner
10851089 }
0 commit comments