diff --git a/config/config.go b/config/config.go index 2694f1b0..1af7c8fe 100644 --- a/config/config.go +++ b/config/config.go @@ -194,9 +194,9 @@ func Dump(private, full bool) (string, error) { func (c *Config) configureConsole() error { if console, ok := c.SystemContainers[CONSOLE_CONTAINER]; ok { if c.Console.Persistent { - console.Labels = append(console.Labels, REMOVE+"=false") + console.Labels.MapParts()[REMOVE] = "false" } else { - console.Labels = append(console.Labels, REMOVE+"=true") + console.Labels.MapParts()[REMOVE] = "true" } } diff --git a/config/default.go b/config/default.go index 11813391..f35340bf 100644 --- a/config/default.go +++ b/config/default.go @@ -79,10 +79,10 @@ func NewConfig() *Config { "udev": { Net: "host", Privileged: true, - Labels: []string{ - DETACH + "=false", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + DETACH: "false", + SCOPE: SYSTEM, + }), Volumes: []string{ "/dev:/host/dev", "/lib/modules:/lib/modules", @@ -98,10 +98,10 @@ func NewConfig() *Config { Restart: "always", Net: "host", Privileged: true, - Labels: []string{ - DETACH + "=true", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + DETACH: "true", + SCOPE: SYSTEM, + }), Environment: []string{ "DAEMON=true", }, @@ -114,10 +114,10 @@ func NewConfig() *Config { Net: "none", ReadOnly: true, Privileged: true, - Labels: []string{ - CREATE_ONLY + "=true", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + CREATE_ONLY: "true", + SCOPE: SYSTEM, + }), Volumes: []string{ "/dev:/host/dev", "/var/lib/rancher/conf:/var/lib/rancher/conf", @@ -134,10 +134,10 @@ func NewConfig() *Config { Net: "none", ReadOnly: true, Privileged: true, - Labels: []string{ - CREATE_ONLY + "=true", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + CREATE_ONLY: "true", + SCOPE: SYSTEM, + }), Volumes: []string{ "/init:/sbin/halt:ro", "/init:/sbin/poweroff:ro", @@ -159,10 +159,10 @@ func NewConfig() *Config { Net: "none", ReadOnly: true, Privileged: true, - Labels: []string{ - CREATE_ONLY + "=true", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + CREATE_ONLY: "true", + SCOPE: SYSTEM, + }), Volumes: []string{ "/home:/home", "/opt:/opt", @@ -174,10 +174,10 @@ func NewConfig() *Config { Net: "none", ReadOnly: true, Privileged: true, - Labels: []string{ - CREATE_ONLY + "=true", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + CREATE_ONLY: "true", + SCOPE: SYSTEM, + }), Volumes: []string{ "/var/lib/rancher:/var/lib/rancher", "/var/lib/docker:/var/lib/docker", @@ -190,10 +190,10 @@ func NewConfig() *Config { Net: "none", ReadOnly: true, Privileged: true, - Labels: []string{ - CREATE_ONLY + "=true", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + CREATE_ONLY: "true", + SCOPE: SYSTEM, + }), VolumesFrom: []string{ "docker-volumes", "command-volumes", @@ -206,11 +206,11 @@ func NewConfig() *Config { Image: "cloudinit", Privileged: true, Net: "host", - Labels: []string{ - RELOAD_CONFIG + "=true", - DETACH + "=false", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + RELOAD_CONFIG: "true", + DETACH: "false", + SCOPE: SYSTEM, + }), Environment: []string{ "CLOUD_INIT_NETWORK=false", }, @@ -223,10 +223,10 @@ func NewConfig() *Config { Image: "network", Privileged: true, Net: "host", - Labels: []string{ - DETACH + "=false", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + DETACH: "false", + SCOPE: SYSTEM, + }), Links: []string{ "cloud-init-pre", }, @@ -238,11 +238,11 @@ func NewConfig() *Config { "cloud-init": { Image: "cloudinit", Privileged: true, - Labels: []string{ - RELOAD_CONFIG + "=true", - DETACH + "=false", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + RELOAD_CONFIG: "true", + DETACH: "false", + SCOPE: SYSTEM, + }), Net: "host", Links: []string{ "cloud-init-pre", @@ -258,9 +258,9 @@ func NewConfig() *Config { Restart: "always", Privileged: true, Net: "host", - Labels: []string{ - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + SCOPE: SYSTEM, + }), Links: []string{ "cloud-init", "network", @@ -271,9 +271,9 @@ func NewConfig() *Config { Restart: "always", Privileged: true, Net: "host", - Labels: []string{ - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + SCOPE: SYSTEM, + }), VolumesFrom: []string{ "system-volumes", }, @@ -286,9 +286,9 @@ func NewConfig() *Config { Pid: "host", Ipc: "host", Net: "host", - Labels: []string{ - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + SCOPE: SYSTEM, + }), Links: []string{ "network", }, @@ -299,10 +299,10 @@ func NewConfig() *Config { "userdockerwait": { Image: "userdockerwait", Net: "host", - Labels: []string{ - DETACH + "=false", - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + DETACH: "false", + SCOPE: SYSTEM, + }), Links: []string{ "userdocker", }, @@ -316,9 +316,9 @@ func NewConfig() *Config { Links: []string{ "cloud-init", }, - Labels: []string{ - SCOPE + "=" + SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + SCOPE: SYSTEM, + }), VolumesFrom: []string{ "all-volumes", }, diff --git a/docker/factory.go b/docker/factory.go index a925a4d3..d0842b61 100644 --- a/docker/factory.go +++ b/docker/factory.go @@ -77,7 +77,7 @@ func (c *containerBasedService) Name() string { } func isSystemService(serviceConfig *project.ServiceConfig) bool { - return util.GetValue(serviceConfig.Labels, config.SCOPE) == config.SYSTEM + return serviceConfig.Labels.MapParts()[config.SCOPE] == config.SYSTEM } func (c *ContainerFactory) Create(project *project.Project, name string, serviceConfig *project.ServiceConfig) (project.Service, error) { diff --git a/init/bootstrap.go b/init/bootstrap.go index ae826128..152f9714 100644 --- a/init/bootstrap.go +++ b/init/bootstrap.go @@ -79,10 +79,10 @@ outer: Privileged: true, Image: "autoformat", Command: format, - Labels: []string{ - config.DETACH + "=false", - config.SCOPE + "=" + config.SYSTEM, - }, + Labels: project.NewSliceorMap(map[string]string{ + config.DETACH: "false", + config.SCOPE: config.SYSTEM, + }), LogDriver: "json-file", Environment: []string{ "MAGIC=" + boot2dockerMagic,