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

@@ -45,13 +45,13 @@ func GetListingScopeIds(
// Validation
switch {
case typ == resource.Unknown:
return nil, nil, errors.New(errors.InvalidParameter, op, "unknown resource")
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "unknown resource")
case repoFn == nil:
return nil, nil, errors.New(errors.InvalidParameter, op, "nil iam repo")
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "nil iam repo")
case rootScopeId == "":
return nil, nil, errors.New(errors.InvalidParameter, op, "missing root scope id")
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing root scope id")
case authResults.Scope == nil:
return nil, nil, errors.New(errors.InvalidParameter, op, "nil scope in auth results")
return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "nil scope in auth results")
}
// Base case: if not recursive, return the scope we were given and the
@@ -103,7 +103,7 @@ func GetListingScopeIds(
}
case 1:
if aSet[0] != action.List {
return nil, nil, errors.New(errors.Internal, op, "unexpected action in set")
return nil, nil, errors.New(ctx, errors.Internal, op, "unexpected action in set")
}
if scopeInfoMap[scpId] == nil {
scopeInfo := &scopes.ScopeInfo{
@@ -119,7 +119,7 @@ func GetListingScopeIds(
globalHasList = true
}
default:
return nil, nil, errors.New(errors.Internal, op, "unexpected number of actions back in set")
return nil, nil, errors.New(ctx, errors.Internal, op, "unexpected number of actions back in set")
}
}