mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Change flag to -o and --opt
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
7c726669cb
commit
c9d7f858fd
5 changed files with 38 additions and 10 deletions
|
@ -13,7 +13,7 @@ type HostConfig struct {
|
|||
PortBindings nat.PortMap
|
||||
Links []string
|
||||
PublishAllPorts bool
|
||||
PluginOptions map[string][]string
|
||||
DriverOptions map[string][]string
|
||||
}
|
||||
|
||||
type KeyValuePair struct {
|
||||
|
@ -29,7 +29,7 @@ func ContainerHostConfigFromJob(job *engine.Job) *HostConfig {
|
|||
}
|
||||
job.GetenvJson("LxcConf", &hostConfig.LxcConf)
|
||||
job.GetenvJson("PortBindings", &hostConfig.PortBindings)
|
||||
job.GetenvJson("PluginOptions", &hostConfig.PluginOptions)
|
||||
job.GetenvJson("DriverOptions", &hostConfig.DriverOptions)
|
||||
if Binds := job.GetenvList("Binds"); Binds != nil {
|
||||
hostConfig.Binds = Binds
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|||
flDnsSearch = opts.NewListOpts(opts.ValidateDomain)
|
||||
flVolumesFrom opts.ListOpts
|
||||
flLxcOpts opts.ListOpts
|
||||
flPluginOpts opts.ListOpts
|
||||
flDriverOpts opts.ListOpts
|
||||
|
||||
flAutoRemove = cmd.Bool([]string{"#rm", "-rm"}, false, "Automatically remove the container when it exits (incompatible with -d)")
|
||||
flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Detached mode: Run container in the background, print new container id")
|
||||
|
@ -77,8 +77,8 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|||
cmd.Var(&flDns, []string{"#dns", "-dns"}, "Set custom dns servers")
|
||||
cmd.Var(&flDnsSearch, []string{"-dns-search"}, "Set custom dns search domains")
|
||||
cmd.Var(&flVolumesFrom, []string{"#volumes-from", "-volumes-from"}, "Mount volumes from the specified container(s)")
|
||||
cmd.Var(&flLxcOpts, []string{"#lxc-conf", "-lxc-conf"}, "Add custom lxc options --lxc-conf=\"lxc.cgroup.cpuset.cpus = 0,1\"")
|
||||
cmd.Var(&flPluginOpts, []string{"-plugin"}, "Add custom plugin options")
|
||||
cmd.Var(&flLxcOpts, []string{"#lxc-conf", "#-lxc-conf"}, "Add custom lxc options --lxc-conf=\"lxc.cgroup.cpuset.cpus = 0,1\"")
|
||||
cmd.Var(&flDriverOpts, []string{"o", "-opt"}, "Add custom driver options")
|
||||
|
||||
if err := cmd.Parse(args); err != nil {
|
||||
return nil, nil, cmd, err
|
||||
|
@ -208,7 +208,10 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|||
WorkingDir: *flWorkingDir,
|
||||
}
|
||||
|
||||
pluginOptions := parsePluginOpts(flPluginOpts)
|
||||
pluginOptions, err := parseDriverOpts(flDriverOpts)
|
||||
if err != nil {
|
||||
return nil, nil, cmd, err
|
||||
}
|
||||
|
||||
hostConfig := &HostConfig{
|
||||
Binds: binds,
|
||||
|
@ -218,7 +221,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|||
PortBindings: portBindings,
|
||||
Links: flLinks.GetAll(),
|
||||
PublishAllPorts: *flPublishAll,
|
||||
PluginOptions: pluginOptions,
|
||||
DriverOptions: pluginOptions,
|
||||
}
|
||||
|
||||
if sysInfo != nil && flMemory > 0 && !sysInfo.SwapLimit {
|
||||
|
@ -253,15 +256,18 @@ func parseLxcOpt(opt string) (string, string, error) {
|
|||
return strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1]), nil
|
||||
}
|
||||
|
||||
func parsePluginOpts(opts opts.ListOpts) map[string][]string {
|
||||
func parseDriverOpts(opts opts.ListOpts) (map[string][]string, error) {
|
||||
out := make(map[string][]string, len(opts.GetAll()))
|
||||
for _, o := range opts.GetAll() {
|
||||
parts := strings.SplitN(o, " ", 2)
|
||||
if len(parts) < 2 {
|
||||
return nil, fmt.Errorf("invalid opt format %s", o)
|
||||
}
|
||||
values, exists := out[parts[0]]
|
||||
if !exists {
|
||||
values = []string{}
|
||||
}
|
||||
out[parts[0]] = append(values, parts[1])
|
||||
}
|
||||
return out
|
||||
return out, nil
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
|
|||
func populateCommand(c *Container) {
|
||||
var (
|
||||
en *execdriver.Network
|
||||
driverConfig = c.hostConfig.PluginOptions
|
||||
driverConfig = c.hostConfig.DriverOptions
|
||||
)
|
||||
|
||||
if driverConfig == nil {
|
||||
|
|
19
runtime/execdriver/native/configuration/fs.go
Normal file
19
runtime/execdriver/native/configuration/fs.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package configuration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func parseFsOpts(container *libcontainer.Container, opts []string) error {
|
||||
opt := strings.TrimSpace(opts[0])
|
||||
|
||||
switch opt {
|
||||
case "readonly":
|
||||
container.ReadonlyFs = true
|
||||
default:
|
||||
return fmt.Errorf("%s is not a valid filesystem option", opt)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -18,6 +18,9 @@ func ParseConfiguration(container *libcontainer.Container, running map[string]*e
|
|||
err error
|
||||
parts = strings.Split(strings.TrimSpace(opt), " ")
|
||||
)
|
||||
if len(parts) < 2 {
|
||||
return fmt.Errorf("invalid native driver opt %s", opt)
|
||||
}
|
||||
|
||||
switch parts[0] {
|
||||
case "cap":
|
||||
|
|
Loading…
Add table
Reference in a new issue