From e7eed5aa90049e70368a912a7e454957bf1e261b Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 18 Nov 2022 16:44:40 +0100 Subject: [PATCH] shell completion: fix hard coded network drivers Depending on the backend (CNI, netavark) we support different drivers, the auto completion should only suggest the ones that are available. This list is podman info so we can get the correct list for local and remote. [NO NEW TESTS NEEDED] Signed-off-by: Paul Holzinger --- cmd/podman/common/completion.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go index 60d056aaae..7595205bb8 100644 --- a/cmd/podman/common/completion.go +++ b/cmd/podman/common/completion.go @@ -1409,10 +1409,18 @@ func AutocompleteManifestFormat(cmd *cobra.Command, args []string, toComplete st } // AutocompleteNetworkDriver - Autocomplete network driver option. -// -> "bridge", "macvlan" func AutocompleteNetworkDriver(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - drivers := []string{types.BridgeNetworkDriver, types.MacVLANNetworkDriver, types.IPVLANNetworkDriver} - return drivers, cobra.ShellCompDirectiveNoFileComp + engine, err := setupContainerEngine(cmd) + if err != nil { + cobra.CompErrorln(err.Error()) + return nil, cobra.ShellCompDirectiveNoFileComp + } + info, err := engine.Info(registry.Context()) + if err != nil { + cobra.CompErrorln(err.Error()) + return nil, cobra.ShellCompDirectiveNoFileComp + } + return info.Plugins.Network, cobra.ShellCompDirectiveNoFileComp } // AutocompleteNetworkIPAMDriver - Autocomplete network ipam driver option.