Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,6 @@ linters:
- prealloc
- unconvert
- copyloopvar
# - perfsprint # reenable after https://github.com/open-policy-agent/opa-envoy-plugin/issues/729 is complete
- perfsprint
- gocritic
# - gosec # too many false positives
6 changes: 3 additions & 3 deletions envoyauth/evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package envoyauth

import (
"context"
"fmt"
"errors"

"github.com/open-policy-agent/opa/v1/ast"
"github.com/open-policy-agent/opa/v1/config"
Expand Down Expand Up @@ -110,9 +110,9 @@ func Eval(ctx context.Context, evalContext EvalContext, input ast.Value, result
case err != nil:
return err
case len(rs) == 0:
return fmt.Errorf("undefined decision")
return errors.New("undefined decision")
case len(rs) > 1:
return fmt.Errorf("multiple evaluation results")
return errors.New("multiple evaluation results")
}

result.NDBuiltinCache = ndbCache
Expand Down
2 changes: 1 addition & 1 deletion envoyauth/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func getGRPCBody(logger logging.Logger, in []byte, parsedPath []string, data any
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md

if len(in) < 5 {
return false, false, fmt.Errorf("less than 5 bytes")
return false, false, errors.New("less than 5 bytes")
}

// Can be 0 or 1, 1 indicates that the payload is compressed.
Expand Down
7 changes: 4 additions & 3 deletions envoyauth/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package envoyauth
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"slices"
Expand Down Expand Up @@ -127,7 +128,7 @@ func (result *EvalResult) IsAllowed() (bool, error) {
var ok, allowed bool

if val, ok = decision["allowed"]; !ok {
return false, fmt.Errorf("unable to determine evaluation result due to missing \"allowed\" key")
return false, errors.New("unable to determine evaluation result due to missing \"allowed\" key")
}

if allowed, ok = val.(bool); !ok {
Expand Down Expand Up @@ -299,7 +300,7 @@ func (result *EvalResult) GetResponseHTTPStatus() (int, error) {
switch decision := result.Decision.(type) {
case bool:
if decision {
return http.StatusOK, fmt.Errorf("HTTP status code undefined for simple 'allow'")
return http.StatusOK, errors.New("HTTP status code undefined for simple 'allow'")
}

return status, nil
Expand Down Expand Up @@ -332,7 +333,7 @@ func (result *EvalResult) GetDynamicMetadata() (*_structpb.Struct, error) {
switch decision := result.Decision.(type) {
case bool:
if decision {
return nil, fmt.Errorf("dynamic metadata undefined for boolean decision")
return nil, errors.New("dynamic metadata undefined for boolean decision")
}
case map[string]any:
var (
Expand Down
2 changes: 1 addition & 1 deletion internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func Validate(m *plugins.Manager, bs []byte) (*Config, error) {
}

if cfg.Path != "" && cfg.Query != "" {
return nil, fmt.Errorf("invalid config: specify a value for only the \"path\" field")
return nil, errors.New("invalid config: specify a value for only the \"path\" field")
}

var parsedQuery ast.Body
Expand Down
2 changes: 1 addition & 1 deletion internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2583,5 +2583,5 @@ func (_ *testPluginError) Reconfigure(context.Context, any) {

func (p *testPluginError) Log(_ context.Context, event logs.EventV1) error {
p.events = append(p.events, event)
return fmt.Errorf("Bad Logger Error")
return errors.New("Bad Logger Error")
}