-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: retries for policies cm comprised of multiple dependent files
Signed-off-by: Ievgenii Shepeliuk <[email protected]>
- Loading branch information
1 parent
eb518c1
commit 6f4208c
Showing
6 changed files
with
109 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
kind: ConfigMap | ||
metadata: | ||
name: multi-file-fail-policy | ||
labels: | ||
kube-mgmt/e2e: "true" | ||
openpolicyagent.org/policy: rego | ||
apiVersion: v1 | ||
data: | ||
f.rego: | | ||
package my_pkg_fail | ||
import data.my_pkg_fail.functions.my_func | ||
default my_rule := false | ||
my_rule { | ||
my_func(input.hello) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
kind: ConfigMap | ||
metadata: | ||
name: multi-file-policy | ||
labels: | ||
kube-mgmt/e2e: "true" | ||
openpolicyagent.org/policy: rego | ||
apiVersion: v1 | ||
data: | ||
a.rego: | | ||
package my_pkg | ||
import data.my_pkg.functions.my_func | ||
default my_rule := false | ||
my_rule { | ||
my_func(input.hello) | ||
} | ||
b.rego: | | ||
package my_pkg.functions | ||
my_func(str) := startswith("world", str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
set -ex | ||
|
||
OPA="http :8080/v1" | ||
|
||
${OPA}/data | jq -e '.result.default//{}|keys|length==0' | ||
|
||
kubectl apply -f "$(dirname $0)/../fixture-multi.yaml" | ||
sleep 5 | ||
|
||
${OPA}/policies | jq -e '.result|any(.id=="default/multi-file-policy/a.rego")==true' | ||
${OPA}/policies | jq -e '.result|any(.id=="default/multi-file-policy/b.rego")==true' | ||
|
||
kubectl get cm multi-file-policy -ojson | \ | ||
jq -e '.metadata.annotations["openpolicyagent.org/kube-mgmt-status"]|fromjson|.status=="ok"' | ||
kubectl get cm multi-file-policy -ojson | \ | ||
jq -e '.metadata.annotations["openpolicyagent.org/kube-mgmt-retries"]=="0"' | ||
|
||
${OPA}/data/my_pkg/my_rule input[hello]=world | jq -e '.result==true' | ||
${OPA}/data/my_pkg/my_rule input[hello]=incorrect | jq -e '.result==false' | ||
|
||
kubectl apply -f "$(dirname $0)/../fixture-multi-fail.yaml" | ||
sleep 5 | ||
|
||
${OPA}/policies | jq -e '.result|length==2' | ||
|
||
kubectl get cm multi-file-fail-policy -ojson | \ | ||
jq -e '.metadata.annotations["openpolicyagent.org/kube-mgmt-status"]|fromjson|.status=="error"' | ||
kubectl get cm multi-file-fail-policy -ojson | \ | ||
jq -e '.metadata.annotations["openpolicyagent.org/kube-mgmt-retries"]=="0"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
useHttps: false | ||
|
||
opa: null | ||
|
||
authz: | ||
enabled: false | ||
|
||
mgmt: | ||
extraArgs: | ||
- "--log-level=debug" |