summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-05-17 16:14:59 +0200
committerPaul Holzinger <pholzing@redhat.com>2022-05-19 14:04:10 +0200
commit318e95fd2a9a8b1bcd0f1caec4612335cc1ee591 (patch)
tree79329c2589d6330ddc905af469dc579ed9100261
parent9915b8f599da2f179c8dd1bff7951141a7bdaa1b (diff)
downloadpodman-318e95fd2a9a8b1bcd0f1caec4612335cc1ee591.tar.gz
podman-318e95fd2a9a8b1bcd0f1caec4612335cc1ee591.tar.bz2
podman-318e95fd2a9a8b1bcd0f1caec4612335cc1ee591.zip
shell completion: fix podman event --filter values
The completion suggested incorrect values for `podman events --filter type=` . It should only list types not the event status. Also make sure to use the constants instead of duplicating the strings. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--cmd/podman/common/completion.go21
-rw-r--r--libpod/events/config.go2
2 files changed, 18 insertions, 5 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index e07e28dab..1275d6cc0 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/image/v5/pkg/sysregistriesv2"
"github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/libpod/define"
+ "github.com/containers/podman/v4/libpod/events"
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/containers/podman/v4/pkg/rootless"
systemdDefine "github.com/containers/podman/v4/pkg/systemd/define"
@@ -1091,11 +1092,21 @@ func getMethodNames(f reflect.Value, prefix string) []string {
// AutocompleteEventFilter - Autocomplete event filter flag options.
// -> "container=", "event=", "image=", "pod=", "volume=", "type="
func AutocompleteEventFilter(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ event := func(_ string) ([]string, cobra.ShellCompDirective) {
+ return []string{events.Attach.String(), events.AutoUpdate.String(), events.Checkpoint.String(), events.Cleanup.String(),
+ events.Commit.String(), events.Create.String(), events.Exec.String(), events.ExecDied.String(),
+ events.Exited.String(), events.Export.String(), events.Import.String(), events.Init.String(), events.Kill.String(),
+ events.LoadFromArchive.String(), events.Mount.String(), events.NetworkConnect.String(),
+ events.NetworkDisconnect.String(), events.Pause.String(), events.Prune.String(), events.Pull.String(),
+ events.Push.String(), events.Refresh.String(), events.Remove.String(), events.Rename.String(),
+ events.Renumber.String(), events.Restart.String(), events.Restore.String(), events.Save.String(),
+ events.Start.String(), events.Stop.String(), events.Sync.String(), events.Tag.String(), events.Unmount.String(),
+ events.Unpause.String(), events.Untag.String(),
+ }, cobra.ShellCompDirectiveNoFileComp
+ }
eventTypes := func(_ string) ([]string, cobra.ShellCompDirective) {
- return []string{"attach", "checkpoint", "cleanup", "commit", "connect", "create", "disconnect", "exec",
- "exec_died", "exited", "export", "import", "init", "kill", "loadFromArchive", "mount", "pause",
- "prune", "pull", "push", "refresh", "remove", "rename", "renumber", "restart", "restore", "save",
- "start", "stop", "sync", "tag", "unmount", "unpause", "untag",
+ return []string{events.Container.String(), events.Image.String(), events.Network.String(),
+ events.Pod.String(), events.System.String(), events.Volume.String(),
}, cobra.ShellCompDirectiveNoFileComp
}
kv := keyValueCompletion{
@@ -1103,7 +1114,7 @@ func AutocompleteEventFilter(cmd *cobra.Command, args []string, toComplete strin
"image=": func(s string) ([]string, cobra.ShellCompDirective) { return getImages(cmd, s) },
"pod=": func(s string) ([]string, cobra.ShellCompDirective) { return getPods(cmd, s, completeDefault) },
"volume=": func(s string) ([]string, cobra.ShellCompDirective) { return getVolumes(cmd, s) },
- "event=": eventTypes,
+ "event=": event,
"type=": eventTypes,
}
return completeKeyValues(toComplete, kv)
diff --git a/libpod/events/config.go b/libpod/events/config.go
index 00cdca007..2e7016136 100644
--- a/libpod/events/config.go
+++ b/libpod/events/config.go
@@ -98,6 +98,8 @@ type Type string
// Status describes the actual event action (stop, start, create, kill)
type Status string
+// When updating this list below please also update the shell completion list in
+// cmd/podman/common/completion.go and the StringToXXX function in events.go.
const (
// Container - event is related to containers
Container Type = "container"