Browse code

Merge pull request #1199 from kargakis/version

Merged by openshift-bot

OpenShift Bot authored on 2015/03/03 04:13:25
Showing 6 changed files
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"github.com/openshift/origin/pkg/cmd/cli/cmd"
13 13
 	"github.com/openshift/origin/pkg/cmd/templates"
14 14
 	"github.com/openshift/origin/pkg/cmd/util/clientcmd"
15
+	"github.com/openshift/origin/pkg/version"
15 16
 )
16 17
 
17 18
 const longDesc = `
... ...
@@ -65,7 +66,6 @@ func NewCommandCLI(name, fullName string) *cobra.Command {
65 65
 	cmds.AddCommand(cmd.NewCmdCancelBuild(f, out))
66 66
 	cmds.AddCommand(cmd.NewCmdBuildLogs(f, out))
67 67
 	cmds.AddCommand(cmd.NewCmdRollback(name, "rollback", f, out))
68
-
69 68
 	cmds.AddCommand(cmd.NewCmdGet(fullName, f, out))
70 69
 	cmds.AddCommand(f.NewCmdDescribe(out))
71 70
 	// Deprecate 'osc apply' with 'osc create' command.
... ...
@@ -73,15 +73,11 @@ func NewCommandCLI(name, fullName string) *cobra.Command {
73 73
 	cmds.AddCommand(cmd.NewCmdProcess(f, out))
74 74
 	cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out))
75 75
 	cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out))
76
-
77 76
 	cmds.AddCommand(cmd.NewCmdLog(fullName, f, out))
78 77
 	cmds.AddCommand(f.NewCmdProxy(out))
79
-
80 78
 	cmds.AddCommand(kubecmd.NewCmdNamespace(out))
81
-
82
-	// Origin build commands
83
-
84 79
 	cmds.AddCommand(cmd.NewCmdOptions(f, out))
80
+	cmds.AddCommand(version.NewVersionCommand(name))
85 81
 
86 82
 	return cmds
87 83
 }
... ...
@@ -1,12 +1,11 @@
1 1
 package builder
2 2
 
3 3
 import (
4
-	"fmt"
5
-
6 4
 	"github.com/spf13/cobra"
7 5
 
8 6
 	"github.com/openshift/origin/pkg/build/builder/cmd"
9 7
 	"github.com/openshift/origin/pkg/cmd/templates"
8
+	"github.com/openshift/origin/pkg/version"
10 9
 )
11 10
 
12 11
 const longCommandSTIDesc = `
... ...
@@ -19,7 +18,7 @@ It expects to be run inside of a container.
19 19
 // NewCommandSTIBuilder provides a CLI handler for STI build type
20 20
 func NewCommandSTIBuilder(name string) *cobra.Command {
21 21
 	cmd := &cobra.Command{
22
-		Use:   fmt.Sprintf("%s", name),
22
+		Use:   name,
23 23
 		Short: "Run an OpenShift Source-to-Images build",
24 24
 		Long:  longCommandSTIDesc,
25 25
 		Run: func(c *cobra.Command, args []string) {
... ...
@@ -28,6 +27,7 @@ func NewCommandSTIBuilder(name string) *cobra.Command {
28 28
 	}
29 29
 	cmd.SetUsageTemplate(templates.MainUsageTemplate())
30 30
 	cmd.SetHelpTemplate(templates.MainHelpTemplate())
31
+	cmd.AddCommand(version.NewVersionCommand(name))
31 32
 	return cmd
32 33
 }
33 34
 
... ...
@@ -41,7 +41,7 @@ It expects to be run inside of a container.
41 41
 // NewCommandDockerBuilder provides a CLI handler for Docker build type
42 42
 func NewCommandDockerBuilder(name string) *cobra.Command {
43 43
 	cmd := &cobra.Command{
44
-		Use:   fmt.Sprintf("%s", name),
44
+		Use:   name,
45 45
 		Short: "Run an OpenShift Docker build",
46 46
 		Long:  longCommandDockerDesc,
47 47
 		Run: func(c *cobra.Command, args []string) {
... ...
@@ -50,5 +50,6 @@ func NewCommandDockerBuilder(name string) *cobra.Command {
50 50
 	}
51 51
 	cmd.SetUsageTemplate(templates.MainUsageTemplate())
52 52
 	cmd.SetHelpTemplate(templates.MainHelpTemplate())
53
+	cmd.AddCommand(version.NewVersionCommand(name))
53 54
 	return cmd
54 55
 }
... ...
@@ -17,6 +17,7 @@ import (
17 17
 	deployapi "github.com/openshift/origin/pkg/deploy/api"
18 18
 	strategy "github.com/openshift/origin/pkg/deploy/strategy/recreate"
19 19
 	deployutil "github.com/openshift/origin/pkg/deploy/util"
20
+	"github.com/openshift/origin/pkg/version"
20 21
 )
21 22
 
22 23
 const longCommandDesc = `
... ...
@@ -68,6 +69,7 @@ func NewCommandDeployer(name string) *cobra.Command {
68 68
 
69 69
 	cmd.SetUsageTemplate(templates.MainUsageTemplate())
70 70
 	cmd.SetHelpTemplate(templates.MainHelpTemplate())
71
+	cmd.AddCommand(version.NewVersionCommand(name))
71 72
 
72 73
 	flag := cmd.Flags()
73 74
 	cfg.Config.Bind(flag)
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"github.com/openshift/origin/pkg/cmd/util/clientcmd"
13 13
 	"github.com/openshift/origin/pkg/router"
14 14
 	controllerfactory "github.com/openshift/origin/pkg/router/controller/factory"
15
+	"github.com/openshift/origin/pkg/version"
15 16
 	templateplugin "github.com/openshift/origin/plugins/router/template"
16 17
 )
17 18
 
... ...
@@ -52,6 +53,7 @@ func NewCommandTemplateRouter(name string) *cobra.Command {
52 52
 
53 53
 	cmd.SetUsageTemplate(templates.MainUsageTemplate())
54 54
 	cmd.SetHelpTemplate(templates.MainHelpTemplate())
55
+	cmd.AddCommand(version.NewVersionCommand(name))
55 56
 
56 57
 	flag := cmd.Flags()
57 58
 	cfg.Config.Bind(flag)
... ...
@@ -4,7 +4,6 @@ import (
4 4
 	"fmt"
5 5
 	"os"
6 6
 
7
-	kubeversion "github.com/GoogleCloudPlatform/kubernetes/pkg/version"
8 7
 	"github.com/spf13/cobra"
9 8
 
10 9
 	"github.com/openshift/origin/pkg/cmd/cli"
... ...
@@ -85,7 +84,7 @@ func NewCommandOpenShift() *cobra.Command {
85 85
 	root.AddCommand(cli.NewCommandCLI("cli", "openshift cli"))
86 86
 	root.AddCommand(cli.NewCmdKubectl("kube"))
87 87
 	root.AddCommand(newExperimentalCommand("openshift", "ex"))
88
-	root.AddCommand(newVersionCommand("version"))
88
+	root.AddCommand(version.NewVersionCommand("openshift"))
89 89
 
90 90
 	// infra commands are those that are bundled with the binary but not displayed to end users
91 91
 	// directly
... ...
@@ -128,15 +127,3 @@ func newExperimentalCommand(parentName, name string) *cobra.Command {
128 128
 	experimental.AddCommand(exregistry.NewCmdRegistry(f, subName, "registry", os.Stdout))
129 129
 	return experimental
130 130
 }
131
-
132
-// newVersionCommand creates a command for displaying the version of this binary
133
-func newVersionCommand(name string) *cobra.Command {
134
-	return &cobra.Command{
135
-		Use:   name,
136
-		Short: "Display version",
137
-		Run: func(c *cobra.Command, args []string) {
138
-			fmt.Printf("openshift %v\n", version.Get())
139
-			fmt.Printf("kubernetes %v\n", kubeversion.Get())
140
-		},
141
-	}
142
-}
... ...
@@ -1,5 +1,12 @@
1 1
 package version
2 2
 
3
+import (
4
+	"fmt"
5
+
6
+	kubeversion "github.com/GoogleCloudPlatform/kubernetes/pkg/version"
7
+	"github.com/spf13/cobra"
8
+)
9
+
3 10
 var (
4 11
 	// commitFromGit is a constant representing the source version that
5 12
 	// generated this build. It should be set during build via -ldflags.
... ...
@@ -42,3 +49,15 @@ func (info Info) String() string {
42 42
 	}
43 43
 	return version
44 44
 }
45
+
46
+// NewVersionCommand creates a command for displaying the version of this binary
47
+func NewVersionCommand(basename string) *cobra.Command {
48
+	return &cobra.Command{
49
+		Use:   "version",
50
+		Short: "Display version",
51
+		Run: func(c *cobra.Command, args []string) {
52
+			fmt.Printf("%s %v\n", basename, Get())
53
+			fmt.Printf("kubernetes %v\n", kubeversion.Get())
54
+		},
55
+	}
56
+}