itaysk / kubectl-neat

Clean up Kubernetes yaml and json output to make it readable
Apache License 2.0
1.7k stars 101 forks source link

Allow multipart yaml files #49

Closed howardjohn closed 3 months ago

howardjohn commented 3 years ago

When not piping from kubectl directly, there are cases to run neat over multipart yaml docs such as

kind: Deployment
...
---
kind: Service
...

Currently, only the first one is returned and the rest are dropped silently

itaysk commented 3 years ago

Hi @howardjohn , Currently kubectl-neat, and also the internal Neat function operates on Kubernetes resources, as opposed to general yaml documents. Multi doc yaml files are not valid Kubernetes resources, so to work around this, I hacked together a solution (https://github.com/itaysk/kubectl-neat/pull/50) that converts the multidoc yaml to a Kubernetes List resource, and Neats that list. It means that you will be able to pass in a multidoc yaml but the result will be a kubernetes list. Is that acceptable solution for your case?

jonny08152 commented 2 years ago

This is exactly what I was looking for. Converting the yamls to a valid kubernetes item list works perfectly for comparing multiple yamls in one go.

I would love to see this getting merged into the main release.

jonny08152 commented 2 years ago

would it also be possible to sort the output list in a consistent way?

buckleyGI commented 1 year ago

Hi @itaysk Is it still on your radar to merge in this PR? I'm using neat in combination with ketall and it outputs only the first resource as @howardjohn mentions. Thanks for considering the merge!

kubectl get-all -n nginxsample -o yaml | k neat

itaysk commented 3 months ago

kubectl-neat is meant to be operating on the output of kubectl, and I don't think kubectl ever emits multipart yaml, instead it emits a "List" kind which kubectl-neat already supports. So I'm closing this one.