yannh / kubeconform

A FAST Kubernetes manifests validator, with support for Custom Resources!
Apache License 2.0
2.07k stars 116 forks source link

Unable to pipe YAMLs to the kubeconform container #250

Closed Skaronator closed 7 months ago

Skaronator commented 7 months ago

I'm trying to pipe my YAML manifest to the kubeconform container, but I'm unable to do so.

Here is a minimal reproduction:

$ echo "" | docker run -it ghcr.io/yannh/kubeconform:latest
the input device is not a TTY

kubeconform expects an TTY, but it seems like that is not possible when piping in data to a docker run command. I don't think the TTY should be necessary in that case anyway.


The use case for me is that I use my devops-toolbox that contains all handy tools for me within that container. My command looks like this:

$ kubectl kustomize cert-manager --enable-helm | kubeconform -schema-location default -strict -summary
the input device is not a TTY
write /dev/stdout: broken pipe

Where kubectl and kubeconform are both just docker commands:

$ type kubectl
kubectl is aliased to `docker run -it -e HOME -e USER -v $PWD:/workdir -v $HOME/.kube/config:$HOME/.kube/config ghcr.io/skaronator/devops-toolbox:latest kubectl'
$ type kubeconform
kubeconform is aliased to `docker run -it -e HOME -e USER -v $PWD:/workdir -v $HOME/.kube/config:$HOME/.kube/config ghcr.io/skaronator/devops-toolbox:latest kubeconform'
Skaronator commented 7 months ago

Now I feel stupid. I tried everything and double-checked everything but yeah... That error is from docker not from kubeconform.

Edit: the -i needs to be removed.

$ echo "" | docker run -t ghcr.io/yannh/kubeconform:latest
2023/12/20 13:04:21 failing to read data from stdin

Works!