helm: `helm version` prints warning if kubeconfig file does not exist
helm version prints a warning if the kubeconfig file does not exist.
KUBECONFIG=config-does-not-exist helm version
W0323 20:15:03.896373 34520 loader.go:223] Config not found: config-does-not-exist
version.BuildInfo{Version:"v3.1.2", GitCommit:"d878d4d45863e42fd5cff6743294a11d28a9abce", GitTreeState:"clean", GoVersion:"go1.13.8"}
This is especially problematic when the short version is used and parsed using a semver library.
KUBECONFIG=config-does-not-exist helm version --short
W0323 20:16:55.655484 34598 loader.go:223] Config not found: config-does-not-exist
v3.1.2+gd878d4d
The problem is that the Kubernetes client is always initialized which should not be necessary for the version command.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 24 (19 by maintainers)
This is still not fixed right? I’m still getting the warning anyway
I’m also coming at this from automation tools like chart-testing and the helm github actions.
I liked the direction for a fix @mattfarina @anshulvermapatel and @marckhouzam discussed. I understand the workaround in the meantime in https://github.com/helm/helm/issues/7796#issuecomment-602816914 but – my 2¢ here – not sure this can be considered fixed until commands that don’t need KUBECONFIG stop trying to find it 🤔
Ah, that said, this test case still produces an error:
Perhaps now that it’s fixed in Kubernetes there is a path forward. More investigation is warranted.
Okay, so this error occurs only when you set the
KUBECONFIGenvironment variable to a non-existent path. If youunset KUBECONFIG, it is fine. If you setKUBECONFIG=""it is fine. The warning message ONLY prints when you give it an invalid path for KUBECONFIG.Why do you believe it is a bug that if you supply it invalid information, Helm emits a warning?
Incidentally,
kubectlseems to model the same behavior (though not forkubectl help). The warning is baked into the Kubernetes libraries, and there is literally no way to shut it off. (They even ignore the log level settings when printing it.)I would propose that the best thing to do is to
KUBECONFIG="" helm versionif you do not have a valid configuration file.