Skip to content

Commit d4ee919

Browse files
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", ...}
1 parent 440d086 commit d4ee919

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/kubectl/cmd/version/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *co
8888
// Complete completes all the required options
8989
func (o *Options) Complete(f cmdutil.Factory, cmd *cobra.Command) error {
9090
var err error
91+
if o.ClientOnly {
92+
return nil
93+
}
9194
o.discoveryClient, err = f.ToDiscoveryClient()
9295
// if we had an empty rest.Config, continue and just print out client information.
9396
// if we had an error other than being unable to build a rest.Config, fail.

0 commit comments

Comments
 (0)