func ParseConfig(config *Config, args ...string) []string { for i, arg := range args { if strings.HasPrefix(arg, "--bip") { config.BridgeAddress = util.GetValue(i, args) } else if strings.HasPrefix(arg, "--fixed-cidr") { config.BridgeAddress = util.GetValue(i, args) } else if strings.HasPrefix(arg, "-b") || strings.HasPrefix(arg, "--bridge") { config.BridgeName = util.GetValue(i, args) } else if strings.HasPrefix(arg, "--mtu") { mtu, err := strconv.Atoi(util.GetValue(i, args)) if err != nil { config.BridgeMtu = mtu } } else if strings.HasPrefix(arg, "-g") || strings.HasPrefix(arg, "--graph") { config.GraphDirectory = util.GetValue(i, args) } } if config.BridgeName != "" && config.BridgeAddress != "" { newArgs := []string{} skip := false for _, arg := range args { if skip { skip = false continue } if arg == "--bip" { skip = true continue } else if strings.HasPrefix(arg, "--bip=") { continue } newArgs = append(newArgs, arg) } args = newArgs } return args }
func touchSockets(args ...string) error { touched := false for i, arg := range args { if strings.HasPrefix(arg, "-H") { val := util.GetValue(i, args) if strings.HasPrefix(val, "unix://") { val = val[len("unix://"):] log.Debugf("Creating temp file at %s", val) if err := touchSocket(val); err != nil { return err } touched = true } } } if !touched { return touchSocket("/var/run/docker.sock") } return nil }