forked from TrueCloudLab/certificates
Use short if-style statements
This commit is contained in:
parent
5f224b729e
commit
f9ae875f9d
3 changed files with 6 additions and 12 deletions
|
@ -297,8 +297,7 @@ func (h *Handler) validateExternalAccountBinding(ctx context.Context, nar *NewAc
|
||||||
}
|
}
|
||||||
|
|
||||||
var payloadJWK *jose.JSONWebKey
|
var payloadJWK *jose.JSONWebKey
|
||||||
err = json.Unmarshal(payload, &payloadJWK)
|
if err = json.Unmarshal(payload, &payloadJWK); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, acme.WrapError(acme.ErrorMalformedType, err, "error unmarshaling payload into jwk")
|
return nil, acme.WrapError(acme.ErrorMalformedType, err, "error unmarshaling payload into jwk")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,8 +251,7 @@ func (db *DB) DeleteExternalAccountKey(ctx context.Context, provisionerName, key
|
||||||
return errors.Wrapf(err, "error deleting ACME EAB Key Reference with Key ID %s and reference %s", keyID, dbeak.Reference)
|
return errors.Wrapf(err, "error deleting ACME EAB Key Reference with Key ID %s and reference %s", keyID, dbeak.Reference)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = db.db.Del(externalAccountKeyTable, []byte(keyID))
|
if err = db.db.Del(externalAccountKeyTable, []byte(keyID)); err != nil {
|
||||||
if err != nil {
|
|
||||||
return errors.Wrapf(err, "error deleting ACME EAB Key with Key ID %s", keyID)
|
return errors.Wrapf(err, "error deleting ACME EAB Key with Key ID %s", keyID)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -102,8 +102,7 @@ func (h *Handler) CreateExternalAccountKey(w http.ResponseWriter, r *http.Reques
|
||||||
k, err := h.acmeDB.GetExternalAccountKeyByReference(r.Context(), prov, reference)
|
k, err := h.acmeDB.GetExternalAccountKeyByReference(r.Context(), prov, reference)
|
||||||
// retrieving an EAB key from DB results in an error if it doesn't exist, which is what we're looking for,
|
// retrieving an EAB key from DB results in an error if it doesn't exist, which is what we're looking for,
|
||||||
// but other errors can also happen. Return early if that happens; continuing if it was acme.ErrNotFound.
|
// but other errors can also happen. Return early if that happens; continuing if it was acme.ErrNotFound.
|
||||||
shouldWriteError := err != nil && !errors.Is(err, acme.ErrNotFound)
|
if shouldWriteError := err != nil && !errors.Is(err, acme.ErrNotFound); shouldWriteError {
|
||||||
if shouldWriteError {
|
|
||||||
api.WriteError(w, admin.WrapErrorISE(err, "could not lookup external account key by reference"))
|
api.WriteError(w, admin.WrapErrorISE(err, "could not lookup external account key by reference"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -164,16 +163,14 @@ func (h *Handler) GetExternalAccountKeys(w http.ResponseWriter, r *http.Request)
|
||||||
limit int
|
limit int
|
||||||
)
|
)
|
||||||
|
|
||||||
cursor, limit, err = api.ParseCursor(r)
|
if cursor, limit, err = api.ParseCursor(r); err != nil {
|
||||||
if err != nil {
|
|
||||||
api.WriteError(w, admin.WrapError(admin.ErrorBadRequestType, err,
|
api.WriteError(w, admin.WrapError(admin.ErrorBadRequestType, err,
|
||||||
"error parsing cursor and limit from query params"))
|
"error parsing cursor and limit from query params"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if reference != "" {
|
if reference != "" {
|
||||||
key, err = h.acmeDB.GetExternalAccountKeyByReference(r.Context(), prov, reference)
|
if key, err = h.acmeDB.GetExternalAccountKeyByReference(r.Context(), prov, reference); err != nil {
|
||||||
if err != nil {
|
|
||||||
api.WriteError(w, admin.WrapErrorISE(err, "error retrieving external account key with reference '%s'", reference))
|
api.WriteError(w, admin.WrapErrorISE(err, "error retrieving external account key with reference '%s'", reference))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -181,8 +178,7 @@ func (h *Handler) GetExternalAccountKeys(w http.ResponseWriter, r *http.Request)
|
||||||
keys = []*acme.ExternalAccountKey{key}
|
keys = []*acme.ExternalAccountKey{key}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
keys, nextCursor, err = h.acmeDB.GetExternalAccountKeys(r.Context(), prov, cursor, limit)
|
if keys, nextCursor, err = h.acmeDB.GetExternalAccountKeys(r.Context(), prov, cursor, limit); err != nil {
|
||||||
if err != nil {
|
|
||||||
api.WriteError(w, admin.WrapErrorISE(err, "error retrieving external account keys"))
|
api.WriteError(w, admin.WrapErrorISE(err, "error retrieving external account keys"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue