[WIP] Add 'admin' option to create role (#425)

* Add 'admin' option to create role

* Fix run_locally_script
This commit is contained in:
zerg-junior
2018-12-27 10:14:33 +01:00
committed by GitHub
parent 26670408c4
commit c0b0b9a832
7 changed files with 22 additions and 6 deletions
+6 -1
View File
@@ -5,9 +5,10 @@ import (
"fmt"
"strings"
"reflect"
"github.com/zalando-incubator/postgres-operator/pkg/spec"
"github.com/zalando-incubator/postgres-operator/pkg/util"
"reflect"
)
const (
@@ -19,6 +20,7 @@ const (
doBlockStmt = `SET LOCAL synchronous_commit = 'local'; DO $$ BEGIN %s; END;$$;`
passwordTemplate = "ENCRYPTED PASSWORD '%s'"
inRoleTemplate = `IN ROLE %s`
adminTemplate = `ADMIN %s`
)
// DefaultUserSyncStrategy implements a user sync strategy that merges already existing database users
@@ -113,6 +115,9 @@ func (strategy DefaultUserSyncStrategy) createPgUser(user spec.PgUser, db *sql.D
if len(user.MemberOf) > 0 {
userFlags = append(userFlags, fmt.Sprintf(inRoleTemplate, quoteMemberList(user)))
}
if user.AdminRole != "" {
userFlags = append(userFlags, fmt.Sprintf(adminTemplate, user.AdminRole))
}
if user.Password == "" {
userPassword = "PASSWORD NULL"