Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pkg/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/openshift/origin/pkg/cmd/cli/cmd"
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
"github.com/openshift/origin/pkg/version"
)

const longDesc = `
Expand Down Expand Up @@ -65,23 +66,18 @@ func NewCommandCLI(name, fullName string) *cobra.Command {
cmds.AddCommand(cmd.NewCmdCancelBuild(f, out))
cmds.AddCommand(cmd.NewCmdBuildLogs(f, out))
cmds.AddCommand(cmd.NewCmdRollback(name, "rollback", f, out))

cmds.AddCommand(cmd.NewCmdGet(fullName, f, out))
cmds.AddCommand(f.NewCmdDescribe(out))
// Deprecate 'osc apply' with 'osc create' command.
cmds.AddCommand(applyToCreate(cmd.NewCmdCreate(fullName, f, out)))
cmds.AddCommand(cmd.NewCmdProcess(f, out))
cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out))
cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out))

cmds.AddCommand(cmd.NewCmdLog(fullName, f, out))
cmds.AddCommand(f.NewCmdProxy(out))

cmds.AddCommand(kubecmd.NewCmdNamespace(out))

// Origin build commands

cmds.AddCommand(cmd.NewCmdOptions(f, out))
cmds.AddCommand(version.NewVersionCommand(name))

return cmds
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/cmd/infra/builder/builder.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package builder

import (
"fmt"

"github.com/spf13/cobra"

"github.com/openshift/origin/pkg/build/builder/cmd"
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/version"
)

const longCommandSTIDesc = `
Expand All @@ -19,7 +18,7 @@ It expects to be run inside of a container.
// NewCommandSTIBuilder provides a CLI handler for STI build type
func NewCommandSTIBuilder(name string) *cobra.Command {
cmd := &cobra.Command{
Use: fmt.Sprintf("%s", name),
Use: name,
Short: "Run an OpenShift Source-to-Images build",
Long: longCommandSTIDesc,
Run: func(c *cobra.Command, args []string) {
Expand All @@ -28,6 +27,7 @@ func NewCommandSTIBuilder(name string) *cobra.Command {
}
cmd.SetUsageTemplate(templates.MainUsageTemplate())
cmd.SetHelpTemplate(templates.MainHelpTemplate())
cmd.AddCommand(version.NewVersionCommand(name))
return cmd
}

Expand All @@ -41,7 +41,7 @@ It expects to be run inside of a container.
// NewCommandDockerBuilder provides a CLI handler for Docker build type
func NewCommandDockerBuilder(name string) *cobra.Command {
cmd := &cobra.Command{
Use: fmt.Sprintf("%s", name),
Use: name,
Short: "Run an OpenShift Docker build",
Long: longCommandDockerDesc,
Run: func(c *cobra.Command, args []string) {
Expand All @@ -50,5 +50,6 @@ func NewCommandDockerBuilder(name string) *cobra.Command {
}
cmd.SetUsageTemplate(templates.MainUsageTemplate())
cmd.SetHelpTemplate(templates.MainHelpTemplate())
cmd.AddCommand(version.NewVersionCommand(name))
return cmd
}
2 changes: 2 additions & 0 deletions pkg/cmd/infra/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
deployapi "github.com/openshift/origin/pkg/deploy/api"
strategy "github.com/openshift/origin/pkg/deploy/strategy/recreate"
deployutil "github.com/openshift/origin/pkg/deploy/util"
"github.com/openshift/origin/pkg/version"
)

const longCommandDesc = `
Expand Down Expand Up @@ -68,6 +69,7 @@ func NewCommandDeployer(name string) *cobra.Command {

cmd.SetUsageTemplate(templates.MainUsageTemplate())
cmd.SetHelpTemplate(templates.MainHelpTemplate())
cmd.AddCommand(version.NewVersionCommand(name))

flag := cmd.Flags()
cfg.Config.Bind(flag)
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/infra/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
"github.com/openshift/origin/pkg/router"
controllerfactory "github.com/openshift/origin/pkg/router/controller/factory"
"github.com/openshift/origin/pkg/version"
templateplugin "github.com/openshift/origin/plugins/router/template"
)

Expand Down Expand Up @@ -52,6 +53,7 @@ func NewCommandTemplateRouter(name string) *cobra.Command {

cmd.SetUsageTemplate(templates.MainUsageTemplate())
cmd.SetHelpTemplate(templates.MainHelpTemplate())
cmd.AddCommand(version.NewVersionCommand(name))

flag := cmd.Flags()
cfg.Config.Bind(flag)
Expand Down
15 changes: 1 addition & 14 deletions pkg/cmd/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"

kubeversion "github.com/GoogleCloudPlatform/kubernetes/pkg/version"
"github.com/spf13/cobra"

"github.com/openshift/origin/pkg/cmd/cli"
Expand Down Expand Up @@ -85,7 +84,7 @@ func NewCommandOpenShift() *cobra.Command {
root.AddCommand(cli.NewCommandCLI("cli", "openshift cli"))
root.AddCommand(cli.NewCmdKubectl("kube"))
root.AddCommand(newExperimentalCommand("openshift", "ex"))
root.AddCommand(newVersionCommand("version"))
root.AddCommand(version.NewVersionCommand("openshift"))

// infra commands are those that are bundled with the binary but not displayed to end users
// directly
Expand Down Expand Up @@ -128,15 +127,3 @@ func newExperimentalCommand(parentName, name string) *cobra.Command {
experimental.AddCommand(exregistry.NewCmdRegistry(f, subName, "registry", os.Stdout))
return experimental
}

// newVersionCommand creates a command for displaying the version of this binary
func newVersionCommand(name string) *cobra.Command {
return &cobra.Command{
Use: name,
Short: "Display version",
Run: func(c *cobra.Command, args []string) {
fmt.Printf("openshift %v\n", version.Get())
fmt.Printf("kubernetes %v\n", kubeversion.Get())
},
}
}
19 changes: 19 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
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.
Expand Down Expand Up @@ -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())
},
}
}