mirror of
https://github.com/containers/podman.git
synced 2026-03-12 03:39:03 -04:00
To prevent code duplication when creating new network backends move reusable code into a separate internal package. This allows all network backends to use the same code as long as they implement the new NetUtil interface. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
20 lines
730 B
Go
20 lines
730 B
Go
package util
|
|
|
|
import "github.com/containers/podman/v3/libpod/network/types"
|
|
|
|
// This is a helper package to allow code sharing between the different
|
|
// network interfaces.
|
|
|
|
// NetUtil is a helper interface which all network interfaces should implement to allow easy code sharing
|
|
type NetUtil interface {
|
|
// ForEach eaxecutes the given function for each network
|
|
ForEach(func(types.Network))
|
|
// Len returns the number of networks
|
|
Len() int
|
|
// DefaultInterfaceName return the default interface name, this will be suffixed by a number
|
|
DefaultInterfaceName() string
|
|
// Network returns the network with the given name or ID.
|
|
// It returns an error if the network is not found
|
|
Network(nameOrID string) (*types.Network, error)
|
|
}
|