Skip to content
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

Stuck reading from stdin when using --directories #184

Closed
Pharb opened this issue Oct 1, 2019 · 4 comments · Fixed by #204
Closed

Stuck reading from stdin when using --directories #184

Pharb opened this issue Oct 1, 2019 · 4 comments · Fixed by #204

Comments

@Pharb
Copy link

Pharb commented Oct 1, 2019

kubeval --directories=/tmp/kubeval-input does not work properly for me when running it in my CI pipeline.

It seems to be stuck reading from stdin, even though I only want it to read from --directories.

My current workaround is to run it like this to switch to the "not-stdin" branch of the code:
kubeval --directories=/tmp/kubeval-input /dev/null

I guess there might be something wrong here: https://github.com/instrumenta/kubeval/blob/0.14.0/main.go#L68

Here are all the options I'm using:

kubeval --strict --kubernetes-version=1.14.6 --skip-kinds=CustomResourceDefinition,Prometheus,PrometheusRule,ServiceMonitor,Alertmanager --schema-location=file:///opt/kubeval-schemas --directories=/tmp/kubeval-input

Thanks for this nice tool 🎉

@stevesim101
Copy link

I have the exact same problem. Thank you @Pharb for the workaround!

@maltoe
Copy link

maltoe commented Nov 13, 2019

Same here, thank you @Pharb

@fredleger
Copy link

fredleger commented Dec 8, 2019

same here don't get why this is like this.
ex:

a) from command line in the ci container:

$ kubeval -d manifests --ignore-missing-schemas

produce

PASS - chaoskube/templates/serviceaccount.yaml contains a valid ServiceAccount
PASS - chaoskube/templates/clusterrole.yaml contains a valid ClusterRole
PASS - chaoskube/templates/clusterrolebinding.yaml contains a valid ClusterRoleBinding
PASS - chaoskube/templates/role.yaml contains a valid Role
PASS - chaoskube/templates/rolebinding.yaml contains a valid RoleBinding
PASS - chaoskube/templates/deployment.yaml contains a valid Deployment
...

In non interactive run in the ci (using same container)

$ kubeval -d manifests --ignore-missing-schema

produce

WARN - Set to ignore missing schemas
PASS - stdin contains an empty YAML document

I could just guess that there is some relation with the terminal not being a tty but it should not rely on that i think.

And more suprisingly the following is working in my CI :

    for file in $(find manifests -type f -iname '*.yaml'); do
      kubeval $file --ignore-missing-schemas
    done

carlossg added a commit to carlossg/kubeval that referenced this issue Dec 17, 2019
The check to use stdin was incorrectly true when running with no tty
and no files were passed as arguments, even though directories were
passed with -d

Fixes instrumenta#184
@DannyBen
Copy link

Thanks for this issue and workaround.
I spent the last 30 minutes trying to figure it out - it is easily reproducible on GitHub actions.

Thanks in advance for the fix - I see there is already a PR in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants