Update primary error functions to take a context, deprecate old functions (#1358)

* add new error funcs which take a ctx and deprecate existing funcs

* use context where available when writing error events

* remove circular internal/errors pkg dep

* suppress some chatty errors using errors.WithoutEvent()

* convert auth oidc funcs to take context where needed to write events

Co-authored-by: Jim <jlambert@hashicorp.com>
This commit is contained in:
s-christoffandJim authored and GitHub committed 2021-07-29 20:52:56 -04:00
1 parent 02ff2db66e
commit 6b78108ecf
227 files changed
+3945 -3736

No files matched your search

+4 -4
View File
@@ -23,7 +23,7 @@ type DatabaseKey struct {
func NewDatabaseKey(rootKeyId string, _ ...Option) (*DatabaseKey, error) {
const op = "kms.NewDatabaseKey"
if rootKeyId == "" {
return nil, errors.New(errors.InvalidParameter, op, "missing root key id")
return nil, errors.NewDeprecated(errors.InvalidParameter, op, "missing root key id")
}
c := &DatabaseKey{
DatabaseKey: &store.DatabaseKey{
@@ -53,15 +53,15 @@ func (k *DatabaseKey) Clone() interface{} {
func (k *DatabaseKey) VetForWrite(ctx context.Context, r db.Reader, opType db.OpType, opt ...db.Option) error {
const op = "kms.(DatabaseKey).VetForWrite"
if k.PrivateId == "" {
return errors.New(errors.InvalidParameter, op, "missing private id")
return errors.New(ctx, errors.InvalidParameter, op, "missing private id")
}
switch opType {
case db.CreateOp:
if k.RootKeyId == "" {
return errors.New(errors.InvalidParameter, op, "missing root key id")
return errors.New(ctx, errors.InvalidParameter, op, "missing root key id")
}
case db.UpdateOp:
return errors.New(errors.InvalidParameter, op, "key is immutable")
return errors.New(ctx, errors.InvalidParameter, op, "key is immutable")
}
return nil
}