Embed NoopNetworkPlugin into other network plugins

Let Noop handle common functions.
This commit is contained in:
Dan Williams
2016-03-22 11:38:21 -05:00
parent be8ce6c385
commit f1323103db
5 changed files with 15 additions and 16 deletions

View File

@@ -94,7 +94,7 @@ type Host interface {
func InitNetworkPlugin(plugins []NetworkPlugin, networkPluginName string, host Host) (NetworkPlugin, error) {
if networkPluginName == "" {
// default to the no_op plugin
plug := &noopNetworkPlugin{}
plug := &NoopNetworkPlugin{}
if err := plug.Init(host); err != nil {
return nil, err
}
@@ -137,12 +137,12 @@ func UnescapePluginName(in string) string {
return strings.Replace(in, "~", "/", -1)
}
type noopNetworkPlugin struct {
type NoopNetworkPlugin struct {
}
const sysctlBridgeCallIptables = "net/bridge/bridge-nf-call-iptables"
func (plugin *noopNetworkPlugin) Init(host Host) error {
func (plugin *NoopNetworkPlugin) Init(host Host) error {
// Set bridge-nf-call-iptables=1 to maintain compatibility with older
// kubernetes versions to ensure the iptables-based kube proxy functions
// correctly. Other plugins are responsible for setting this correctly
@@ -159,21 +159,21 @@ func (plugin *noopNetworkPlugin) Init(host Host) error {
return nil
}
func (plugin *noopNetworkPlugin) Event(name string, details map[string]interface{}) {
func (plugin *NoopNetworkPlugin) Event(name string, details map[string]interface{}) {
}
func (plugin *noopNetworkPlugin) Name() string {
func (plugin *NoopNetworkPlugin) Name() string {
return DefaultPluginName
}
func (plugin *noopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.DockerID) error {
func (plugin *NoopNetworkPlugin) SetUpPod(namespace string, name string, id kubecontainer.DockerID) error {
return nil
}
func (plugin *noopNetworkPlugin) TearDownPod(namespace string, name string, id kubecontainer.DockerID) error {
func (plugin *NoopNetworkPlugin) TearDownPod(namespace string, name string, id kubecontainer.DockerID) error {
return nil
}
func (plugin *noopNetworkPlugin) Status(namespace string, name string, id kubecontainer.DockerID) (*PodNetworkStatus, error) {
func (plugin *NoopNetworkPlugin) Status(namespace string, name string, id kubecontainer.DockerID) (*PodNetworkStatus, error) {
return nil, nil
}