From 9ae3ee1fcbf336c6235f754cfdfb402c8f76564f Mon Sep 17 00:00:00 2001 From: Erik Stidham Date: Thu, 20 Jul 2017 16:54:58 -0500 Subject: [PATCH] Get version from datastore with version command - Retrieve CalicoVersion and ClusterType from datastore and print with version command --- calicoctl/commands/version.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/calicoctl/commands/version.go b/calicoctl/commands/version.go index 8f29e04db..b307e229c 100644 --- a/calicoctl/commands/version.go +++ b/calicoctl/commands/version.go @@ -33,7 +33,7 @@ func init() { func Version(args []string) { doc := `Usage: - calicoctl version + calicoctl version [--config=] Options: -h --help Show this screen. @@ -53,9 +53,9 @@ Description: return } - fmt.Println("Version: ", VERSION) - fmt.Println("Build date: ", BUILD_DATE) - fmt.Println("Git commit: ", GIT_REVISION) + fmt.Println("Client Version: ", VERSION) + fmt.Println("Build date: ", BUILD_DATE) + fmt.Println("Git commit: ", GIT_REVISION) // Load the client config and connect. cf := parsedArgs["--config"].(string) @@ -66,8 +66,18 @@ Description: } cfg := client.Config() - val, _, _ := cfg.GetFelixConfig("ClusterVersion", "") - fmt.Println("Cluster Version: ", val) - val, _, _ = cfg.GetFelixConfig("ClusterType", "") + val, assigned, err := cfg.GetFelixConfig("CalicoVersion", "") + if err != nil { + val = fmt.Sprintf("unknown (%s)", err) + } else if !assigned { + val = "unknown" + } + fmt.Println("Server Version: ", val) + val, assigned, err = cfg.GetFelixConfig("ClusterType", "") + if err != nil { + val = fmt.Sprintf("unknown (%s)", err) + } else if !assigned { + val = "unknown" + } fmt.Println("Cluster Type: ", val) }