Added `--client` flag to `odo version`
This PR adds `--client` flag to `odo version` command so that,
to check only client version, we dont need to talk to server.
(Similar to `kubectl`)
Usage:
```
odo version --client
```
@@ -2,10 +2,11 @@ package cmd
import (
"fmt"
- "github.com/redhat-developer/odo/pkg/odo/util"
"os"
"strings"
+ "github.com/redhat-developer/odo/pkg/odo/util"
+
"github.com/golang/glog"
"github.com/spf13/cobra"
)
@@ -20,6 +21,8 @@ var (
GITCOMMIT = "HEAD"
)
+var clientFlag bool
+
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
@@ -40,12 +43,12 @@ var versionCmd = &cobra.Command{
fmt.Println("odo " + VERSION + " (" + GITCOMMIT + ")")
+ if !clientFlag {
// turning off the flag which checks for login status
util.GlobalSkipConnectionCheck = true
// Lets fetch the info about the server
serverInfo, err := util.GetOcClient().GetServerVersion()
util.CheckError(err, "")
-
// make sure we only include Openshift info if we actually have it
openshiftStr := ""
if len(serverInfo.OpenShiftVersion) > 0 {
@@ -58,6 +61,7 @@ var versionCmd = &cobra.Command{
serverInfo.Address,
openshiftStr,
serverInfo.KubernetesVersion)
+ }
},
}
@@ -65,6 +69,7 @@ func init() {
// Add a defined annotation in order to appear in the help menu
versionCmd.Annotations = map[string]string{"command": "utility"}
versionCmd.SetUsageTemplate(cmdUsageTemplate)
+ versionCmd.Flags().BoolVar(&clientFlag, "client", false, "Client version only (no server required).")
rootCmd.AddCommand(versionCmd)
}
