mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
549f508d5b
This changes the namespace configuration on the config to include the name of the namespace along with an optional path. This path is used to point to a file of another namespace for the namespace so that it can be joined in place of the empty, initialized namespace. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
35 lines
783 B
Go
35 lines
783 B
Go
// +build linux
|
|
|
|
package network
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
var (
|
|
ErrNotValidStrategyType = errors.New("not a valid network strategy type")
|
|
)
|
|
|
|
var strategies = map[string]NetworkStrategy{
|
|
"veth": &Veth{},
|
|
"loopback": &Loopback{},
|
|
}
|
|
|
|
// NetworkStrategy represents a specific network configuration for
|
|
// a container's networking stack
|
|
type NetworkStrategy interface {
|
|
Create(*Network, int, *NetworkState) error
|
|
Initialize(*Network, *NetworkState) error
|
|
}
|
|
|
|
// GetStrategy returns the specific network strategy for the
|
|
// provided type. If no strategy is registered for the type an
|
|
// ErrNotValidStrategyType is returned.
|
|
func GetStrategy(tpe string) (NetworkStrategy, error) {
|
|
s, exists := strategies[tpe]
|
|
if !exists {
|
|
return nil, ErrNotValidStrategyType
|
|
}
|
|
return s, nil
|
|
}
|