Initialize arrays of errors / error messages + minor refactoring (#1701)

* init error arrays correctly
* avoid nilPointer when syncing connectionPooler
* getInfrastructureRoles should return error
* fix unit tests and return type for getInfrastructureRoles
This commit is contained in:
Felix Kunde
2021-11-29 12:49:12 +01:00
committed by GitHub
parent 3e275d122a
commit f7858ffb70
7 changed files with 38 additions and 76 deletions
+2 -2
View File
@@ -101,7 +101,7 @@ func (strategy DefaultUserSyncStrategy) ProduceSyncRequests(dbUsers spec.PgUserM
// ExecuteSyncRequests makes actual database changes from the requests passed in its arguments.
func (strategy DefaultUserSyncStrategy) ExecuteSyncRequests(requests []spec.PgSyncUserRequest, db *sql.DB) error {
var reqretries []spec.PgSyncUserRequest
var errors []string
errors := make([]string, 0)
for _, request := range requests {
switch request.Kind {
case spec.PGSyncUserAdd:
@@ -138,7 +138,7 @@ func (strategy DefaultUserSyncStrategy) ExecuteSyncRequests(requests []spec.PgSy
return err
}
} 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, `', '`))
}
}