From 7f6ee39cb81613f9930ac9bf4f4336d8384e7e7d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 1 Nov 2023 11:02:16 +0300 Subject: [PATCH] [#14] Fix linter warnings Signed-off-by: Evgenii Stratonikov --- chain.go | 3 +-- error.go | 2 +- iam/converter.go | 1 + inmemory.go | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/chain.go b/chain.go index 922f5d8..938854d 100644 --- a/chain.go +++ b/chain.go @@ -101,7 +101,7 @@ func (c *Condition) Match(req Request) bool { switch c.Op { default: - panic(fmt.Sprintf("unimplemented: %s", c.Op)) + panic(fmt.Sprintf("unimplemented: %d", c.Op)) case CondStringEquals: return val == c.Value case CondStringNotEquals: @@ -153,7 +153,6 @@ func (r *Rule) matchCondition(obj Request) (status Status, matched bool) { func (r *Rule) matchAny(obj Request) (status Status, matched bool) { for i := range r.Condition { if r.Condition[i].Match(obj) { - return r.Status, true } } diff --git a/error.go b/error.go index e834b10..3fc1c59 100644 --- a/error.go +++ b/error.go @@ -2,7 +2,7 @@ package policyengine import "fmt" -// Status is the status for policy application +// Status is the status for policy application. type Status byte const ( diff --git a/iam/converter.go b/iam/converter.go index 8ddc22a..637bf35 100644 --- a/iam/converter.go +++ b/iam/converter.go @@ -109,6 +109,7 @@ func (p Policy) ToChain() (*policyengine.Chain, error) { return &chain, nil } +//nolint:funlen func (c Conditions) ToChainCondition() ([]policyengine.Condition, error) { var conditions []policyengine.Condition diff --git a/inmemory.go b/inmemory.go index a8e0684..5bd4f4c 100644 --- a/inmemory.go +++ b/inmemory.go @@ -20,8 +20,7 @@ func NewInMemory() CachedChainStorage { } } -// TODO параметры для actor (IP) -// TODO +// IsAllowed implements the Engine interface. func (s *inmemory) IsAllowed(name Name, namespace string, r Request) (Status, bool) { var ruleFound bool if local, ok := s.local[name]; ok {