1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Move ListOps to utils submodule

This will be needed for later use in docker-init without a docker
dependency
This commit is contained in:
Alexander Larsson 2013-10-10 10:49:18 +02:00 committed by Victor Vieux
parent 249f5a65a5
commit d063c8d941
6 changed files with 23 additions and 23 deletions

View file

@ -1480,18 +1480,6 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
// Ports type - Used to parse multiple -p flags // Ports type - Used to parse multiple -p flags
type ports []int 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 // AttachOpts stores arguments to 'docker run -a', eg. which streams to attach to
type AttachOpts map[string]bool type AttachOpts map[string]bool

View file

@ -175,30 +175,30 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
flCpuShares := cmd.Int64("c", 0, "CPU shares (relative weight)") 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)") 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") 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") cmd.Var(&flEnv, "e", "Set environment variables")
var flDns ListOpts var flDns utils.ListOpts
cmd.Var(&flDns, "dns", "Set custom dns servers") cmd.Var(&flDns, "dns", "Set custom dns servers")
flVolumes := NewPathOpts() flVolumes := NewPathOpts()
cmd.Var(flVolumes, "v", "Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)") 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") cmd.Var(&flVolumesFrom, "volumes-from", "Mount volumes from the specified container")
flEntrypoint := cmd.String("entrypoint", "", "Overwrite the default entrypoint of the image") 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\"") 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)") cmd.Var(&flLinks, "link", "Add link to another container (containerid:alias)")
if err := cmd.Parse(args); err != nil { if err := cmd.Parse(args); err != nil {

View file

@ -36,7 +36,7 @@ func main() {
flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.") 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.") flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
flDns := flag.String("dns", "", "Set custom dns servers") 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") 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") 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") flDefaultIp := flag.String("ip", "0.0.0.0", "Default ip address to use when binding a containers ports")

View file

@ -69,7 +69,7 @@ func changeUser(u string) {
} }
// Clear environment pollution introduced by lxc-start // Clear environment pollution introduced by lxc-start
func cleanupEnv(env ListOpts) { func cleanupEnv(env utils.ListOpts) {
os.Clearenv() os.Clearenv()
for _, kv := range env { for _, kv := range env {
parts := strings.SplitN(kv, "=", 2) parts := strings.SplitN(kv, "=", 2)
@ -104,7 +104,7 @@ func SysInit() {
var gw = flag.String("g", "", "gateway address") var gw = flag.String("g", "", "gateway address")
var workdir = flag.String("w", "", "workdir") var workdir = flag.String("w", "", "workdir")
var flEnv ListOpts var flEnv utils.ListOpts
flag.Var(&flEnv, "e", "Set environment variables") flag.Var(&flEnv, "e", "Set environment variables")
flag.Parse() flag.Parse()

View file

@ -175,7 +175,7 @@ func MergeConfig(userConf, imageConf *Config) error {
return nil return nil
} }
func parseLxcConfOpts(opts ListOpts) ([]KeyValuePair, error) { func parseLxcConfOpts(opts utils.ListOpts) ([]KeyValuePair, error) {
out := make([]KeyValuePair, len(opts)) out := make([]KeyValuePair, len(opts))
for i, o := range opts { for i, o := range opts {
k, v, err := parseLxcOpt(o) k, v, err := parseLxcOpt(o)

View file

@ -21,6 +21,18 @@ import (
"time" "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, // 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. // and returns a channel which will later return the function's return value.
func Go(f func() error) chan error { func Go(f func() error) chan error {