-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
15 additions
and
17 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
File renamed without changes.
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 |
---|---|---|
@@ -1,24 +1,22 @@ | ||
package kubernetes.validating.images | ||
|
||
import future.keywords.contains | ||
import future.keywords.if | ||
import future.keywords.in | ||
import rego.v1 | ||
|
||
deny contains msg if { | ||
input.request.kind.kind == "Pod" | ||
input.request.kind.kind == "Pod" | ||
|
||
# The `some` keyword declares local variables. This rule declares a variable | ||
# called `container`, with the value any of the input request's spec's container | ||
# objects. It then checks if the container object's `"image"` field does not | ||
# start with "hooli.com/". | ||
some container in input.request.object.spec.containers | ||
endswith(container.image, ":latest") | ||
msg := sprintf("Tag 'latest' is forbidden for image %v", [container.image]) | ||
# The `some` keyword declares local variables. This rule declares a variable | ||
# called `container`, with the value any of the input request's spec's container | ||
# objects. It then checks if the container object's `"image"` field does not | ||
# start with "hooli.com/". | ||
some container in input.request.object.spec.containers | ||
endswith(container.image, ":latest") | ||
msg := sprintf("Tag 'latest' is forbidden for image %v", [container.image]) | ||
} | ||
|
||
deny contains msg if { | ||
input.request.kind.kind == "Pod" | ||
some container2 in input.request.object.spec.containers | ||
not contains(container2.image, ":") | ||
msg := sprintf("Image must contains a tag for image %v", [container2.image]) | ||
input.request.kind.kind == "Pod" | ||
some container2 in input.request.object.spec.containers | ||
not contains(container2.image, ":") | ||
msg := sprintf("Image must contains a tag for image %v", [container2.image]) | ||
} |