ContextInject attempts to inject the rbac object for the cached workspace fields into the given context, either returning the wrapped context or the original.
(ctx context.Context)
| 68 | // ContextInject attempts to inject the rbac object for the cached workspace fields |
| 69 | // into the given context, either returning the wrapped context or the original. |
| 70 | func (cws *CachedWorkspaceFields) ContextInject(ctx context.Context) (context.Context, error) { |
| 71 | var err error |
| 72 | rbacCtx := ctx |
| 73 | if dbws, ok := cws.AsWorkspaceIdentity(); ok { |
| 74 | rbacCtx, err = dbauthz.WithWorkspaceRBAC(ctx, dbws.RBACObject()) |
| 75 | if err != nil { |
| 76 | // Don't error level log here, will exit the function. We want to fall back to GetWorkspaceByAgentID. |
| 77 | //nolint:gocritic |
| 78 | return ctx, xerrors.Errorf("Cached workspace was present but RBAC object was invalid: %w", err) |
| 79 | } |
| 80 | } |
| 81 | return rbacCtx, nil |
| 82 | } |
nothing calls this directly
no test coverage detected