mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Make volumes-from a slice instead of string split
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
		
							parent
							
								
									af9746412b
								
							
						
					
					
						commit
						b4f2821e6d
					
				
					 3 changed files with 8 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue