Just started to deal with conftest and OPA, I'm trying to validate a sample kubernetes deployment manifest to make sure it contains a specific key in a list (i.e. image
exists for all containers
)
here's a sample input
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
containers:
- image: hub.com/img1:tag1
imagePullPolicy: Always
I thought this policy should check the existence of image
for all containers:
deny[reason] {
input.kind == "Deployment"
some i
not input.spec.template.spec.containers[i].image
reason := "Container.image not found"
}
but conftest
throws an error complaining not input.spec.template.spec.containers[i].image
expression is unsafe
Any comments/suggestions on how to deal with this case is appreciated.