mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-04 23:31:25 +02:00
getInfrastructureRoles should return error
This commit is contained in:
+11
-9
@@ -195,9 +195,9 @@ func (c *Controller) getInfrastructureRoleDefinitions() []*config.Infrastructure
|
||||
|
||||
func (c *Controller) getInfrastructureRoles(
|
||||
rolesSecrets []*config.InfrastructureRole) (
|
||||
map[string]spec.PgUser, []error) {
|
||||
map[string]spec.PgUser, error) {
|
||||
|
||||
errors := make([]error, 0)
|
||||
errors := make([]string, 0)
|
||||
noRolesProvided := true
|
||||
roles := []spec.PgUser{}
|
||||
uniqRoles := map[string]spec.PgUser{}
|
||||
@@ -220,30 +220,32 @@ func (c *Controller) getInfrastructureRoles(
|
||||
infraRoles, err := c.getInfrastructureRole(secret)
|
||||
|
||||
if err != nil || infraRoles == nil {
|
||||
c.logger.Debugf("Cannot get infrastructure role: %+v", *secret)
|
||||
c.logger.Debugf("cannot get infrastructure role: %+v", *secret)
|
||||
|
||||
if err != nil {
|
||||
errors = append(errors, err)
|
||||
errors = append(errors, fmt.Sprintf("%v", err))
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
for _, r := range infraRoles {
|
||||
roles = append(roles, r)
|
||||
}
|
||||
roles = append(roles, infraRoles...)
|
||||
}
|
||||
|
||||
for _, r := range roles {
|
||||
if _, exists := uniqRoles[r.Name]; exists {
|
||||
msg := "Conflicting infrastructure roles: roles[%s] = (%q, %q)"
|
||||
msg := "conflicting infrastructure roles: roles[%s] = (%q, %q)"
|
||||
c.logger.Debugf(msg, r.Name, uniqRoles[r.Name], r)
|
||||
}
|
||||
|
||||
uniqRoles[r.Name] = r
|
||||
}
|
||||
|
||||
return uniqRoles, errors
|
||||
if len(errors) > 0 {
|
||||
return nil, fmt.Errorf(strings.Join(errors, `', '`))
|
||||
}
|
||||
|
||||
return uniqRoles, nil
|
||||
}
|
||||
|
||||
// Generate list of users representing one infrastructure role based on its
|
||||
|
||||
Reference in New Issue
Block a user