From 5e8309464aea005fbc1604c304a94760aff4ee9a Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Mon, 13 Sep 2021 14:07:05 +0200 Subject: Add Drivers method to the Network Interface Drivers should return the list of supported network drivers by this plugin. This is useful for podman info. Signed-off-by: Paul Holzinger --- libpod/info.go | 4 +--- libpod/network/cni/network.go | 6 ++++++ libpod/network/types/network.go | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libpod/info.go b/libpod/info.go index 122a6b587..fb28c97dd 100644 --- a/libpod/info.go +++ b/libpod/info.go @@ -18,7 +18,6 @@ import ( "github.com/containers/image/v5/pkg/sysregistriesv2" "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/linkmode" - "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/cgroups" "github.com/containers/podman/v3/pkg/rootless" "github.com/containers/storage" @@ -73,8 +72,7 @@ func (r *Runtime) info() (*define.Info, error) { volumePlugins = append(volumePlugins, plugin) } info.Plugins.Volume = volumePlugins - // TODO move this into the new network interface - info.Plugins.Network = []string{types.BridgeNetworkDriver, types.MacVLANNetworkDriver} + info.Plugins.Network = r.network.Drivers() info.Plugins.Log = logDrivers info.Registries = registries diff --git a/libpod/network/cni/network.go b/libpod/network/cni/network.go index 4e4ea7ee5..46e07f780 100644 --- a/libpod/network/cni/network.go +++ b/libpod/network/cni/network.go @@ -106,6 +106,12 @@ func NewCNINetworkInterface(conf InitConfig) (types.ContainerNetwork, error) { return n, nil } +// Drivers will return the list of supported network drivers +// for this interface. +func (n *cniNetwork) Drivers() []string { + return []string{types.BridgeNetworkDriver, types.MacVLANNetworkDriver} +} + func (n *cniNetwork) loadNetworks() error { // skip loading networks if they are already loaded if n.networks != nil { diff --git a/libpod/network/types/network.go b/libpod/network/types/network.go index ad46c9ac1..6053ceb29 100644 --- a/libpod/network/types/network.go +++ b/libpod/network/types/network.go @@ -23,6 +23,10 @@ type ContainerNetwork interface { Setup(namespacePath string, options SetupOptions) (map[string]StatusBlock, error) // Teardown will teardown the container network namespace. Teardown(namespacePath string, options TeardownOptions) error + + // Drivers will return the list of supported network drivers + // for this interface. + Drivers() []string } // Network describes the Network attributes. -- cgit v1.2.3-54-g00ecf