From 721518279aff4540837230ea32f09bb448234aa5 Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Tue, 13 Dec 2016 13:22:55 -0800 Subject: [PATCH] Handling the new experimental daemon flag related to https://github.com/docker/docker/issues/29368 Signed-off-by: Madhu Venugopal --- libnetwork/config/config.go | 9 +++++++++ libnetwork/controller.go | 4 ++-- libnetwork/drivers_experimental_linux.go | 2 -- libnetwork/drivers_freebsd.go | 2 +- libnetwork/drivers_linux.go | 6 ++++-- libnetwork/drivers_solaris.go | 2 +- libnetwork/drivers_stub_linux.go | 7 ------- libnetwork/drivers_windows.go | 2 +- 8 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 libnetwork/drivers_stub_linux.go diff --git a/libnetwork/config/config.go b/libnetwork/config/config.go index 6e29563df6..171f1852c0 100644 --- a/libnetwork/config/config.go +++ b/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 { diff --git a/libnetwork/controller.go b/libnetwork/controller.go index 154b337a94..b551230baf 100644 --- a/libnetwork/controller.go +++ b/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 } diff --git a/libnetwork/drivers_experimental_linux.go b/libnetwork/drivers_experimental_linux.go index ca7c9f9b0e..4f540d4a87 100644 --- a/libnetwork/drivers_experimental_linux.go +++ b/libnetwork/drivers_experimental_linux.go @@ -1,5 +1,3 @@ -// +build experimental - package libnetwork import "github.com/docker/libnetwork/drivers/ipvlan" diff --git a/libnetwork/drivers_freebsd.go b/libnetwork/drivers_freebsd.go index 416bba04d8..d117c25780 100644 --- a/libnetwork/drivers_freebsd.go +++ b/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"}, diff --git a/libnetwork/drivers_linux.go b/libnetwork/drivers_linux.go index 50416512f3..c53d516fa6 100644 --- a/libnetwork/drivers_linux.go +++ b/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 } diff --git a/libnetwork/drivers_solaris.go b/libnetwork/drivers_solaris.go index ad5184a3fc..c4fcd96b7e 100644 --- a/libnetwork/drivers_solaris.go +++ b/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"}, diff --git a/libnetwork/drivers_stub_linux.go b/libnetwork/drivers_stub_linux.go deleted file mode 100644 index e20428c72f..0000000000 --- a/libnetwork/drivers_stub_linux.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build !experimental - -package libnetwork - -func additionalDrivers() []initializer { - return nil -} diff --git a/libnetwork/drivers_windows.go b/libnetwork/drivers_windows.go index 87705e7652..384d855cb8 100644 --- a/libnetwork/drivers_windows.go +++ b/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"},