-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Recursively traverse a directory containing Kubernetes YAML files #353
Comments
Hey, you can utilise your shells filename expansion features and achieve this with On the other hand, I'd be happy to accept a PR to fix the newline bug: kube-score/cmd/kube-score/main.go Line 37 in ac55fb0
|
I can certainly appreciate the desire to lean on shell features (Unix philosophy and all that) and keep the code as simple as possible. Yet, I also think there's value to making the small UX improvement. A limitation of using I'll open a PR to fix the newline issue, thanks for the pointer! |
They do! In the default output format kube-score doesn't display the file paths (the json and serif formats do), but the support for tracking the filenames is there, even if the data comes from templated helm. Here's some examples from the testdata: $ helm template score/testdata/helm/app1 | kube-score score - --output-format json | jq '.[].file_name'
"app1/templates/deployment.yaml"
"app1/templates/deployment.yaml" $ kube-score score score/testdata/ingress-* --output-format json | jq '.[].file_name'
"/Users/gustav/src/kube-score/score/testdata/ingress-v1-invalid-backend.yaml"
"/Users/gustav/src/kube-score/score/testdata/ingress-targets-service.yaml"
"/Users/gustav/src/kube-score/score/testdata/ingress-networkingv1-targets-service.yaml"
"/Users/gustav/src/kube-score/score/testdata/ingress-networkingv1beta1-targets-service.yaml"
"/Users/gustav/src/kube-score/score/testdata/ingress-targets-service.yaml"
This might very well be true, but it's still hard to get right. Should symlinks be followed? Should non |
But how would that work with nested folders? When I generate templates with helmfile these end up in nested file structures. |
@Morriz - I managed to use the following for nested folders: @zegl - I really like this tool, but agree that it would be much easier if kube-score supported this functionality natively. Also note that the default docker image is build on |
When I pass all the files to kube-score using find then finding where the object is located is difficult in human output format (working with helm charts that have complex dependent charts). And it is a human who reads it, so making it json format is not desired. When I print the file name and then run kube-score file-by-file then I would get a bunch of errors about missing "network policies" etc (obviously). I think it would be helpful to print the file name when kube-score was executed with more than 1 file as the input. As demonstrated earlier, the program already has the information when using "json" output. Perhaps this should be a separate issue? Since this issue is about recursive path traversing and it can easely be solved with find or xargs example. I have created a fork that does something like this, I am not sure if it is PR worthy though since I did not write tests for it but the current tests do still pass: martivo@913eee6 The best part of it is that it also works when passing a "helm template ." through stdin. |
Currently,
kube-score
emits an error if passing a directory name ti the score function:(Sidenote: this also seems to be missing a trailing newline)
By contrast, kube-linter recursively traverses the directory and lints everything, emitting the filenames and errors for each, which is extremely convenient in a CI pipeline:
I'd love to contribute a feature like this to kube-score, but will need some guidance on how to do so 😄
The text was updated successfully, but these errors were encountered: