violation to check if key exists #525
-
How do I raise a violation if a key is missing in a pod? For example, this violation prevents a pod being created if nodeSelectorTerms don't match. However it ignores the pod if the affinity configuration is missing.
Do I need another violation to check if Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This works using
|
Beta Was this translation helpful? Give feedback.
-
If you want to make that attribute required, I'd add another violation. That way you'll can have the error message explain in detail why it fails: violation[{"msg": msg}] {
not pod.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms
msg := "missing required pod.spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms"
} |
Beta Was this translation helpful? Give feedback.
If you want to make that attribute required, I'd add another violation. That way you'll can have the error message explain in detail why it fails: