Explorar el Código

Merge pull request #1592 from mavenugo/exp

Handling the new experimental daemon flag
Santhosh Manohar hace 8 años
padre
commit
fa65450a79

+ 9 - 0
libnetwork/config/config.go

@@ -35,6 +35,7 @@ type Config struct {
 // DaemonCfg represents libnetwork core configuration
 type DaemonCfg struct {
 	Debug           bool
+	Experimental    bool
 	DataDir         string
 	DefaultNetwork  string
 	DefaultDriver   string
@@ -222,6 +223,14 @@ func OptionPluginGetter(pg plugingetter.PluginGetter) Option {
 	}
 }
 
+// OptionExperimental function returns an option setter for experimental daemon
+func OptionExperimental(exp bool) Option {
+	return func(c *Config) {
+		logrus.Debugf("Option Experimental: %v", exp)
+		c.Daemon.Experimental = exp
+	}
+}
+
 // ProcessOptions processes options and stores it in config
 func (c *Config) ProcessOptions(options ...Option) {
 	for _, opt := range options {

+ 2 - 2
libnetwork/controller.go

@@ -188,7 +188,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
 		return nil, err
 	}
 
-	for _, i := range getInitializers() {
+	for _, i := range getInitializers(c.cfg.Daemon.Experimental) {
 		var dcfg map[string]interface{}
 
 		// External plugins don't need config passed through daemon. They can
@@ -476,7 +476,7 @@ func (c *controller) ID() string {
 
 func (c *controller) BuiltinDrivers() []string {
 	drivers := []string{}
-	for _, i := range getInitializers() {
+	for _, i := range getInitializers(c.cfg.Daemon.Experimental) {
 		if i.ntype == "remote" {
 			continue
 		}

+ 0 - 2
libnetwork/drivers_experimental_linux.go

@@ -1,5 +1,3 @@
-// +build experimental
-
 package libnetwork
 
 import "github.com/docker/libnetwork/drivers/ipvlan"

+ 1 - 1
libnetwork/drivers_freebsd.go

@@ -5,7 +5,7 @@ import (
 	"github.com/docker/libnetwork/drivers/remote"
 )
 
-func getInitializers() []initializer {
+func getInitializers(experimental bool) []initializer {
 	return []initializer{
 		{null.Init, "null"},
 		{remote.Init, "remote"},

+ 4 - 2
libnetwork/drivers_linux.go

@@ -9,7 +9,7 @@ import (
 	"github.com/docker/libnetwork/drivers/remote"
 )
 
-func getInitializers() []initializer {
+func getInitializers(experimental bool) []initializer {
 	in := []initializer{
 		{bridge.Init, "bridge"},
 		{host.Init, "host"},
@@ -19,6 +19,8 @@ func getInitializers() []initializer {
 		{overlay.Init, "overlay"},
 	}
 
-	in = append(in, additionalDrivers()...)
+	if experimental {
+		in = append(in, additionalDrivers()...)
+	}
 	return in
 }

+ 1 - 1
libnetwork/drivers_solaris.go

@@ -6,7 +6,7 @@ import (
 	"github.com/docker/libnetwork/drivers/solaris/overlay"
 )
 
-func getInitializers() []initializer {
+func getInitializers(experimental bool) []initializer {
 	return []initializer{
 		{overlay.Init, "overlay"},
 		{bridge.Init, "bridge"},

+ 0 - 7
libnetwork/drivers_stub_linux.go

@@ -1,7 +0,0 @@
-// +build !experimental
-
-package libnetwork
-
-func additionalDrivers() []initializer {
-	return nil
-}

+ 1 - 1
libnetwork/drivers_windows.go

@@ -7,7 +7,7 @@ import (
 	"github.com/docker/libnetwork/drivers/windows/overlay"
 )
 
-func getInitializers() []initializer {
+func getInitializers(experimental bool) []initializer {
 	return []initializer{
 		{null.Init, "null"},
 		{overlay.Init, "overlay"},