Need help: fetch multiple key values from data inventory #445
Unanswered
laxmanvallandas
asked this question in
Gatekeeper
Replies: 1 comment 2 replies
-
Hey there! And sorry for the late reply — somehow I hadn't seen this until now. You could extract the name of the namespace(s) as well when iterating over the ns_objs := {ns: o |
some ns
o := data.inventory.namespace[ns][_][_][_]
}
violation[{"msg": msg}] {
some ns
obj := ns_objs[ns]
existing := obj.metadata.annotations[input.parameters.annotation]
msg := sprintf("annotation <%v> with value <%v> already exists for another %v in namespace %v", [
input.parameters.annotation,
existing,
input.review.object.kind,
ns,
])
} This line is suspicious though: existing := obj.metadata.annotations[input.parameters.annotation] You probably want to use a value from the object submitted for review rather than a parameter here.. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, Newbie in rego here.
Below logic is mostly inspired from https://github.com/open-policy-agent/gatekeeper/blob/b7230e0bdc3479b867acd2fd0d7192b1182c59d4/demo/basic/templates/k8suniquelabel_template.yaml#L47
Is there a way in rego to directly map multiple values to a key?
Below is our violation logic.
In addition to input params, we also want to print the namespace in which annotation already exists in a service. Is that possible to achieve?
Beta Was this translation helpful? Give feedback.
All reactions