Skip to content

Commit

Permalink
Update references to ctl binary name
Browse files Browse the repository at this point in the history
Signed-off-by: James Munnelly <james@munnelly.eu>
  • Loading branch information
munnerz committed May 5, 2020
1 parent b893ee4 commit 927a16f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
31 changes: 26 additions & 5 deletions cmd/ctl/cmd/cmd.go
Expand Up @@ -37,12 +37,12 @@ import (

func NewCertManagerCtlCommand(in io.Reader, out, err io.Writer, stopCh <-chan struct{}) *cobra.Command {
cmds := &cobra.Command{
Use: "kubectl-cert-manager",
Use: "cert-manager",
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`,
Run: runHelp,
}
cmds.SetUsageTemplate(usageTemplate)

kubeConfigFlags := genericclioptions.NewConfigFlags(true)
kubeConfigFlags.AddFlags(cmds.PersistentFlags())
Expand All @@ -67,6 +67,27 @@ kubectl cert-manager is a CLI tool manage and configure cert-manager resources f
return cmds
}

func runHelp(cmd *cobra.Command, args []string) {
cmd.Help()
}
const usageTemplate = `Usage:{{if .Runnable}}
kubectl {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
kubectl {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
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}}
`
6 changes: 3 additions & 3 deletions cmd/ctl/pkg/renew/renew.go
Expand Up @@ -43,13 +43,13 @@ Mark cert-manager Certificate resources for manual renewal.`))

example = templates.Examples(i18n.T(`
# Renew the Certificates named 'my-app' and 'vault' in the current context namespace.
ctl renew my-app vault
kubectl cert-manager renew my-app vault
# Renew all Certificates in the 'kube-system' namespace.
ctl renew --namespace kube-system --all
kubectl cert-manager renew --namespace kube-system --all
# Renew all Certificates in all namespaces, provided those Certificates have the label 'app=my-service
ctl renew --all-namespaces -l app=my-service`))
kubectl cert-manager renew --all-namespaces -l app=my-service`))
)

// Options is a struct to support renew command
Expand Down
2 changes: 1 addition & 1 deletion tools/cobra/main_test.go
Expand Up @@ -49,7 +49,7 @@ func TestRun(t *testing.T) {
},
"if directory given, should write docs": {
input: []string{"cobra", filepath.Join(rootDir, "foo")},
expDirs: []string{"foo/ca-injector", "foo/cert-manager-controller", "foo/kubectl-cert-manager"},
expDirs: []string{"foo/ca-injector", "foo/cert-manager-controller", "foo/cert-manager"},
},
}

Expand Down

0 comments on commit 927a16f

Please sign in to comment.