mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-01 02:41:29 +02:00
Fix error messages (#27)
Use lowercase for kubernetes objects Use %v instead of %s for errors Start error messages with a lowercase letter.
This commit is contained in:
@@ -10,7 +10,7 @@ type ConditionFunc func() (bool, error)
|
||||
func Retry(interval time.Duration, timeout time.Duration, f ConditionFunc) error {
|
||||
//TODO: make the retry exponential
|
||||
if timeout < interval {
|
||||
return fmt.Errorf("timout(%s) should be greater than interval(%s)", timeout, interval)
|
||||
return fmt.Errorf("timout(%s) should be greater than interval(%v)", timeout, interval)
|
||||
}
|
||||
maxRetries := int(timeout / interval)
|
||||
tick := time.NewTicker(interval)
|
||||
@@ -29,5 +29,5 @@ func Retry(interval time.Duration, timeout time.Duration, f ConditionFunc) error
|
||||
}
|
||||
<-tick.C
|
||||
}
|
||||
return fmt.Errorf("Still failing after %d retries", maxRetries)
|
||||
return fmt.Errorf("still failing after %d retries", maxRetries)
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ func (t *API) TeamInfo(teamID string) (*Team, error) {
|
||||
}
|
||||
|
||||
if errMessage, ok := raw["error"]; ok {
|
||||
return nil, fmt.Errorf("Team API query failed with status code %d and message: '%s'", resp.StatusCode, string(errMessage))
|
||||
return nil, fmt.Errorf("team API query failed with status code %d and message: '%v'", resp.StatusCode, string(errMessage))
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Team API query failed with status code %d", resp.StatusCode)
|
||||
return nil, fmt.Errorf("team API query failed with status code %d", resp.StatusCode)
|
||||
}
|
||||
teamInfo := &Team{}
|
||||
d := json.NewDecoder(resp.Body)
|
||||
|
||||
@@ -60,14 +60,14 @@ func (s DefaultUserSyncStrategy) ExecuteSyncRequests(reqs []spec.PgSyncUserReque
|
||||
switch r.Kind {
|
||||
case spec.PGSyncUserAdd:
|
||||
if err := s.createPgUser(r.User, db); err != nil {
|
||||
return fmt.Errorf("Can't create user '%s': %s", r.User.Name, err)
|
||||
return fmt.Errorf("could not create user '%s': %v", r.User.Name, err)
|
||||
}
|
||||
case spec.PGsyncUserAlter:
|
||||
if err := s.alterPgUser(r.User, db); err != nil {
|
||||
return fmt.Errorf("Can't alter user '%s': %s", r.User.Name, err)
|
||||
return fmt.Errorf("could not alter user '%s': %v", r.User.Name, err)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Unrecognized operation: %v", r.Kind)
|
||||
return fmt.Errorf("unrecognized operation: %v", r.Kind)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func (s DefaultUserSyncStrategy) createPgUser(user spec.PgUser, db *sql.DB) (err
|
||||
|
||||
_, err = db.Query(query) // TODO: Try several times
|
||||
if err != nil {
|
||||
err = fmt.Errorf("DB error: %s, query: %s", err, query)
|
||||
err = fmt.Errorf("dB error: %s, query: %v", err, query)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func (s DefaultUserSyncStrategy) alterPgUser(user spec.PgUser, db *sql.DB) (err
|
||||
|
||||
_, err = db.Query(query) // TODO: Try several times
|
||||
if err != nil {
|
||||
err = fmt.Errorf("DB error: %s query %s", err, query)
|
||||
err = fmt.Errorf("dB error: %s query %v", err, query)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user