Skip to content

Commit

Permalink
move "openshift ex" -> "oc ex"
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Nov 29, 2017
1 parent 354df72 commit 4bdb0bd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 49 deletions.
42 changes: 0 additions & 42 deletions pkg/cmd/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,8 @@ import (
"github.com/openshift/origin/pkg/cmd/server/start"
"github.com/openshift/origin/pkg/cmd/templates"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/oc/admin"
diagnostics "github.com/openshift/origin/pkg/oc/admin/diagnostics"
sync "github.com/openshift/origin/pkg/oc/admin/groups/sync/cli"
"github.com/openshift/origin/pkg/oc/admin/validate"
"github.com/openshift/origin/pkg/oc/cli/cmd"
"github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
"github.com/openshift/origin/pkg/oc/experimental/buildchain"
configcmd "github.com/openshift/origin/pkg/oc/experimental/config"
"github.com/openshift/origin/pkg/oc/experimental/dockergc"
exipfailover "github.com/openshift/origin/pkg/oc/experimental/ipfailover"
)

var (
Expand Down Expand Up @@ -103,7 +95,6 @@ func NewCommandOpenShift(name string) *cobra.Command {

startAllInOne, _ := start.NewCommandStartAllInOne(name, out, errout)
root.AddCommand(startAllInOne)
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(newCompletionCommand("completion", name+" completion"))
root.AddCommand(cmd.NewCmdVersion(name, f, out, cmd.VersionOptions{PrintEtcdVersion: true, IsServer: true}))
root.AddCommand(cmd.NewCmdOptions(out))
Expand All @@ -114,39 +105,6 @@ func NewCommandOpenShift(name string) *cobra.Command {
return root
}

func newExperimentalCommand(name, fullName string) *cobra.Command {
out := os.Stdout
errout := os.Stderr

experimental := &cobra.Command{
Use: name,
Short: "Experimental commands under active development",
Long: "The commands grouped here are under development and may change without notice.",
Run: func(c *cobra.Command, args []string) {
c.SetOutput(out)
c.Help()
},
BashCompletionFunction: admin.BashCompletionFunc,
}

f := clientcmd.New(experimental.PersistentFlags())

experimental.AddCommand(validate.NewCommandValidate(validate.ValidateRecommendedName, fullName+" "+validate.ValidateRecommendedName, out, errout))
experimental.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out, errout))
experimental.AddCommand(dockergc.NewCmdDockerGCConfig(f, fullName, "dockergc", out, errout))
experimental.AddCommand(buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out))
experimental.AddCommand(configcmd.NewCmdConfig(configcmd.ConfigRecommendedName, fullName+" "+configcmd.ConfigRecommendedName, f, out, errout))
deprecatedDiag := diagnostics.NewCmdDiagnostics(diagnostics.DiagnosticsRecommendedName, fullName+" "+diagnostics.DiagnosticsRecommendedName, out)
deprecatedDiag.Deprecated = fmt.Sprintf(`use "oc adm %[1]s" to run diagnostics instead.`, diagnostics.DiagnosticsRecommendedName)
experimental.AddCommand(deprecatedDiag)
experimental.AddCommand(cmd.NewCmdOptions(out))

// these groups also live under `oc adm groups {sync,prune}` and are here only for backwards compatibility
experimental.AddCommand(sync.NewCmdSync("sync-groups", fullName+" "+"sync-groups", f, out))
experimental.AddCommand(sync.NewCmdPrune("prune-groups", fullName+" "+"prune-groups", f, out))
return experimental
}

var (
completion_long = ktemplates.LongDesc(`
Output shell completion code for the given shell (bash or zsh).
Expand Down
48 changes: 41 additions & 7 deletions pkg/oc/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import (
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util/term"
"github.com/openshift/origin/pkg/oc/admin"
diagnostics "github.com/openshift/origin/pkg/oc/admin/diagnostics"
sync "github.com/openshift/origin/pkg/oc/admin/groups/sync/cli"
"github.com/openshift/origin/pkg/oc/admin/validate"
"github.com/openshift/origin/pkg/oc/cli/cmd"
"github.com/openshift/origin/pkg/oc/cli/cmd/cluster"
"github.com/openshift/origin/pkg/oc/cli/cmd/image"
Expand All @@ -30,6 +33,10 @@ import (
"github.com/openshift/origin/pkg/oc/cli/sa"
"github.com/openshift/origin/pkg/oc/cli/secrets"
"github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
"github.com/openshift/origin/pkg/oc/experimental/buildchain"
configcmd "github.com/openshift/origin/pkg/oc/experimental/config"
"github.com/openshift/origin/pkg/oc/experimental/dockergc"
exipfailover "github.com/openshift/origin/pkg/oc/experimental/ipfailover"
)

const productName = `OpenShift`
Expand Down Expand Up @@ -192,13 +199,7 @@ func NewCommandCLI(name, fullName string, in io.Reader, out, errout io.Writer) *
templates.ActsAsRootCommand(cmds, filters, groups...).
ExposeFlags(loginCmd, "certificate-authority", "insecure-skip-tls-verify", "token")

// experimental commands are those that are bundled with the binary but not displayed to end users
// directly
experimental := &cobra.Command{
Use: "ex", // Because this command exposes no description, it will not be shown in help
}
experimental.AddCommand()
cmds.AddCommand(experimental)
cmds.AddCommand(newExperimentalCommand("ex", name+"ex"))

cmds.AddCommand(cmd.NewCmdPlugin(fullName, f, in, out, errout))
if name == fullName {
Expand Down Expand Up @@ -254,6 +255,39 @@ func changeSharedFlagDefaults(rootCmd *cobra.Command) {
}
}

func newExperimentalCommand(name, fullName string) *cobra.Command {
out := os.Stdout
errout := os.Stderr

experimental := &cobra.Command{
Use: name,
Short: "Experimental commands under active development",
Long: "The commands grouped here are under development and may change without notice.",
Run: func(c *cobra.Command, args []string) {
c.SetOutput(out)
c.Help()
},
BashCompletionFunction: admin.BashCompletionFunc,
}

f := clientcmd.New(experimental.PersistentFlags())

experimental.AddCommand(validate.NewCommandValidate(validate.ValidateRecommendedName, fullName+" "+validate.ValidateRecommendedName, out, errout))
experimental.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out, errout))
experimental.AddCommand(dockergc.NewCmdDockerGCConfig(f, fullName, "dockergc", out, errout))
experimental.AddCommand(buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out))
experimental.AddCommand(configcmd.NewCmdConfig(configcmd.ConfigRecommendedName, fullName+" "+configcmd.ConfigRecommendedName, f, out, errout))
deprecatedDiag := diagnostics.NewCmdDiagnostics(diagnostics.DiagnosticsRecommendedName, fullName+" "+diagnostics.DiagnosticsRecommendedName, out)
deprecatedDiag.Deprecated = fmt.Sprintf(`use "oc adm %[1]s" to run diagnostics instead.`, diagnostics.DiagnosticsRecommendedName)
experimental.AddCommand(deprecatedDiag)
experimental.AddCommand(cmd.NewCmdOptions(out))

// these groups also live under `oc adm groups {sync,prune}` and are here only for backwards compatibility
experimental.AddCommand(sync.NewCmdSync("sync-groups", fullName+" "+"sync-groups", f, out))
experimental.AddCommand(sync.NewCmdPrune("prune-groups", fullName+" "+"prune-groups", f, out))
return experimental
}

// CommandFor returns the appropriate command for this base name,
// or the OpenShift CLI command.
func CommandFor(basename string) *cobra.Command {
Expand Down

0 comments on commit 4bdb0bd

Please sign in to comment.