From 608d919782a8598d00dc7d2df9cb189001ee4f39 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sun, 10 Feb 2019 21:08:23 -0500 Subject: [PATCH] Cleanup `oc adm` help for clarity Reduce the amount of sections, focus important commands at the top, and clarify help text of some lesser used commands like certificate and policy. --- contrib/completions/bash/oc | 110 ------------------------------ contrib/completions/zsh/oc | 110 ------------------------------ pkg/oc/cli/admin/admin.go | 41 ++++++----- pkg/oc/cli/admin/cert/cert.go | 2 +- pkg/oc/cli/admin/policy/policy.go | 2 +- pkg/oc/cli/cli.go | 10 ++- 6 files changed, 29 insertions(+), 246 deletions(-) diff --git a/contrib/completions/bash/oc b/contrib/completions/bash/oc index 3834dd944f00..0287ede01b0b 100644 --- a/contrib/completions/bash/oc +++ b/contrib/completions/bash/oc @@ -10614,115 +10614,6 @@ _oc_image() noun_aliases=() } -_oc_import_app.json() -{ - last_command="oc_import_app.json" - commands=() - - flags=() - two_word_flags=() - local_nonpersistent_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--allow-missing-template-keys") - local_nonpersistent_flags+=("--allow-missing-template-keys") - flags+=("--as-template=") - local_nonpersistent_flags+=("--as-template=") - flags+=("--filename=") - flags_with_completion+=("--filename") - flags_completion+=("__oc_handle_filename_extension_flag json|yaml|yml") - two_word_flags+=("-f") - flags_with_completion+=("-f") - flags_completion+=("__oc_handle_filename_extension_flag json|yaml|yml") - local_nonpersistent_flags+=("--filename=") - flags+=("--generator=") - local_nonpersistent_flags+=("--generator=") - flags+=("--image=") - local_nonpersistent_flags+=("--image=") - flags+=("--output=") - two_word_flags+=("-o") - local_nonpersistent_flags+=("--output=") - flags+=("--template=") - flags_with_completion+=("--template") - flags_completion+=("_filedir") - local_nonpersistent_flags+=("--template=") - flags+=("--as=") - flags+=("--as-group=") - flags+=("--cache-dir=") - flags+=("--certificate-authority=") - flags+=("--client-certificate=") - flags+=("--client-key=") - flags+=("--cluster=") - flags+=("--config=") - flags+=("--context=") - flags+=("--insecure-skip-tls-verify") - flags+=("--kubeconfig=") - flags+=("--loglevel=") - flags+=("--logspec=") - flags+=("--match-server-version") - flags+=("--namespace=") - flags_with_completion+=("--namespace") - flags_completion+=("__oc_get_namespaces") - two_word_flags+=("-n") - flags_with_completion+=("-n") - flags_completion+=("__oc_get_namespaces") - flags+=("--request-timeout=") - flags+=("--server=") - two_word_flags+=("-s") - flags+=("--token=") - flags+=("--user=") - - must_have_one_flag=() - must_have_one_flag+=("--filename=") - must_have_one_flag+=("-f") - must_have_one_noun=() - noun_aliases=() -} - -_oc_import() -{ - last_command="oc_import" - commands=() - commands+=("app.json") - - flags=() - two_word_flags=() - local_nonpersistent_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--as=") - flags+=("--as-group=") - flags+=("--cache-dir=") - flags+=("--certificate-authority=") - flags+=("--client-certificate=") - flags+=("--client-key=") - flags+=("--cluster=") - flags+=("--config=") - flags+=("--context=") - flags+=("--insecure-skip-tls-verify") - flags+=("--kubeconfig=") - flags+=("--loglevel=") - flags+=("--logspec=") - flags+=("--match-server-version") - flags+=("--namespace=") - flags_with_completion+=("--namespace") - flags_completion+=("__oc_get_namespaces") - two_word_flags+=("-n") - flags_with_completion+=("-n") - flags_completion+=("__oc_get_namespaces") - flags+=("--request-timeout=") - flags+=("--server=") - two_word_flags+=("-s") - flags+=("--token=") - flags+=("--user=") - - must_have_one_flag=() - must_have_one_noun=() - noun_aliases=() -} - _oc_import-image() { last_command="oc_import-image" @@ -15600,7 +15491,6 @@ _oc_root_command() commands+=("get") commands+=("idle") commands+=("image") - commands+=("import") commands+=("import-image") commands+=("label") commands+=("login") diff --git a/contrib/completions/zsh/oc b/contrib/completions/zsh/oc index d3d3403c6bed..0e5c49a4cd39 100644 --- a/contrib/completions/zsh/oc +++ b/contrib/completions/zsh/oc @@ -10756,115 +10756,6 @@ _oc_image() noun_aliases=() } -_oc_import_app.json() -{ - last_command="oc_import_app.json" - commands=() - - flags=() - two_word_flags=() - local_nonpersistent_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--allow-missing-template-keys") - local_nonpersistent_flags+=("--allow-missing-template-keys") - flags+=("--as-template=") - local_nonpersistent_flags+=("--as-template=") - flags+=("--filename=") - flags_with_completion+=("--filename") - flags_completion+=("__oc_handle_filename_extension_flag json|yaml|yml") - two_word_flags+=("-f") - flags_with_completion+=("-f") - flags_completion+=("__oc_handle_filename_extension_flag json|yaml|yml") - local_nonpersistent_flags+=("--filename=") - flags+=("--generator=") - local_nonpersistent_flags+=("--generator=") - flags+=("--image=") - local_nonpersistent_flags+=("--image=") - flags+=("--output=") - two_word_flags+=("-o") - local_nonpersistent_flags+=("--output=") - flags+=("--template=") - flags_with_completion+=("--template") - flags_completion+=("_filedir") - local_nonpersistent_flags+=("--template=") - flags+=("--as=") - flags+=("--as-group=") - flags+=("--cache-dir=") - flags+=("--certificate-authority=") - flags+=("--client-certificate=") - flags+=("--client-key=") - flags+=("--cluster=") - flags+=("--config=") - flags+=("--context=") - flags+=("--insecure-skip-tls-verify") - flags+=("--kubeconfig=") - flags+=("--loglevel=") - flags+=("--logspec=") - flags+=("--match-server-version") - flags+=("--namespace=") - flags_with_completion+=("--namespace") - flags_completion+=("__oc_get_namespaces") - two_word_flags+=("-n") - flags_with_completion+=("-n") - flags_completion+=("__oc_get_namespaces") - flags+=("--request-timeout=") - flags+=("--server=") - two_word_flags+=("-s") - flags+=("--token=") - flags+=("--user=") - - must_have_one_flag=() - must_have_one_flag+=("--filename=") - must_have_one_flag+=("-f") - must_have_one_noun=() - noun_aliases=() -} - -_oc_import() -{ - last_command="oc_import" - commands=() - commands+=("app.json") - - flags=() - two_word_flags=() - local_nonpersistent_flags=() - flags_with_completion=() - flags_completion=() - - flags+=("--as=") - flags+=("--as-group=") - flags+=("--cache-dir=") - flags+=("--certificate-authority=") - flags+=("--client-certificate=") - flags+=("--client-key=") - flags+=("--cluster=") - flags+=("--config=") - flags+=("--context=") - flags+=("--insecure-skip-tls-verify") - flags+=("--kubeconfig=") - flags+=("--loglevel=") - flags+=("--logspec=") - flags+=("--match-server-version") - flags+=("--namespace=") - flags_with_completion+=("--namespace") - flags_completion+=("__oc_get_namespaces") - two_word_flags+=("-n") - flags_with_completion+=("-n") - flags_completion+=("__oc_get_namespaces") - flags+=("--request-timeout=") - flags+=("--server=") - two_word_flags+=("-s") - flags+=("--token=") - flags+=("--user=") - - must_have_one_flag=() - must_have_one_noun=() - noun_aliases=() -} - _oc_import-image() { last_command="oc_import-image" @@ -15742,7 +15633,6 @@ _oc_root_command() commands+=("get") commands+=("idle") commands+=("image") - commands+=("import") commands+=("import-image") commands+=("label") commands+=("login") diff --git a/pkg/oc/cli/admin/admin.go b/pkg/oc/cli/admin/admin.go index bf81c6a81208..2b40fabf3881 100644 --- a/pkg/oc/cli/admin/admin.go +++ b/pkg/oc/cli/admin/admin.go @@ -46,8 +46,7 @@ import ( var adminLong = ktemplates.LongDesc(` Administrative Commands - Commands for managing a cluster are exposed here. Many administrative - actions involve interaction with the command-line client as well.`) + Actions for administering an OpenShift cluster are exposed here.`) func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { // Main command @@ -63,35 +62,33 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc Message: "Cluster Management:", Commands: []*cobra.Command{ upgrade.New(f, fullName, streams), - release.NewCmd(f, fullName, streams), - }, - }, - { - Message: "Security and Policy:", - Commands: []*cobra.Command{ - project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, streams), - policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, streams), - groups.NewCmdGroups(groups.GroupsRecommendedName, fullName+" "+groups.GroupsRecommendedName, f, streams), - cert.NewCmdCert(cert.CertRecommendedName, fullName+" "+cert.CertRecommendedName, streams), - kubecmd.NewCmdCertificate(f, streams), + top.NewCommandTop(top.TopRecommendedName, fullName+" "+top.TopRecommendedName, f, streams), }, }, { Message: "Node Management:", Commands: []*cobra.Command{ + cmdutil.ReplaceCommandName("kubectl", fullName, kubecmd.NewCmdDrain(f, streams)), cmdutil.ReplaceCommandName("kubectl", fullName, ktemplates.Normalize(kubecmd.NewCmdCordon(f, streams))), cmdutil.ReplaceCommandName("kubectl", fullName, ktemplates.Normalize(kubecmd.NewCmdUncordon(f, streams))), - cmdutil.ReplaceCommandName("kubectl", fullName, kubecmd.NewCmdDrain(f, streams)), cmdutil.ReplaceCommandName("kubectl", fullName, ktemplates.Normalize(kubecmd.NewCmdTaint(f, streams))), - network.NewCmdPodNetwork(network.PodNetworkCommandName, fullName+" "+network.PodNetworkCommandName, f, streams), logs.NewCmdLogs(fullName, f, streams), }, }, + { + Message: "Security and Policy:", + Commands: []*cobra.Command{ + project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, streams), + policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, streams), + groups.NewCmdGroups(groups.GroupsRecommendedName, fullName+" "+groups.GroupsRecommendedName, f, streams), + withShortDescription(kubecmd.NewCmdCertificate(f, streams), "Approve or reject certificate requests"), + network.NewCmdPodNetwork(network.PodNetworkCommandName, fullName+" "+network.PodNetworkCommandName, f, streams), + }, + }, { Message: "Maintenance:", Commands: []*cobra.Command{ prune.NewCommandPrune(prune.PruneRecommendedName, fullName+" "+prune.PruneRecommendedName, f, streams), - buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, streams), migrate.NewCommandMigrate( migrate.MigrateRecommendedName, fullName+" "+migrate.MigrateRecommendedName, f, streams, // Migration commands @@ -101,13 +98,12 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc migratehpa.NewCmdMigrateLegacyHPA("legacy-hpa", fullName+" "+migrate.MigrateRecommendedName+" legacy-hpa", f, streams), migratetemplateinstances.NewCmdMigrateTemplateInstances("template-instances", fullName+" "+migrate.MigrateRecommendedName+" template-instances", f, streams), ), - top.NewCommandTop(top.TopRecommendedName, fullName+" "+top.TopRecommendedName, f, streams), - verifyimagesignature.NewCmdVerifyImageSignature(name, fullName+" "+verifyimagesignature.VerifyRecommendedName, f, streams), }, }, { Message: "Configuration:", Commands: []*cobra.Command{ + cert.NewCmdCert(cert.CertRecommendedName, fullName+" "+cert.CertRecommendedName, streams), admin.NewCommandCreateKubeConfig(admin.CreateKubeConfigCommandName, fullName+" "+admin.CreateKubeConfigCommandName, streams), admin.NewCommandCreateClient(admin.CreateClientCommandName, fullName+" "+admin.CreateClientCommandName, streams), @@ -152,6 +148,10 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc } cmds.AddCommand( + release.NewCmd(f, fullName, streams), + buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, streams), + verifyimagesignature.NewCmdVerifyImageSignature(name, fullName+" "+verifyimagesignature.VerifyRecommendedName, f, streams), + // part of every root command kubectlwrappers.NewCmdConfig(fullName, "config", f, streams), kubectlwrappers.NewCmdCompletion(fullName, streams), @@ -166,3 +166,8 @@ func NewCommandAdmin(name, fullName string, f kcmdutil.Factory, streams genericc return cmds } + +func withShortDescription(cmd *cobra.Command, desc string) *cobra.Command { + cmd.Short = desc + return cmd +} diff --git a/pkg/oc/cli/admin/cert/cert.go b/pkg/oc/cli/admin/cert/cert.go index 15d0ef9d4658..d3ef99be16ee 100644 --- a/pkg/oc/cli/admin/cert/cert.go +++ b/pkg/oc/cli/admin/cert/cert.go @@ -15,7 +15,7 @@ func NewCmdCert(name, fullName string, streams genericclioptions.IOStreams) *cob // Parent command to which all subcommands are added. cmds := &cobra.Command{ Use: name, - Short: "Manage certificates and keys", + Short: "Create CA certificates", Long: `Manage certificates and keys`, Run: cmdutil.DefaultSubCommandRun(streams.ErrOut), } diff --git a/pkg/oc/cli/admin/policy/policy.go b/pkg/oc/cli/admin/policy/policy.go index 3a5f246f1cbb..9d216cd20ee2 100644 --- a/pkg/oc/cli/admin/policy/policy.go +++ b/pkg/oc/cli/admin/policy/policy.go @@ -36,7 +36,7 @@ func NewCmdPolicy(name, fullName string, f cmdutil.Factory, streams genericcliop // Parent command to which all subcommands are added. cmds := &cobra.Command{ Use: name, - Short: "Manage policy", + Short: "Manage cluster authorization and security policy", Long: policyLong, Run: cmdutil.DefaultSubCommandRun(streams.ErrOut), } diff --git a/pkg/oc/cli/cli.go b/pkg/oc/cli/cli.go index 74dc534e4103..85be58ea37fe 100644 --- a/pkg/oc/cli/cli.go +++ b/pkg/oc/cli/cli.go @@ -32,7 +32,6 @@ import ( "github.com/openshift/origin/pkg/oc/cli/extract" "github.com/openshift/origin/pkg/oc/cli/idle" "github.com/openshift/origin/pkg/oc/cli/image" - "github.com/openshift/origin/pkg/oc/cli/importer" "github.com/openshift/origin/pkg/oc/cli/importimage" "github.com/openshift/origin/pkg/oc/cli/kubectlwrappers" "github.com/openshift/origin/pkg/oc/cli/login" @@ -157,7 +156,6 @@ func NewOcCommand(name, fullName string, in io.Reader, out, errout io.Writer) *c project.NewCmdProject(fullName, f, ioStreams), projects.NewCmdProjects(fullName, f, ioStreams), kubectlwrappers.NewCmdExplain(fullName, f, ioStreams), - kubectlwrappers.NewCmdClusterInfo(fullName, f, ioStreams), }, }, { @@ -175,6 +173,8 @@ func NewOcCommand(name, fullName string, in io.Reader, out, errout io.Writer) *c { Message: "Application Management Commands:", Commands: []*cobra.Command{ + kubectlwrappers.NewCmdCreate(fullName, f, ioStreams), + kubectlwrappers.NewCmdApply(fullName, f, ioStreams), kubectlwrappers.NewCmdGet(fullName, f, ioStreams), kubectlwrappers.NewCmdDescribe(fullName, f, ioStreams), kubectlwrappers.NewCmdEdit(fullName, f, ioStreams), @@ -209,22 +209,20 @@ func NewOcCommand(name, fullName string, in io.Reader, out, errout io.Writer) *c Message: "Advanced Commands:", Commands: []*cobra.Command{ admin.NewCommandAdmin("adm", fullName+" "+"adm", f, ioStreams), - kubectlwrappers.NewCmdCreate(fullName, f, ioStreams), kubectlwrappers.NewCmdReplace(fullName, f, ioStreams), - kubectlwrappers.NewCmdApply(fullName, f, ioStreams), kubectlwrappers.NewCmdPatch(fullName, f, ioStreams), process.NewCmdProcess(fullName, f, ioStreams), extract.NewCmdExtract(fullName, f, ioStreams), - idle.NewCmdIdle(fullName, f, ioStreams), observe.NewCmdObserve(fullName, f, ioStreams), policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, ioStreams), kubectlwrappers.NewCmdAuth(fullName, f, ioStreams), kubectlwrappers.NewCmdConvert(fullName, f, ioStreams), - importer.NewCmdImport(fullName, f, ioStreams), image.NewCmdImage(fullName, f, ioStreams), registry.NewCmd(fullName, f, ioStreams), + idle.NewCmdIdle(fullName, f, ioStreams), kubectlwrappers.NewCmdApiVersions(fullName, f, ioStreams), kubectlwrappers.NewCmdApiResources(fullName, f, ioStreams), + kubectlwrappers.NewCmdClusterInfo(fullName, f, ioStreams), }, }, {