Skip to content

Commit

Permalink
Rename deny rule to violation
Browse files Browse the repository at this point in the history
We should push a release after merging this PR to make sure demo/example
still work.

Signed-off-by: Max Smythe <smythe@google.com>
  • Loading branch information
maxsmythe committed Jul 2, 2019
1 parent e162885 commit 4595ef4
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ spec:
rego: |
package k8srequiredlabels
deny[{"msg": msg, "details": {"missing_labels": missing}}] {
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.constraint.spec.parameters.labels[_]}
missing := required - provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
rego: |
package k8sbannedimagetags
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
img_split := split(container.image, ":")
tag := img_split[count(img_split) - 1]
Expand Down
2 changes: 1 addition & 1 deletion demo/agilebank/templates/k8sallowedrepos_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
rego: |
package k8sallowedrepos
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
satisfied := [good | repo = input.constraint.spec.parameters.repos[_] ; good = startswith(container.image, repo)]
not any(satisfied)
Expand Down
16 changes: 8 additions & 8 deletions demo/agilebank/templates/k8scontainterlimits_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,45 +124,45 @@ spec:
new := to_number(raw) * mem_multiple(suffix)
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
cpu_orig := container.resources.limits.cpu
not canonify_cpu(cpu_orig)
msg := sprintf("container <%v> cpu limit <%v> could not be parsed", [container.name, cpu_orig])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
mem_orig := container.resources.limits.memory
not canonify_mem(mem_orig)
msg := sprintf("container <%v> memory limit <%v> could not be parsed", [container.name, mem_orig])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
not container.resources
msg := sprintf("container <%v> has no resource limits", [container.name])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
not container.resources.limits
msg := sprintf("container <%v> has no resource limits", [container.name])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
missing(container.resources.limits, "cpu")
msg := sprintf("container <%v> has no cpu limit", [container.name])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
missing(container.resources.limits, "memory")
msg := sprintf("container <%v> has no memory limit", [container.name])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
cpu_orig := container.resources.limits.cpu
cpu := canonify_cpu(cpu_orig)
Expand All @@ -172,7 +172,7 @@ spec:
msg := sprintf("container <%v> cpu limit <%v> is higher than the maximum allowed of <%v>", [container.name, cpu_orig, max_cpu_orig])
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
container := input.review.object.spec.containers[_]
mem_orig := container.resources.limits.memory
mem := canonify_mem(mem_orig)
Expand Down
4 changes: 2 additions & 2 deletions demo/agilebank/templates/k8srequiredlabels_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
msg := constraint.spec.parameters.message
}
deny[{"msg": msg, "details": {"missing_labels": missing}}] {
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.constraint.spec.parameters.labels[_].key}
missing := required - provided
Expand All @@ -48,7 +48,7 @@ spec:
msg := get_message(input.constraint, def_msg)
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
value := input.review.object.metadata.labels[key]
expected := input.constraint.spec.parameters.labels[_]
expected.key == key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
flattened := concat(",", sort(selectors))
}
deny[{"msg": msg}] {
violation[{"msg": msg}] {
input.review.kind.kind == "Service"
input.review.kind.version == "v1"
input.review.kind.group == ""
Expand Down
2 changes: 1 addition & 1 deletion demo/basic/bad/bad_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
obj.apiVersion == make_apiversion(review.kind)
}
deny[{"msg": msg, "details": {"value": val, "label": label}}]
violation[{"msg": msg, "details": {"value": val, "label": label}}]
label := input.constraint.spec.parameters.label
val := input.review.object.metadata.labels[label]
cluster_objs := [o | o = data.inventory.cluster[_][_][_]; not identical_cluster(o, input.review)]
Expand Down
2 changes: 1 addition & 1 deletion demo/basic/templates/k8srequiredlabels_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
rego: |
package k8srequiredlabels
deny[{"msg": msg, "details": {"missing_labels": missing}}] {
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.constraint.spec.parameters.labels[_]}
missing := required - provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
rego: |
package k8srequiredlabels
deny[{"msg": msg, "details": {"missing_labels": missing}}] {
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.constraint.spec.parameters.labels[_]}
missing := required - provided
Expand Down
2 changes: 1 addition & 1 deletion demo/basic/templates/k8suniquelabels_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
obj.apiVersion == make_apiversion(review.kind)
}
deny[{"msg": msg, "details": {"value": val, "label": label}}] {
violation[{"msg": msg, "details": {"value": val, "label": label}}] {
label := input.constraint.spec.parameters.label
val := input.review.object.metadata.labels[label]
cluster_objs := [o | o = data.inventory.cluster[_][_][_]; not identical_cluster(o, input.review)]
Expand Down
2 changes: 1 addition & 1 deletion example/templates/k8srequiredlabels_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
rego: |
package k8srequiredlabels
deny[{"msg": msg, "details": {"missing_labels": missing}}] {
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.constraint.spec.parameters.labels[_]}
missing := required - provided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestReconcile(t *testing.T) {
Rego: `
package foo
deny[{"msg": "denied!"}] {
violation[{"msg": "denied!"}] {
1 == 1
}
`},
Expand Down Expand Up @@ -219,7 +219,7 @@ deny[{"msg": "denied!"}] {
Rego: `
package foo
deny[}}}//invalid//rego
violation[}}}//invalid//rego
`},
},
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4595ef4

Please sign in to comment.