Align version outputs

This commit is contained in:
Ian Howell 2019-05-03 10:13:03 -05:00
parent c29ad8a23f
commit a5e6ea852e
2 changed files with 12 additions and 29 deletions
cmd
testdata/TestVersionGoldenOutput
version.go

@ -1,5 +1,2 @@
airshipadm: v0.1.0
golang : go1.12
kubernetes: v0.0.0-master+$Format:%h$
helm : TODO
argo : TODO
client: v0.1.0
kubernetes server: v0.0.0-master+$Format:%h$

@ -3,20 +3,17 @@ package cmd
import (
"fmt"
"io"
"runtime"
"text/tabwriter"
"github.com/spf13/cobra"
kube "github.com/ian-howell/airshipadm/pkg/kube"
)
const versionLong = `Show the versions for the airshipadm tool and the supporting tools.
This includes the following tools, in order:
* airshipadm
* golang
* kubernetes
* helm
* argo
const versionLong = `Show the versions for the airshipadm tool and its components.
This includes the following components, in order:
* airshipadm client
* kubernetes cluster
`
// NewVersionCommand prints out the versions of airshipadm and its underlying tools
@ -26,17 +23,16 @@ func NewVersionCommand(out io.Writer, client *kube.Client) *cobra.Command {
Short: "Show the version number of airshipadm and its underlying tools",
Long: versionLong,
Run: func(cmd *cobra.Command, args []string) {
fmt.Fprintf(out, "%-10s: %s\n", "airshipadm", airshipadmVersion())
fmt.Fprintf(out, "%-10s: %s\n", "golang", runtime.Version())
fmt.Fprintf(out, "%-10s: %s\n", "kubernetes", kubeVersion(client))
fmt.Fprintf(out, "%-10s: %s\n", "helm", helmVersion())
fmt.Fprintf(out, "%-10s: %s\n", "argo", argoVersion())
w := tabwriter.NewWriter(out, 0, 0, 1, ' ', 0)
fmt.Fprintf(w, "%s:\t%s\n", "client", clientVersion())
fmt.Fprintf(w, "%s:\t%s\n", "kubernetes server", kubeVersion(client))
w.Flush()
},
}
return versionCmd
}
func airshipadmVersion() string {
func clientVersion() string {
// TODO(howell): There's gotta be a smarter way to do this
return "v0.1.0"
}
@ -49,13 +45,3 @@ func kubeVersion(client *kube.Client) string {
}
return version.String()
}
func helmVersion() string {
// TODO(howell): Implement this
return "TODO"
}
func argoVersion() string {
// TODO(howell): Implement this
return "TODO"
}