1cad0a1d6c
Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion) Remove loopback code from veth strategy Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion) Looback strategy: Get rid of uneeded code in Create Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion) Use append when building network strategy list Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion) Swap loopback and veth strategies in Networks list Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion) Revert "Swap loopback and veth strategies in Networks list" This reverts commit 3b8b2c8454171d79bed5e9a80165172617e92fc7. Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion) When initializing networks, only return from the loop if there is an error Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion)
33 lines
853 B
Go
33 lines
853 B
Go
package network
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/dotcloud/docker/pkg/libcontainer"
|
|
)
|
|
|
|
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(*libcontainer.Network, int, libcontainer.Context) error
|
|
Initialize(*libcontainer.Network, libcontainer.Context) 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
|
|
}
|