From f93ba587c608e2678b176f1460b32e8a144edf1a Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 28 Apr 2022 14:49:03 +0200 Subject: shell completion --format: work with nil structs AutocompleteFormat() takes the format struct as argument. Often the structs are deeply nested and contain other structs. Up until now if there was a pointer to a struct the logic was not able to get the field names from that, simply because the pointer was nil. However it is possible to create a new initialized type with reflect.New(). This allows us to complete all struct fields/functions even when there nil pointers. Therefore we can drop the extra initialization which was done by some callers. Signed-off-by: Paul Holzinger --- cmd/podman/system/info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/podman/system') diff --git a/cmd/podman/system/info.go b/cmd/podman/system/info.go index e95e9336d..87ceaa7cd 100644 --- a/cmd/podman/system/info.go +++ b/cmd/podman/system/info.go @@ -66,7 +66,7 @@ func infoFlags(cmd *cobra.Command) { formatFlagName := "format" flags.StringVarP(&inFormat, formatFlagName, "f", "", "Change the output format to JSON or a Go template") - _ = cmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(define.Info{Host: &define.HostInfo{}, Store: &define.StoreInfo{}})) + _ = cmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(define.Info{})) } func info(cmd *cobra.Command, args []string) error { -- cgit v1.2.3-54-g00ecf