1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

1.move cors into common config

2.windows can use cors, too
3.remove function setPlatformServerConfig

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-03-28 22:57:39 +08:00
parent 1e9b2355e4
commit 2feb88cbd3
5 changed files with 5 additions and 18 deletions

View file

@ -77,6 +77,8 @@ type CommonConfig struct {
Root string `json:"graph,omitempty"` Root string `json:"graph,omitempty"`
SocketGroup string `json:"group,omitempty"` SocketGroup string `json:"group,omitempty"`
TrustKeyPath string `json:"-"` 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 // 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 // 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.ClusterAdvertise, []string{"-cluster-advertise"}, "", usageFn("Address or interface name to advertise"))
cmd.StringVar(&config.ClusterStore, []string{"-cluster-store"}, "", usageFn("Set the cluster store")) 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.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 // IsValueSet returns true if a configuration value

View file

@ -24,11 +24,8 @@ type Config struct {
CommonConfig CommonConfig
// Fields below here are platform specific. // Fields below here are platform specific.
CgroupParent string `json:"cgroup-parent,omitempty"` CgroupParent string `json:"cgroup-parent,omitempty"`
ContainerdAddr string `json:"containerd,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"` EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"`
ExecRoot string `json:"exec-root,omitempty"` ExecRoot string `json:"exec-root,omitempty"`
RemappedRoot string `json:"userns-remap,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.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.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.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.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.RemappedRoot, []string{"-userns-remap"}, "", usageFn("User/Group setting for user namespaces"))
cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket")) cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket"))

View file

@ -179,8 +179,9 @@ func (cli *DaemonCli) start() {
Logging: true, Logging: true,
SocketGroup: cli.Config.SocketGroup, SocketGroup: cli.Config.SocketGroup,
Version: dockerversion.Version, Version: dockerversion.Version,
EnableCors: cli.Config.EnableCors,
CorsHeaders: cli.Config.CorsHeaders,
} }
serverConfig = setPlatformServerConfig(serverConfig, cli.Config)
if cli.Config.TLS { if cli.Config.TLS {
tlsOptions := tlsconfig.Options{ tlsOptions := tlsconfig.Options{

View file

@ -12,7 +12,6 @@ import (
"syscall" "syscall"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
apiserver "github.com/docker/docker/api/server"
"github.com/docker/docker/daemon" "github.com/docker/docker/daemon"
"github.com/docker/docker/libcontainerd" "github.com/docker/docker/libcontainerd"
"github.com/docker/docker/pkg/mflag" "github.com/docker/docker/pkg/mflag"
@ -22,13 +21,6 @@ import (
const defaultDaemonConfigFile = "/etc/docker/daemon.json" 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 // currentUserIsOwner checks whether the current user is the owner of the given
// file. // file.
func currentUserIsOwner(f string) bool { func currentUserIsOwner(f string) bool {

View file

@ -6,7 +6,6 @@ import (
"syscall" "syscall"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
apiserver "github.com/docker/docker/api/server"
"github.com/docker/docker/daemon" "github.com/docker/docker/daemon"
"github.com/docker/docker/libcontainerd" "github.com/docker/docker/libcontainerd"
"github.com/docker/docker/pkg/mflag" "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" 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 // currentUserIsOwner checks whether the current user is the owner of the given
// file. // file.
func currentUserIsOwner(f string) bool { func currentUserIsOwner(f string) bool {