-
Notifications
You must be signed in to change notification settings - Fork 114
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
Couldn't Parse the Correct {{ .ResourceKind }}
Variable Value
#110
Comments
{{ .ResourceKind }}
Variable{{ .ResourceKind }}
Variable Value
For everyone facing the same issue, for file in ./input/*.yaml; do
check=$(yq e '.items[0]' "${file}")
if [ "$check" == "null" ]; then
crd_kind=$(yq e '.spec.names.kind' "${file}" | tr '[:upper:]' '[:lower:]')
crd_apiversion=$(yq e '.spec.versions[0].name' "${file}" | tr '[:upper:]' '[:lower:]')
path="./schemas/${crd_kind}_${crd_apiversion}.json"
echo $path
kubeconform -summary -output json -ignore-missing-schemas -schema-location default -schema-location ${path} ${file}
else
crd_kind=$(yq e '.items[0].spec.names.kind' "${file}" | tr '[:upper:]' '[:lower:]')
crd_apiversion=$(yq e '.items[0].spec.versions[0].name' "${file}" | tr '[:upper:]' '[:lower:]')
path="./schemas/${crd_kind}_${crd_apiversion}.json"
echo $path
kubeconform -summary -output json -ignore-missing-schemas -schema-location default -schema-location ${path} ${file}
fi
done Hope this can help !! and looking for a true solution to |
ok, now that wrote all the details, I'm able to understand why this is not working for you. your CRs are validated correctly. this is why I wasn't able to reproduce the issue that you described here. So just to make sure we are aligned - the issue that you're having is that you're not able to validate the CRD that defines the Prometheus CR. @royhadad wrote here why this is happening and suggested a workaround that you can use. because this workaround was already merged to datree, you can also use it to make your script shorter: |
Specified as local is work! example: kubeconform -summary -output json -schema-location |
Hi all,
When I tried to manage my CRDs and validate them using Kubeconform, I got a problem with parsing the correct
Kind
from myyaml file
to match the new schema generated file.Process
kubeconform -schema-location default --schema-location '{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json' <crd-name-file.yaml>
Input
Here some of my CRDs ready to be converted, with the format:
{crd-kind}-{apiversion}
My Kubeconfrom version
Expected
By this, I expected to have all my yaml files converted and checked with kubeconform
Output
With
. ├── input │ └── prom-crd.yaml ├── schemas │ └── prometheus_v1.json └── script-crd.sh 2 directories, 3 files
AND
Troubleshooting
For instance and as the error msg shows, I found that
{{ .ResourceKind }}
variable is containing theCustomResourceDefinition
valueWhile I was expecting to have
prometheus
valueI checked that by passing a static correct ResourceKind
Thank you !!
The text was updated successfully, but these errors were encountered: