Signed-off-by: allencloud <allen.sun@daocloud.io>
| ... | ... |
@@ -77,6 +77,8 @@ type CommonConfig struct {
|
| 77 | 77 |
Root string `json:"graph,omitempty"` |
| 78 | 78 |
SocketGroup string `json:"group,omitempty"` |
| 79 | 79 |
TrustKeyPath string `json:"-"` |
| 80 |
+ CorsHeaders string `json:"api-cors-headers,omitempty"` |
|
| 81 |
+ EnableCors bool `json:"api-enable-cors,omitempty"` |
|
| 80 | 82 |
|
| 81 | 83 |
// ClusterStore is the storage backend used for the cluster information. It is used by both |
| 82 | 84 |
// 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) |
| 135 | 135 |
cmd.StringVar(&config.ClusterAdvertise, []string{"-cluster-advertise"}, "", usageFn("Address or interface name to advertise"))
|
| 136 | 136 |
cmd.StringVar(&config.ClusterStore, []string{"-cluster-store"}, "", usageFn("Set the cluster store"))
|
| 137 | 137 |
cmd.Var(opts.NewNamedMapOpts("cluster-store-opts", config.ClusterOpts, nil), []string{"-cluster-store-opt"}, usageFn("Set cluster store options"))
|
| 138 |
+ cmd.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", usageFn("Set CORS headers in the remote API"))
|
|
| 138 | 139 |
} |
| 139 | 140 |
|
| 140 | 141 |
// IsValueSet returns true if a configuration value |
| ... | ... |
@@ -24,11 +24,8 @@ type Config struct {
|
| 24 | 24 |
CommonConfig |
| 25 | 25 |
|
| 26 | 26 |
// Fields below here are platform specific. |
| 27 |
- |
|
| 28 | 27 |
CgroupParent string `json:"cgroup-parent,omitempty"` |
| 29 | 28 |
ContainerdAddr string `json:"containerd,omitempty"` |
| 30 |
- CorsHeaders string `json:"api-cors-headers,omitempty"` |
|
| 31 |
- EnableCors bool `json:"api-enable-cors,omitempty"` |
|
| 32 | 29 |
EnableSelinuxSupport bool `json:"selinux-enabled,omitempty"` |
| 33 | 30 |
ExecRoot string `json:"exec-root,omitempty"` |
| 34 | 31 |
RemappedRoot string `json:"userns-remap,omitempty"` |
| ... | ... |
@@ -82,7 +79,6 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin |
| 82 | 82 |
cmd.Var(opts.NewIPOpt(&config.bridgeConfig.DefaultIP, "0.0.0.0"), []string{"#ip", "-ip"}, usageFn("Default IP when binding container ports"))
|
| 83 | 83 |
cmd.BoolVar(&config.bridgeConfig.EnableUserlandProxy, []string{"-userland-proxy"}, true, usageFn("Use userland proxy for loopback traffic"))
|
| 84 | 84 |
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"))
|
| 85 |
- cmd.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", usageFn("Set CORS headers in the remote API"))
|
|
| 86 | 85 |
cmd.StringVar(&config.CgroupParent, []string{"-cgroup-parent"}, "", usageFn("Set parent cgroup for all containers"))
|
| 87 | 86 |
cmd.StringVar(&config.RemappedRoot, []string{"-userns-remap"}, "", usageFn("User/Group setting for user namespaces"))
|
| 88 | 87 |
cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket"))
|
| ... | ... |
@@ -179,8 +179,9 @@ func (cli *DaemonCli) start() {
|
| 179 | 179 |
Logging: true, |
| 180 | 180 |
SocketGroup: cli.Config.SocketGroup, |
| 181 | 181 |
Version: dockerversion.Version, |
| 182 |
+ EnableCors: cli.Config.EnableCors, |
|
| 183 |
+ CorsHeaders: cli.Config.CorsHeaders, |
|
| 182 | 184 |
} |
| 183 |
- serverConfig = setPlatformServerConfig(serverConfig, cli.Config) |
|
| 184 | 185 |
|
| 185 | 186 |
if cli.Config.TLS {
|
| 186 | 187 |
tlsOptions := tlsconfig.Options{
|
| ... | ... |
@@ -12,7 +12,6 @@ import ( |
| 12 | 12 |
"syscall" |
| 13 | 13 |
|
| 14 | 14 |
"github.com/Sirupsen/logrus" |
| 15 |
- apiserver "github.com/docker/docker/api/server" |
|
| 16 | 15 |
"github.com/docker/docker/daemon" |
| 17 | 16 |
"github.com/docker/docker/libcontainerd" |
| 18 | 17 |
"github.com/docker/docker/pkg/mflag" |
| ... | ... |
@@ -22,13 +21,6 @@ import ( |
| 22 | 22 |
|
| 23 | 23 |
const defaultDaemonConfigFile = "/etc/docker/daemon.json" |
| 24 | 24 |
|
| 25 |
-func setPlatformServerConfig(serverConfig *apiserver.Config, daemonCfg *daemon.Config) *apiserver.Config {
|
|
| 26 |
- serverConfig.EnableCors = daemonCfg.EnableCors |
|
| 27 |
- serverConfig.CorsHeaders = daemonCfg.CorsHeaders |
|
| 28 |
- |
|
| 29 |
- return serverConfig |
|
| 30 |
-} |
|
| 31 |
- |
|
| 32 | 25 |
// currentUserIsOwner checks whether the current user is the owner of the given |
| 33 | 26 |
// file. |
| 34 | 27 |
func currentUserIsOwner(f string) bool {
|
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"syscall" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/Sirupsen/logrus" |
| 9 |
- apiserver "github.com/docker/docker/api/server" |
|
| 10 | 9 |
"github.com/docker/docker/daemon" |
| 11 | 10 |
"github.com/docker/docker/libcontainerd" |
| 12 | 11 |
"github.com/docker/docker/pkg/mflag" |
| ... | ... |
@@ -15,10 +14,6 @@ import ( |
| 15 | 15 |
|
| 16 | 16 |
var defaultDaemonConfigFile = os.Getenv("programdata") + string(os.PathSeparator) + "docker" + string(os.PathSeparator) + "config" + string(os.PathSeparator) + "daemon.json"
|
| 17 | 17 |
|
| 18 |
-func setPlatformServerConfig(serverConfig *apiserver.Config, daemonCfg *daemon.Config) *apiserver.Config {
|
|
| 19 |
- return serverConfig |
|
| 20 |
-} |
|
| 21 |
- |
|
| 22 | 18 |
// currentUserIsOwner checks whether the current user is the owner of the given |
| 23 | 19 |
// file. |
| 24 | 20 |
func currentUserIsOwner(f string) bool {
|