Skip to content

Commit

Permalink
Merge pull request #39 from wklken/ft_new_eval
Browse files Browse the repository at this point in the history
docs(condition/translate): add comment for starts_with translate
  • Loading branch information
wklken authored Oct 29, 2021
2 parents 9a79a2e + 0afc611 commit 4771d1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/abac/pdp/condition/string_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ func (c *StringPrefixCondition) Eval(ctx types.EvalContextor) bool {
return strings.HasPrefix(aStr, bStr)
})
}

func (c *StringPrefixCondition) Translate(withSystem bool) (map[string]interface{}, error) {
key := c.Key
if !withSystem {
key = removeSystemFromKey(key)
}

// NOTE: starts_with/ends_with/not_starts_with/not_ends_with should be
// 1. single value like: a starts_with x
// 2. multiple value like: a starts_with x OR a starts_with y
// NEVER BE `a starts_with [x, y]`
content := make([]map[string]interface{}, 0, len(c.Value))
for _, v := range c.Value {
content = append(content, map[string]interface{}{
Expand Down

0 comments on commit 4771d1c

Please sign in to comment.