Comments (5)
I wonder if .class
is the cause of the problem. It's a reserved word in Ruby and a lot of other languages.
What happens if you use the bracket-style for the child node? i.e., "$.metadata.annotations.ingress['class']"
from copper.
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:
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...
}
And the result of running both in Copper:
copper check --rules ingress.cop --file ingress-good.yaml
Validating part 0
IngressAnnotation - FAIL
from copper.
Copper uses JSONPath format in which .
has a special meaning. You can use [
to refernece attributes better. For more details, please see https://goessner.net/articles/JsonPath/
from copper.
D'oh! I missed that ingress.class
was a single path component.
Given:
metadata:
annotations:
kubernetes.io/ingress.class: eurekap
You should use:
"$.metadata.annotations['kubernetes.io/ingress.class']"
from copper.
@docwhat that worked! Thanks.
from copper.
Related Issues (17)
- Rules for validating the filename and/or path HOT 2
- Fail to install Copper using rubygems HOT 3
- Returns 0 when tests fail HOT 2
- How to filter by object type HOT 4
- Current getting started doc formats to an emdash, appearing to be the wrong syntax for CLI parameters HOT 1
- reading yml files from directory HOT 1
- Return code only reflects validation of the last segment HOT 1
- kubetest HOT 1
- basic example fails with (<unknown>): mapping values are not allowed in this context at line 11 column 22 (Psych::SyntaxError) HOT 2
- Documentation off HOT 1
- gem ships binaries that conflict HOT 2
- Copper handles yaml files beginning with `---` incorrectly HOT 2
- interface {} is []interface {}, not []map[string]interface {}
- add lodash to libjs
- Add ES6 javascript engine for validators HOT 1
- Update copper.sh? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copper.