diff --git a/daemon/config.go b/daemon/config.go index 0da156a16d..dd11ab7792 100644 --- a/daemon/config.go +++ b/daemon/config.go @@ -77,6 +77,8 @@ type CommonConfig struct { Root string `json:"graph,omitempty"` SocketGroup string `json:"group,omitempty"` TrustKeyPath string `json:"-"` + CorsHeaders string `json:"api-cors-headers,omitempty"` + EnableCors bool `json:"api-enable-cors,omitempty"` // ClusterStore is the storage backend used for the cluster information. It is used by both // multihost networking (to store networks and endpoints information) and by the node discovery @@ -135,6 +137,7 @@ func (config *Config) InstallCommonFlags(cmd *flag.FlagSet, usageFn func(string) cmd.StringVar(&config.ClusterAdvertise, []string{"-cluster-advertise"}, "", usageFn("Address or interface name to advertise")) cmd.StringVar(&config.ClusterStore, []string{"-cluster-store"}, "", usageFn("Set the cluster store")) cmd.Var(opts.NewNamedMapOpts("cluster-store-opts", config.ClusterOpts, nil), []string{"-cluster-store-opt"}, usageFn("Set cluster store options")) + cmd.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", usageFn("Set CORS headers in the remote API")) } // IsValueSet returns true if a configuration value diff --git a/daemon/config_unix.go b/daemon/config_unix.go index 3640b71932..441c349c8e 100644 --- a/daemon/config_unix.go +++ b/daemon/config_unix.go @@ -24,11 +24,8 @@ type Config struct { CommonConfig // Fields below here are platform specific. - CgroupParent string `json:"cgroup-parent,omitempty"` ContainerdAddr string `json:"containerd,omitempty"` - CorsHeaders string `json:"api-cors-headers,omitempty"` - EnableCors bool `json:"api-enable-cors,omitempty"` EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"` ExecRoot string `json:"exec-root,omitempty"` RemappedRoot string `json:"userns-remap,omitempty"` @@ -82,7 +79,6 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin cmd.Var(opts.NewIPOpt(&config.bridgeConfig.DefaultIP, "0.0.0.0"), []string{"#ip", "-ip"}, usageFn("Default IP when binding container ports")) cmd.BoolVar(&config.bridgeConfig.EnableUserlandProxy, []string{"-userland-proxy"}, true, usageFn("Use userland proxy for loopback traffic")) cmd.BoolVar(&config.EnableCors, []string{"#api-enable-cors", "#-api-enable-cors"}, false, usageFn("Enable CORS headers in the remote API, this is deprecated by --api-cors-header")) - cmd.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", usageFn("Set CORS headers in the remote API")) cmd.StringVar(&config.CgroupParent, []string{"-cgroup-parent"}, "", usageFn("Set parent cgroup for all containers")) cmd.StringVar(&config.RemappedRoot, []string{"-userns-remap"}, "", usageFn("User/Group setting for user namespaces")) cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket")) diff --git a/docker/daemon.go b/docker/daemon.go index c7c2ccfa06..e6e5ccbd70 100644 --- a/docker/daemon.go +++ b/docker/daemon.go @@ -179,8 +179,9 @@ func (cli *DaemonCli) start() { Logging: true, SocketGroup: cli.Config.SocketGroup, Version: dockerversion.Version, + EnableCors: cli.Config.EnableCors, + CorsHeaders: cli.Config.CorsHeaders, } - serverConfig = setPlatformServerConfig(serverConfig, cli.Config) if cli.Config.TLS { tlsOptions := tlsconfig.Options{ diff --git a/docker/daemon_unix.go b/docker/daemon_unix.go index 83fe0b5100..80d7b149b9 100644 --- a/docker/daemon_unix.go +++ b/docker/daemon_unix.go @@ -12,7 +12,6 @@ import ( "syscall" "github.com/Sirupsen/logrus" - apiserver "github.com/docker/docker/api/server" "github.com/docker/docker/daemon" "github.com/docker/docker/libcontainerd" "github.com/docker/docker/pkg/mflag" @@ -22,13 +21,6 @@ import ( const defaultDaemonConfigFile = "/etc/docker/daemon.json" -func setPlatformServerConfig(serverConfig *apiserver.Config, daemonCfg *daemon.Config) *apiserver.Config { - serverConfig.EnableCors = daemonCfg.EnableCors - serverConfig.CorsHeaders = daemonCfg.CorsHeaders - - return serverConfig -} - // currentUserIsOwner checks whether the current user is the owner of the given // file. func currentUserIsOwner(f string) bool { diff --git a/docker/daemon_windows.go b/docker/daemon_windows.go index 7bd77bcc1d..f452d1d4cf 100644 --- a/docker/daemon_windows.go +++ b/docker/daemon_windows.go @@ -6,7 +6,6 @@ import ( "syscall" "github.com/Sirupsen/logrus" - apiserver "github.com/docker/docker/api/server" "github.com/docker/docker/daemon" "github.com/docker/docker/libcontainerd" "github.com/docker/docker/pkg/mflag" @@ -15,10 +14,6 @@ import ( var defaultDaemonConfigFile = os.Getenv("programdata") + string(os.PathSeparator) + "docker" + string(os.PathSeparator) + "config" + string(os.PathSeparator) + "daemon.json" -func setPlatformServerConfig(serverConfig *apiserver.Config, daemonCfg *daemon.Config) *apiserver.Config { - return serverConfig -} - // currentUserIsOwner checks whether the current user is the owner of the given // file. func currentUserIsOwner(f string) bool {