Skip to content

Instantly share code, notes, and snippets.

@jmassardo
Created February 19, 2021 14:21
Show Gist options
  • Save jmassardo/3235d04e467c72d6c7e7aced825410cd to your computer and use it in GitHub Desktop.
Save jmassardo/3235d04e467c72d6c7e7aced825410cd to your computer and use it in GitHub Desktop.
Example of how to give a rule a custom name so it can be called individually from a unit test
# List of namespaces to exclude
excludedNamespaces = {"good", "ok"}
imageSafety[decision] {
# This rule compares the namespace from the admission controller
# to the list of namespaces above
not excludedNamespaces[input.request.namespace]
data.library.v1.kubernetes.admission.workload.v1.block_latest_image_tag[message]
decision := {
"allowed": false,
"message": message
}
}
enforce[decision]{
imageSafety[decision]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment