mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
Updates command registration to use new commands package. Name CLI
command by the build name. Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
This commit is contained in:
+2
-11
@@ -6,17 +6,8 @@ go_library(
|
||||
importpath = "github.com/jetstack/cert-manager/cmd/ctl/cmd",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//cmd/ctl/pkg/approve:go_default_library",
|
||||
"//cmd/ctl/pkg/check:go_default_library",
|
||||
"//cmd/ctl/pkg/completion:go_default_library",
|
||||
"//cmd/ctl/pkg/convert:go_default_library",
|
||||
"//cmd/ctl/pkg/create:go_default_library",
|
||||
"//cmd/ctl/pkg/deny:go_default_library",
|
||||
"//cmd/ctl/pkg/experimental:go_default_library",
|
||||
"//cmd/ctl/pkg/inspect:go_default_library",
|
||||
"//cmd/ctl/pkg/renew:go_default_library",
|
||||
"//cmd/ctl/pkg/status:go_default_library",
|
||||
"//cmd/ctl/pkg/version:go_default_library",
|
||||
"//cmd/ctl/pkg/build:go_default_library",
|
||||
"//cmd/ctl/pkg/build/commands:go_default_library",
|
||||
"@com_github_spf13_cobra//:go_default_library",
|
||||
"@io_k8s_cli_runtime//pkg/genericclioptions:go_default_library",
|
||||
"@io_k8s_klog_v2//:go_default_library",
|
||||
|
||||
+17
-33
@@ -27,27 +27,21 @@ import (
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/approve"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/check"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/completion"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/convert"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/create"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/deny"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/experimental"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/inspect"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/renew"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/status"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/version"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/build"
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/pkg/build/commands"
|
||||
)
|
||||
|
||||
func NewCertManagerCtlCommand(ctx context.Context, in io.Reader, out, err io.Writer) *cobra.Command {
|
||||
cmds := &cobra.Command{
|
||||
Use: "cert-manager",
|
||||
Use: build.Name(),
|
||||
Short: "cert-manager CLI tool to manage and configure cert-manager resources",
|
||||
Long: `
|
||||
kubectl cert-manager is a CLI tool manage and configure cert-manager resources for Kubernetes`,
|
||||
Long: build.WithTemplate(`
|
||||
{{.BuildName}} is a CLI tool manage and configure cert-manager resources for Kubernetes`),
|
||||
CompletionOptions: cobra.CompletionOptions{
|
||||
DisableDefaultCmd: true,
|
||||
},
|
||||
}
|
||||
cmds.SetUsageTemplate(usageTemplate)
|
||||
cmds.SetUsageTemplate(usageTemplate())
|
||||
|
||||
cmds.Flags().AddGoFlagSet(flag.CommandLine)
|
||||
flag.CommandLine.Parse([]string{})
|
||||
@@ -59,26 +53,15 @@ kubectl cert-manager is a CLI tool manage and configure cert-manager resources f
|
||||
}
|
||||
|
||||
ioStreams := genericclioptions.IOStreams{In: in, Out: out, ErrOut: err}
|
||||
cmds.AddCommand(version.NewCmdVersion(ctx, ioStreams))
|
||||
cmds.AddCommand(convert.NewCmdConvert(ctx, ioStreams))
|
||||
cmds.AddCommand(create.NewCmdCreate(ctx, ioStreams))
|
||||
cmds.AddCommand(renew.NewCmdRenew(ctx, ioStreams))
|
||||
cmds.AddCommand(status.NewCmdStatus(ctx, ioStreams))
|
||||
cmds.AddCommand(inspect.NewCmdInspect(ctx, ioStreams))
|
||||
cmds.AddCommand(approve.NewCmdApprove(ctx, ioStreams))
|
||||
cmds.AddCommand(deny.NewCmdDeny(ctx, ioStreams))
|
||||
cmds.AddCommand(check.NewCmdCheck(ctx, ioStreams))
|
||||
cmds.AddCommand(completion.NewCmdCompletion(ctx, ioStreams))
|
||||
|
||||
// Experimental features
|
||||
cmds.AddCommand(experimental.NewCmdExperimental(ctx, ioStreams))
|
||||
for _, registerCmd := range commands.Commands() {
|
||||
cmds.AddCommand(registerCmd(ctx, ioStreams))
|
||||
}
|
||||
|
||||
return cmds
|
||||
}
|
||||
|
||||
const usageTemplate = `Usage:{{if .Runnable}}
|
||||
kubectl {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
|
||||
kubectl {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
|
||||
func usageTemplate() string {
|
||||
return fmt.Sprintf(`Usage:{{if .Runnable}} %s {{end}}{{if .HasAvailableSubCommands}} %s [command]{{end}}{{if gt (len .Aliases) 0}}
|
||||
|
||||
Aliases:
|
||||
{{.NameAndAliases}}{{end}}{{if .HasExample}}
|
||||
@@ -98,5 +81,6 @@ Global Flags:
|
||||
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
|
||||
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
|
||||
|
||||
Use "kubectl {{.CommandPath}} [command] --help" for more information about a command.{{end}}
|
||||
`
|
||||
Use "%s [command] --help" for more information about a command.{{end}}
|
||||
`, build.Name(), build.Name(), build.Name())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user