Add version command for all binaries/symlinks
package version
+import (
+ "fmt"
+
+ kubeversion "github.com/GoogleCloudPlatform/kubernetes/pkg/version"
+ "github.com/spf13/cobra"
+)
+
var (
// commitFromGit is a constant representing the source version that
// generated this build. It should be set during build via -ldflags.
@@ -42,3 +49,15 @@ func (info Info) String() string {
}
return version
}
+
+// NewVersionCommand creates a command for displaying the version of this binary
+func NewVersionCommand(basename string) *cobra.Command {
+ return &cobra.Command{
+ Use: "version",
+ Short: "Display version",
+ Run: func(c *cobra.Command, args []string) {
+ fmt.Printf("%s %v\n", basename, Get())
+ fmt.Printf("kubernetes %v\n", kubeversion.Get())
+ },
+ }
+}
