Skip to content

Commit

Permalink
Get version from datastore with version command
Browse files Browse the repository at this point in the history
- Retrieve CalicoVersion and ClusterType from datastore and print with
  version command
  • Loading branch information
tmjd committed Jul 20, 2017
1 parent d545bb7 commit 9ae3ee1
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions calicoctl/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func init() {

func Version(args []string) {
doc := `Usage:
calicoctl version
calicoctl version [--config=<CONFIG>]
Options:
-h --help Show this screen.
Expand All @@ -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)
Expand All @@ -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)
}

0 comments on commit 9ae3ee1

Please sign in to comment.