-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
problem reading annotations, e.g. can't modify frozen String (FrozenError) #13
Comments
I wonder if What happens if you use the bracket-style for the child node? i.e., |
Thanks @docwhat, I tried that and it is better as I no longer get the "FrozenError" but the rule assertion fails. Getting closer... My yaml input: rule IngressAnnotation ensure {
// fetch("$.metadata.annotations.kubernetes.io/ingress.class").first == "eurekap" // Doesn't work, error: can't modify frozen String (FrozenError)
fetch("$.metadata.annotations.ingress['class']").first == "eurekap" // The assertion fails "IngressAnnotation - FAIL" better than the frozen string error...
} My rule file:
And the result of running both in Copper: copper check --rules ingress.cop --file ingress-good.yaml
Validating part 0
IngressAnnotation - FAIL |
Copper uses JSONPath format in which |
D'oh! I missed that Given: metadata:
annotations:
kubernetes.io/ingress.class: eurekap You should use: "$.metadata.annotations['kubernetes.io/ingress.class']" |
@docwhat that worked! Thanks. |
Hello Again,
I am trying to validate that a simple Ingress .yaml contains a certain ingress class in its annotations yet, I get:
I think it has something to do with the
.
and/
in my annotation values.Here is my input yaml:
Here is my Copper rule file:
And when I run Copper, I get the following error:
If I modify both my .yaml and the rule to get rid of the slashes and dots in the annotation element, it works. I can't use that as a solution though. So, its got something to do with the format of my annotation and not sure how to get it to read them properly.
For example, if I modify my .yaml and rule to change my annotation from
kubernetes.io/ingress.class
toingress-class
it works.The Copper rule to be:
Then it works:
Thanks for your help.
The text was updated successfully, but these errors were encountered: