github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/daemon/utils.go (about) 1 package daemon 2 3 import ( 4 "errors" 5 "fmt" 6 "strings" 7 8 "github.com/docker/docker/runconfig" 9 ) 10 11 func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) { 12 if hostConfig == nil { 13 return nil, nil 14 } 15 16 out := []string{} 17 18 // merge in the lxc conf options into the generic config map 19 if lxcConf := hostConfig.LxcConf; lxcConf != nil { 20 lxSlice := lxcConf.Slice() 21 for _, pair := range lxSlice { 22 // because lxc conf gets the driver name lxc.XXXX we need to trim it off 23 // and let the lxc driver add it back later if needed 24 if !strings.Contains(pair.Key, ".") { 25 return nil, errors.New("Illegal Key passed into LXC Configurations") 26 } 27 parts := strings.SplitN(pair.Key, ".", 2) 28 out = append(out, fmt.Sprintf("%s=%s", parts[1], pair.Value)) 29 } 30 } 31 32 return out, nil 33 }