Add 'admin' option to create role

This commit is contained in:
Sergey Dudoladov
2018-11-30 17:08:41 +01:00
parent ff5c63ddf1
commit 83ef5ff5b6
5 changed files with 20 additions and 5 deletions
+9 -4
View File
@@ -709,11 +709,16 @@ func (c *Cluster) initRobotUsers() error {
if err != nil {
return fmt.Errorf("invalid flags for user %q: %v", username, err)
}
adminRole := ""
if c.OpConfig.AddAdminFlagToRobotRoles {
adminRole = c.OpConfig.TeamAdminRole
}
newRole := spec.PgUser{
Origin: spec.RoleOriginManifest,
Name: username,
Password: util.RandomPassword(constants.PasswordLength),
Flags: flags,
Origin: spec.RoleOriginManifest,
Name: username,
Password: util.RandomPassword(constants.PasswordLength),
Flags: flags,
AdminRole: adminRole,
}
if currentRole, present := c.pgUsers[username]; present {
c.pgUsers[username] = c.resolveNameConflict(&currentRole, &newRole)