utils.go 809 B

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