Goju is for Go JSON UNIT tests.
It is intended to test JSON files using other json files
{
"items": [ {
"spec": {
"containers": [ {
"image": "k8s.gcr.io/heapster-amd64:v1.5.0"
}
]
}
}
]
}
is checked for regular expression by the JSON file
{
"items": {
"length" :"1",
"spec":{
"containers":{
"image":{
"matches":"^(gcr.io/(google[-_]containers|k8s-minikube)|k8s.gcr.io)"
}
}
}
}
}
This means, the items array is checked for length 1 and any images in the items/spec/containers array is checked, if the string matches the regular expression. More examples are in the data directory.
The concept is to check configurations by other configurations, and implement checks adding additional leaves in JSON or YAML.
The executable checks are invoked by reflection on a Check object and must have the same name as define in the check.go
file with a leading capital letter.
Install Goju by
go get github.com/endodoce/goju
Simply call
goju -json=data/imagepod.json -rule=data/imagerule.json
to get an output like
I0624 13:24:16.733258 3384 main.go:29] Errors : 0
I0624 13:24:16.733543 3384 main.go:30] Checks true: 2
I0624 13:24:16.733573 3384 main.go:31] Checks false: 0
The errors are parsing errors like unknown functions and the check results, which are true and false are reported