From b4f2821e6d4ba6f6073365a244681df21f5d4472 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 8 Apr 2014 10:02:17 +0000 Subject: [PATCH] Make volumes-from a slice instead of string split Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- runconfig/hostconfig.go | 6 ++++-- runconfig/parse.go | 2 +- runtime/volumes.go | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/runconfig/hostconfig.go b/runconfig/hostconfig.go index 127c06d9c..3235bf1f4 100644 --- a/runconfig/hostconfig.go +++ b/runconfig/hostconfig.go @@ -16,7 +16,7 @@ type HostConfig struct { PublishAllPorts bool Dns []string DnsSearch []string - VolumesFrom string + VolumesFrom []string } func ContainerHostConfigFromJob(job *engine.Job) *HostConfig { @@ -24,7 +24,6 @@ func ContainerHostConfigFromJob(job *engine.Job) *HostConfig { ContainerIDFile: job.Getenv("ContainerIDFile"), Privileged: job.GetenvBool("Privileged"), PublishAllPorts: job.GetenvBool("PublishAllPorts"), - VolumesFrom: job.Getenv("VolumesFrom"), } job.GetenvJson("LxcConf", &hostConfig.LxcConf) job.GetenvJson("PortBindings", &hostConfig.PortBindings) @@ -40,5 +39,8 @@ func ContainerHostConfigFromJob(job *engine.Job) *HostConfig { if DnsSearch := job.GetenvList("DnsSearch"); DnsSearch != nil { hostConfig.DnsSearch = DnsSearch } + if VolumesFrom := job.GetenvList("VolumesFrom"); VolumesFrom != nil { + hostConfig.VolumesFrom = VolumesFrom + } return hostConfig } diff --git a/runconfig/parse.go b/runconfig/parse.go index b76f59a36..d395b49e8 100644 --- a/runconfig/parse.go +++ b/runconfig/parse.go @@ -229,7 +229,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf PublishAllPorts: *flPublishAll, Dns: flDns.GetAll(), DnsSearch: flDnsSearch.GetAll(), - VolumesFrom: strings.Join(flVolumesFrom.GetAll(), ","), + VolumesFrom: flVolumesFrom.GetAll(), } if sysInfo != nil && flMemory > 0 && !sysInfo.SwapLimit { diff --git a/runtime/volumes.go b/runtime/volumes.go index e74442e1b..004f1bb02 100644 --- a/runtime/volumes.go +++ b/runtime/volumes.go @@ -60,8 +60,8 @@ func setupMountsForContainer(container *Container, envPath string) error { func applyVolumesFrom(container *Container) error { volumesFrom := container.hostConfig.VolumesFrom - if volumesFrom != "" { - for _, containerSpec := range strings.Split(volumesFrom, ",") { + if len(volumesFrom) > 0 { + for _, containerSpec := range volumesFrom { var ( mountRW = true specParts = strings.SplitN(containerSpec, ":", 2) @@ -69,7 +69,7 @@ func applyVolumesFrom(container *Container) error { switch len(specParts) { case 0: - return fmt.Errorf("Malformed volumes-from specification: %s", volumesFrom) + return fmt.Errorf("Malformed volumes-from specification: %s", containerSpec) case 2: switch specParts[1] { case "ro":