|
6 | 6 |
|
7 | 7 | "github.com/spf13/cobra"
|
8 | 8 |
|
| 9 | + "github.com/openshift/origin/pkg/cmd/admin/cert" |
9 | 10 | "github.com/openshift/origin/pkg/cmd/admin/node"
|
10 | 11 | "github.com/openshift/origin/pkg/cmd/admin/policy"
|
11 | 12 | "github.com/openshift/origin/pkg/cmd/admin/project"
|
@@ -38,31 +39,68 @@ func NewCommandAdmin(name, fullName string, out io.Writer) *cobra.Command {
|
38 | 39 |
|
39 | 40 | f := clientcmd.New(cmds.PersistentFlags())
|
40 | 41 |
|
41 |
| - cmds.AddCommand(project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, out)) |
42 |
| - cmds.AddCommand(policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out)) |
43 |
| - cmds.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out)) |
44 |
| - cmds.AddCommand(router.NewCmdRouter(f, fullName, "router", out)) |
45 |
| - cmds.AddCommand(registry.NewCmdRegistry(f, fullName, "registry", out)) |
46 |
| - cmds.AddCommand(buildchain.NewCmdBuildChain(f, fullName, "build-chain")) |
47 |
| - cmds.AddCommand(node.NewCommandManageNode(f, node.ManageNodeCommandName, fullName+" "+node.ManageNodeCommandName, out)) |
48 |
| - cmds.AddCommand(cmd.NewCmdConfig(fullName, "config")) |
49 |
| - cmds.AddCommand(prune.NewCommandPrune(prune.PruneRecommendedName, fullName+" "+prune.PruneRecommendedName, f, out)) |
| 42 | + groups := templates.CommandGroups{ |
| 43 | + { |
| 44 | + Message: "Basic Commands:", |
| 45 | + Commands: []*cobra.Command{ |
| 46 | + project.NewCmdNewProject(project.NewProjectRecommendedName, fullName+" "+project.NewProjectRecommendedName, f, out), |
| 47 | + policy.NewCmdPolicy(policy.PolicyRecommendedName, fullName+" "+policy.PolicyRecommendedName, f, out), |
| 48 | + }, |
| 49 | + }, |
| 50 | + { |
| 51 | + Message: "Install Commands:", |
| 52 | + Commands: []*cobra.Command{ |
| 53 | + router.NewCmdRouter(f, fullName, "router", out), |
| 54 | + exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out), |
| 55 | + registry.NewCmdRegistry(f, fullName, "registry", out), |
| 56 | + }, |
| 57 | + }, |
| 58 | + { |
| 59 | + Message: "Maintenance Commands:", |
| 60 | + Commands: []*cobra.Command{ |
| 61 | + buildchain.NewCmdBuildChain(f, fullName, "build-chain"), |
| 62 | + node.NewCommandManageNode(f, node.ManageNodeCommandName, fullName+" "+node.ManageNodeCommandName, out), |
| 63 | + prune.NewCommandPrune(prune.PruneRecommendedName, fullName+" "+prune.PruneRecommendedName, f, out), |
| 64 | + }, |
| 65 | + }, |
| 66 | + { |
| 67 | + Message: "Settings Commands:", |
| 68 | + Commands: []*cobra.Command{ |
| 69 | + cmd.NewCmdConfig(fullName, "config"), |
50 | 70 |
|
51 |
| - // TODO: these probably belong in a sub command |
52 |
| - cmds.AddCommand(admin.NewCommandCreateKubeConfig(admin.CreateKubeConfigCommandName, fullName+" "+admin.CreateKubeConfigCommandName, out)) |
53 |
| - cmds.AddCommand(admin.NewCommandCreateBootstrapPolicyFile(admin.CreateBootstrapPolicyFileCommand, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out)) |
54 |
| - cmds.AddCommand(admin.NewCommandCreateBootstrapProjectTemplate(f, admin.CreateBootstrapProjectTemplateCommand, fullName+" "+admin.CreateBootstrapProjectTemplateCommand, out)) |
55 |
| - cmds.AddCommand(admin.NewCommandOverwriteBootstrapPolicy(admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out)) |
56 |
| - cmds.AddCommand(admin.NewCommandNodeConfig(admin.NodeConfigCommandName, fullName+" "+admin.NodeConfigCommandName, out)) |
57 |
| - // TODO: these should be rolled up together |
58 |
| - cmds.AddCommand(admin.NewCommandCreateMasterCerts(admin.CreateMasterCertsCommandName, fullName+" "+admin.CreateMasterCertsCommandName, out)) |
59 |
| - cmds.AddCommand(admin.NewCommandCreateClient(admin.CreateClientCommandName, fullName+" "+admin.CreateClientCommandName, out)) |
60 |
| - cmds.AddCommand(admin.NewCommandCreateKeyPair(admin.CreateKeyPairCommandName, fullName+" "+admin.CreateKeyPairCommandName, out)) |
61 |
| - cmds.AddCommand(admin.NewCommandCreateServerCert(admin.CreateServerCertCommandName, fullName+" "+admin.CreateServerCertCommandName, out)) |
62 |
| - cmds.AddCommand(admin.NewCommandCreateSignerCert(admin.CreateSignerCertCommandName, fullName+" "+admin.CreateSignerCertCommandName, out)) |
| 71 | + // TODO: these probably belong in a sub command |
| 72 | + admin.NewCommandCreateKubeConfig(admin.CreateKubeConfigCommandName, fullName+" "+admin.CreateKubeConfigCommandName, out), |
| 73 | + admin.NewCommandCreateClient(admin.CreateClientCommandName, fullName+" "+admin.CreateClientCommandName, out), |
| 74 | + }, |
| 75 | + }, |
| 76 | + { |
| 77 | + Message: "Advanced Commands:", |
| 78 | + Commands: []*cobra.Command{ |
| 79 | + admin.NewCommandCreateBootstrapProjectTemplate(f, admin.CreateBootstrapProjectTemplateCommand, fullName+" "+admin.CreateBootstrapProjectTemplateCommand, out), |
| 80 | + admin.NewCommandCreateBootstrapPolicyFile(admin.CreateBootstrapPolicyFileCommand, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out), |
| 81 | + admin.NewCommandOverwriteBootstrapPolicy(admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.OverwriteBootstrapPolicyCommandName, fullName+" "+admin.CreateBootstrapPolicyFileCommand, out), |
| 82 | + admin.NewCommandNodeConfig(admin.NodeConfigCommandName, fullName+" "+admin.NodeConfigCommandName, out), |
| 83 | + cert.NewCmdCert(cert.CertRecommendedName, fullName+" "+cert.CertRecommendedName, out), |
| 84 | + }, |
| 85 | + }, |
| 86 | + } |
| 87 | + |
| 88 | + groups.Add(cmds) |
| 89 | + templates.ActsAsRootCommand(cmds, groups...) |
63 | 90 |
|
64 |
| - // TODO: use groups |
65 |
| - templates.ActsAsRootCommand(cmds) |
| 91 | + // Deprecated commands that are bundled with the binary but not displayed to end users directly |
| 92 | + deprecatedCommands := []*cobra.Command{ |
| 93 | + admin.NewCommandCreateMasterCerts(admin.CreateMasterCertsCommandName, fullName+" "+admin.CreateMasterCertsCommandName, out), |
| 94 | + admin.NewCommandCreateKeyPair(admin.CreateKeyPairCommandName, fullName+" "+admin.CreateKeyPairCommandName, out), |
| 95 | + admin.NewCommandCreateServerCert(admin.CreateServerCertCommandName, fullName+" "+admin.CreateServerCertCommandName, out), |
| 96 | + admin.NewCommandCreateSignerCert(admin.CreateSignerCertCommandName, fullName+" "+admin.CreateSignerCertCommandName, out), |
| 97 | + } |
| 98 | + for _, cmd := range deprecatedCommands { |
| 99 | + // Unsetting Short description will not show this command in help |
| 100 | + cmd.Short = "" |
| 101 | + cmd.Deprecated = fmt.Sprintf("Use '%s ca' instead.", fullName) |
| 102 | + cmds.AddCommand(cmd) |
| 103 | + } |
66 | 104 |
|
67 | 105 | if name == fullName {
|
68 | 106 | cmds.AddCommand(version.NewVersionCommand(fullName))
|
|
0 commit comments