From d4ee919fb588d18864a5c40ee43aa44657536f65 Mon Sep 17 00:00:00 2001 From: Stuart McLaren Date: Tue, 16 Apr 2019 18:29:22 +0100 Subject: [PATCH] Fix kubectl version --client=true Getting the client version fails if the kubeconfig is invalid: $ kubectl version --client=true Error in configuration: * unable to read client-cert .../client.crt: no such file or directory * unable to read client-key .../client.key: no such file or directory * unable to read certificate-authority .../ca.crt: no such file or directory Update to match behaviour on v1.10.13 and earlier: $ kubectl version --client=true Client Version: version.Info{Major:"1", ...} --- pkg/kubectl/cmd/version/version.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/kubectl/cmd/version/version.go b/pkg/kubectl/cmd/version/version.go index 6827da212b..110742be00 100644 --- a/pkg/kubectl/cmd/version/version.go +++ b/pkg/kubectl/cmd/version/version.go @@ -88,6 +88,9 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *co // Complete completes all the required options func (o *Options) Complete(f cmdutil.Factory, cmd *cobra.Command) error { var err error + if o.ClientOnly { + return nil + } o.discoveryClient, err = f.ToDiscoveryClient() // if we had an empty rest.Config, continue and just print out client information. // if we had an error other than being unable to build a rest.Config, fail.