diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-11-18 22:20:32 +0100 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-11-18 22:57:32 +0100 |
commit | 22ef7b6208fbe958594577bbec37ddca4f1dff82 (patch) | |
tree | 4b68b81729a46edb575f40ad600002c90d6cd8ab | |
parent | 0376e6092c850435b4740876045fdccb467cafd8 (diff) | |
download | podman-22ef7b6208fbe958594577bbec37ddca4f1dff82.tar.gz podman-22ef7b6208fbe958594577bbec37ddca4f1dff82.tar.bz2 podman-22ef7b6208fbe958594577bbec37ddca4f1dff82.zip |
fix duplicated logs command
Podman logs was defined twice, once for container logs and once for pod
logs. This causes problems with the shell completion. Also podman --help
showed this command twice.
[NO NEW TESTS NEEDED]
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r-- | cmd/podman/pods/logs.go | 31 | ||||
-rwxr-xr-x | hack/xref-helpmsgs-manpages | 7 |
2 files changed, 13 insertions, 25 deletions
diff --git a/cmd/podman/pods/logs.go b/cmd/podman/pods/logs.go index fe5205669..a79c0430f 100644 --- a/cmd/podman/pods/logs.go +++ b/cmd/podman/pods/logs.go @@ -27,11 +27,11 @@ type logsOptionsWrapper struct { var ( logsPodOptions logsOptionsWrapper logsPodDescription = `Displays logs for pod with one or more containers.` - logsPodCommand = &cobra.Command{ + podLogsCommand = &cobra.Command{ Use: "logs [options] POD", Short: "Fetch logs for pod with one or more containers", Long: logsPodDescription, - // We dont want users to invoke latest and pod togather + // We dont want users to invoke latest and pod together Args: func(cmd *cobra.Command, args []string) error { switch { case registry.IsRemote() && logsPodOptions.Latest: @@ -53,35 +53,16 @@ var ( podman pod logs --follow=true --since 10m podID podman pod logs mywebserver`, } - - containerLogsCommand = &cobra.Command{ - Use: logsPodCommand.Use, - Short: logsPodCommand.Short, - Long: logsPodCommand.Long, - Args: logsPodCommand.Args, - RunE: logsPodCommand.RunE, - ValidArgsFunction: logsPodCommand.ValidArgsFunction, - Example: `podman pod logs podId - podman pod logs -c ctrname podName - podman pod logs --tail 2 mywebserver - podman pod logs --follow=true --since 10m podID`, - } ) func init() { + // pod logs registry.Commands = append(registry.Commands, registry.CliCommand{ - Command: logsPodCommand, - }) - logsFlags(logsPodCommand) - validate.AddLatestFlag(logsPodCommand, &logsPodOptions.Latest) - - // container logs - registry.Commands = append(registry.Commands, registry.CliCommand{ - Command: containerLogsCommand, + Command: podLogsCommand, Parent: podCmd, }) - logsFlags(containerLogsCommand) - validate.AddLatestFlag(containerLogsCommand, &logsPodOptions.Latest) + logsFlags(podLogsCommand) + validate.AddLatestFlag(podLogsCommand, &logsPodOptions.Latest) } func logsFlags(cmd *cobra.Command) { diff --git a/hack/xref-helpmsgs-manpages b/hack/xref-helpmsgs-manpages index 6a2d627bb..a447f4da1 100755 --- a/hack/xref-helpmsgs-manpages +++ b/hack/xref-helpmsgs-manpages @@ -242,6 +242,13 @@ sub podman_help { if ($line =~ /^\s{1,4}(\S+)\s/) { my $subcommand = $1; print "> podman @_ $subcommand\n" if $debug; + + # check that the same subcommand is not listed twice (#12356) + if (exists $help{$subcommand}) { + warn "$ME: 'podman @_ help' lists '$subcommand' twice\n"; + ++$Errs; + } + $help{$subcommand} = podman_help(@_, $subcommand) unless $subcommand eq 'help'; # 'help' not in man } |