add --client flag to virtctl version
@@ -12,6 +12,8 @@ import (
"kubevirt.io/kubevirt/pkg/virtctl/templates"
)
+var clientOnly bool
+
func VersionCommand(clientConfig clientcmd.ClientConfig) *cobra.Command {
cmd := &cobra.Command{
Use: "version",
@@ -23,6 +25,7 @@ func VersionCommand(clientConfig clientcmd.ClientConfig) *cobra.Command {
return v.Run(cmd, args)
},
}
+ cmd.Flags().BoolVarP(&clientOnly, "client", "c", clientOnly, "Client version only (no server required).")
cmd.SetUsageTemplate(templates.UsageTemplate())
return cmd
}
@@ -40,6 +43,7 @@ type Version struct {
func (v *Version) Run(cmd *cobra.Command, args []string) error {
fmt.Printf("Client Version: %s\n", fmt.Sprintf("%#v", version.Get()))
+ if !clientOnly {
virCli, err := kubecli.GetKubevirtClientFromClientConfig(v.clientConfig)
if err != nil {
return err
@@ -51,5 +55,7 @@ func (v *Version) Run(cmd *cobra.Command, args []string) error {
}
fmt.Printf("Server Version: %s\n", fmt.Sprintf("%#v", serverInfo))
+ }
+
return nil
}
