Skip to content

Commit

Permalink
docs(condition/translate): add comment for starts_with translate
Browse files Browse the repository at this point in the history
  • Loading branch information
wklken committed Oct 29, 2021
1 parent 76b63e8 commit 0afc611
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 0afc611

Please sign in to comment.