diff --git a/commands.go b/commands.go index f62fdeef20..2a6b59b84c 100644 --- a/commands.go +++ b/commands.go @@ -1480,18 +1480,6 @@ func (cli *DockerCli) CmdSearch(args ...string) error { // Ports type - Used to parse multiple -p flags type ports []int -// ListOpts type -type ListOpts []string - -func (opts *ListOpts) String() string { - return fmt.Sprint(*opts) -} - -func (opts *ListOpts) Set(value string) error { - *opts = append(*opts, value) - return nil -} - // AttachOpts stores arguments to 'docker run -a', eg. which streams to attach to type AttachOpts map[string]bool diff --git a/container.go b/container.go index c6899d2bc5..dfa19ab0c1 100644 --- a/container.go +++ b/container.go @@ -175,30 +175,30 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, flCpuShares := cmd.Int64("c", 0, "CPU shares (relative weight)") - var flPublish ListOpts + var flPublish utils.ListOpts cmd.Var(&flPublish, "p", "Publish a container's port to the host (use 'docker port' to see the actual mapping)") - var flExpose ListOpts + var flExpose utils.ListOpts cmd.Var(&flExpose, "expose", "Expose a port from the container without publishing it to your host") - var flEnv ListOpts + var flEnv utils.ListOpts cmd.Var(&flEnv, "e", "Set environment variables") - var flDns ListOpts + var flDns utils.ListOpts cmd.Var(&flDns, "dns", "Set custom dns servers") flVolumes := NewPathOpts() cmd.Var(flVolumes, "v", "Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)") - var flVolumesFrom ListOpts + var flVolumesFrom utils.ListOpts cmd.Var(&flVolumesFrom, "volumes-from", "Mount volumes from the specified container") flEntrypoint := cmd.String("entrypoint", "", "Overwrite the default entrypoint of the image") - var flLxcOpts ListOpts + var flLxcOpts utils.ListOpts cmd.Var(&flLxcOpts, "lxc-conf", "Add custom lxc options -lxc-conf=\"lxc.cgroup.cpuset.cpus = 0,1\"") - var flLinks ListOpts + var flLinks utils.ListOpts cmd.Var(&flLinks, "link", "Add link to another container (containerid:alias)") if err := cmd.Parse(args); err != nil { diff --git a/docker/docker.go b/docker/docker.go index 184b687c7c..a9c62e5534 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -36,7 +36,7 @@ func main() { flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.") flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.") flDns := flag.String("dns", "", "Set custom dns servers") - flHosts := docker.ListOpts{fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)} + flHosts := utils.ListOpts{fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)} flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use") flEnableIptables := flag.Bool("iptables", true, "Disable iptables within docker") flDefaultIp := flag.String("ip", "0.0.0.0", "Default ip address to use when binding a containers ports") diff --git a/sysinit.go b/sysinit.go index bbd68fa75a..e93b4787a3 100644 --- a/sysinit.go +++ b/sysinit.go @@ -69,7 +69,7 @@ func changeUser(u string) { } // Clear environment pollution introduced by lxc-start -func cleanupEnv(env ListOpts) { +func cleanupEnv(env utils.ListOpts) { os.Clearenv() for _, kv := range env { parts := strings.SplitN(kv, "=", 2) @@ -104,7 +104,7 @@ func SysInit() { var gw = flag.String("g", "", "gateway address") var workdir = flag.String("w", "", "workdir") - var flEnv ListOpts + var flEnv utils.ListOpts flag.Var(&flEnv, "e", "Set environment variables") flag.Parse() diff --git a/utils.go b/utils.go index 45949cb350..6da1c0aee6 100644 --- a/utils.go +++ b/utils.go @@ -175,7 +175,7 @@ func MergeConfig(userConf, imageConf *Config) error { return nil } -func parseLxcConfOpts(opts ListOpts) ([]KeyValuePair, error) { +func parseLxcConfOpts(opts utils.ListOpts) ([]KeyValuePair, error) { out := make([]KeyValuePair, len(opts)) for i, o := range opts { k, v, err := parseLxcOpt(o) diff --git a/utils/utils.go b/utils/utils.go index 0654874089..3bf2cf05be 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -21,6 +21,18 @@ import ( "time" ) +// ListOpts type +type ListOpts []string + +func (opts *ListOpts) String() string { + return fmt.Sprint(*opts) +} + +func (opts *ListOpts) Set(value string) error { + *opts = append(*opts, value) + return nil +} + // Go is a basic promise implementation: it wraps calls a function in a goroutine, // and returns a channel which will later return the function's return value. func Go(f func() error) chan error {