Improvements per review

This commit is contained in:
erthalion
2018-09-14 15:24:01 +02:00
parent 903902933f
commit 43a0449c8f
3 changed files with 13 additions and 10 deletions
+6 -3
View File
@@ -9,6 +9,8 @@ import (
var NoActions []Action = []Action{}
type Plan = []Action
type MetaData struct {
cluster *Cluster
namespace string
@@ -90,7 +92,8 @@ func (action UpdateSecret) Apply() error {
user := cluster.getSecretUser(action.secretUsername)
// if this secret belongs to the infrastructure role and the password has
// changed - replace it in the secret
// changed, we need to replace it in the secret. Otherwise synchronize the
// information what we've got in the memory with the data from the secret
updateSecret := (user.Password != string(action.secret.Data["password"]) &&
user.Origin == spec.RoleOriginInfrastructure)
@@ -107,8 +110,8 @@ func (action UpdateSecret) Apply() error {
return fmt.Errorf(msg, action.secretUsername, err)
}
} else {
// for non-infrastructure role - update the role with the password from
// the secret
// for non-infrastructure role - sync the in-memory data. For that we
// need to update password for the role with the value from the secret
user.Password = string(action.secret.Data["password"])
cluster.setSecretUser(action.secretUsername, user)
}
+2 -2
View File
@@ -200,7 +200,7 @@ func (c *Cluster) initUsers() error {
return nil
}
func (c *Cluster) PlanForCreate() (plan []Action) {
func (c *Cluster) PlanForCreate() (plan Plan) {
if err := c.initUsers(); err != nil {
c.logger.Errorf("Cannot init users: %v", err)
return NoActions
@@ -211,7 +211,7 @@ func (c *Cluster) PlanForCreate() (plan []Action) {
}
// TODO: mind the secrets of the deleted/new users
func (c *Cluster) PlanForSecrets() (plan []Action) {
func (c *Cluster) PlanForSecrets() (plan Plan) {
var msg string
secrets := c.generateUserSecrets()