Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
opa fmt with v1.0.0
  • Loading branch information
Emyrk committed Jan 2, 2025
commit d89dbb80cecedad37ebbc2b6beadf8abbcdda710
16 changes: 8 additions & 8 deletions coderd/rbac/policy.rego
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import rego.v1

# bool_flip lets you assign a value to an inverted bool.
# You cannot do 'x := !false', but you can do 'x := bool_flip(false)'
bool_flip(b) = flipped if {
bool_flip(b) := flipped if {
b
flipped = false
}

bool_flip(b) = flipped if {
bool_flip(b) := flipped if {
not b
flipped = true
}
Expand All @@ -45,17 +45,17 @@ bool_flip(b) = flipped if {
# -1: {false, true} or {false}
# 0: {}
# 1: {true}
number(set) = c if {
number(set) := c if {
count(set) == 0
c := 0
}

number(set) = c if {
number(set) := c if {
false in set
c := -1
}

number(set) = c if {
number(set) := c if {
not false in set
set[_]
c := 1
Expand All @@ -64,7 +64,7 @@ number(set) = c if {
# site, org, and user rules are all similar. Each rule should return a number
# from [-1, 1]. The number corresponds to "negative", "abstain", and "positive"
# for the given level. See the 'allow' rules for how these numbers are used.
default site = 0
default site := 0

site := site_allow(input.subject.roles)

Expand Down Expand Up @@ -93,7 +93,7 @@ org_members := {orgID |

# org is the same as 'site' except we need to iterate over each organization
# that the actor is a member of.
default org = 0
default org := 0

org := org_allow(input.subject.roles)

Expand Down Expand Up @@ -193,7 +193,7 @@ org_ok if {

# User is the same as the site, except it only applies if the user owns the object and
# the user is apart of the org (if the object has an org).
default user = 0
default user := 0

user := user_allow(input.subject.roles)

Expand Down
Loading