getInfrastructureRoles should return error
This commit is contained in:
		
							parent
							
								
									7edc14dfb3
								
							
						
					
					
						commit
						4bbf1e9d24
					
				|  | @ -506,7 +506,7 @@ func (c *Cluster) deleteSecrets() error { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if len(errors) > 0 { | 	if len(errors) > 0 { | ||||||
| 		return fmt.Errorf("could not delete all secrets: %v", errors) | 		return fmt.Errorf("could not delete all secrets: %v", strings.Join(errors, `', '`)) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
|  |  | ||||||
|  | @ -195,9 +195,9 @@ func (c *Controller) getInfrastructureRoleDefinitions() []*config.Infrastructure | ||||||
| 
 | 
 | ||||||
| func (c *Controller) getInfrastructureRoles( | func (c *Controller) getInfrastructureRoles( | ||||||
| 	rolesSecrets []*config.InfrastructureRole) ( | 	rolesSecrets []*config.InfrastructureRole) ( | ||||||
| 	map[string]spec.PgUser, []error) { | 	map[string]spec.PgUser, error) { | ||||||
| 
 | 
 | ||||||
| 	errors := make([]error, 0) | 	errors := make([]string, 0) | ||||||
| 	noRolesProvided := true | 	noRolesProvided := true | ||||||
| 	roles := []spec.PgUser{} | 	roles := []spec.PgUser{} | ||||||
| 	uniqRoles := map[string]spec.PgUser{} | 	uniqRoles := map[string]spec.PgUser{} | ||||||
|  | @ -220,30 +220,32 @@ func (c *Controller) getInfrastructureRoles( | ||||||
| 		infraRoles, err := c.getInfrastructureRole(secret) | 		infraRoles, err := c.getInfrastructureRole(secret) | ||||||
| 
 | 
 | ||||||
| 		if err != nil || infraRoles == nil { | 		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 { | 			if err != nil { | ||||||
| 				errors = append(errors, err) | 				errors = append(errors, fmt.Sprintf("%v", err)) | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		for _, r := range infraRoles { | 		roles = append(roles, infraRoles...) | ||||||
| 			roles = append(roles, r) |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for _, r := range roles { | 	for _, r := range roles { | ||||||
| 		if _, exists := uniqRoles[r.Name]; exists { | 		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) | 			c.logger.Debugf(msg, r.Name, uniqRoles[r.Name], r) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		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
 | // Generate list of users representing one infrastructure role based on its
 | ||||||
|  |  | ||||||
|  | @ -138,7 +138,7 @@ func (strategy DefaultUserSyncStrategy) ExecuteSyncRequests(requests []spec.PgSy | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			return fmt.Errorf("could not execute sync requests for users: %v", errors) | 			return fmt.Errorf("could not execute sync requests for users: %v", strings.Join(errors, `', '`)) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue