Remove unreachable code (#18576)

I happened to spot that the `TemplateError` type is never instantiated.
Therefore delete it, and code referencing it.
This commit is contained in:
Max Bowsher 2023-01-03 14:02:01 +00:00 committed by GitHub
parent 9c0f145ac1
commit 8d7e70cecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 17 deletions

View File

@ -8,7 +8,7 @@ import (
"sync"
"time"
metrics "github.com/armon/go-metrics"
"github.com/armon/go-metrics"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-secure-stdlib/strutil"
lru "github.com/hashicorp/golang-lru"
@ -745,18 +745,6 @@ func (ps *PolicyStore) switchedDeletePolicy(ctx context.Context, name string, po
return nil
}
type TemplateError struct {
Err error
}
func (t *TemplateError) WrappedErrors() []error {
return []error{t.Err}
}
func (t *TemplateError) Error() string {
return t.Err.Error()
}
// ACL is used to return an ACL which is built using the
// named policies and pre-fetched policies if given.
func (ps *PolicyStore) ACL(ctx context.Context, entity *identity.Entity, policyNames map[string][]string, additionalPolicies ...*Policy) (*ACL, error) {

View File

@ -243,10 +243,6 @@ func (c *Core) fetchACLTokenEntryAndEntity(ctx context.Context, req *logical.Req
// performed on the token's namespace.
acl, err := c.policyStore.ACL(tokenCtx, entity, policyNames, policies...)
if err != nil {
if errwrap.ContainsType(err, new(TemplateError)) {
c.logger.Warn("permission denied due to a templated policy being invalid or containing directives not satisfied by the requestor", "error", err)
return nil, nil, nil, nil, logical.ErrPermissionDenied
}
c.logger.Error("failed to construct ACL", "error", err)
return nil, nil, nil, nil, ErrInternalError
}