Skip to content

Commit

Permalink
Move ulimit options to runconfig opts
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <[email protected]>
  • Loading branch information
dnephin committed Dec 23, 2015
1 parent 3b8301b commit 5adbea7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions api/client/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/ulimit"
"github.com/docker/docker/pkg/urlutil"
"github.com/docker/docker/reference"
runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/docker/utils"
"github.com/docker/go-units"
)
Expand Down Expand Up @@ -62,8 +62,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
cmd.Var(&flBuildArg, []string{"-build-arg"}, "Set build-time variables")
isolation := cmd.String([]string{"-isolation"}, "", "Container isolation level")

ulimits := make(map[string]*ulimit.Ulimit)
flUlimits := opts.NewUlimitOpt(&ulimits)
ulimits := make(map[string]*units.Ulimit)
flUlimits := runconfigopts.NewUlimitOpt(&ulimits)
cmd.Var(flUlimits, []string{"-ulimit"}, "Ulimit options")

cmd.Require(flag.Exact, 1)
Expand Down
9 changes: 5 additions & 4 deletions daemon/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (

"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/ulimit"
runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/go-units"
)

var (
Expand All @@ -27,7 +28,7 @@ type Config struct {
EnableSelinuxSupport bool
RemappedRoot string
SocketGroup string
Ulimits map[string]*ulimit.Ulimit
Ulimits map[string]*units.Ulimit
}

// bridgeConfig stores all the bridge driver specific
Expand Down Expand Up @@ -59,8 +60,8 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin
// Then platform-specific install flags
cmd.BoolVar(&config.EnableSelinuxSupport, []string{"-selinux-enabled"}, false, usageFn("Enable selinux support"))
cmd.StringVar(&config.SocketGroup, []string{"G", "-group"}, "docker", usageFn("Group for the unix socket"))
config.Ulimits = make(map[string]*ulimit.Ulimit)
cmd.Var(opts.NewUlimitOpt(&config.Ulimits), []string{"-default-ulimit"}, usageFn("Set default ulimits for containers"))
config.Ulimits = make(map[string]*units.Ulimit)
cmd.Var(runconfigopts.NewUlimitOpt(&config.Ulimits), []string{"-default-ulimit"}, usageFn("Set default ulimits for containers"))
cmd.BoolVar(&config.Bridge.EnableIPTables, []string{"#iptables", "-iptables"}, true, usageFn("Enable addition of iptables rules"))
cmd.BoolVar(&config.Bridge.EnableIPForward, []string{"#ip-forward", "-ip-forward"}, true, usageFn("Enable net.ipv4.ip_forward"))
cmd.BoolVar(&config.Bridge.EnableIPMasq, []string{"-ip-masq"}, true, usageFn("Enable IP masquerading"))
Expand Down
14 changes: 7 additions & 7 deletions opts/ulimit.go → runconfig/opts/ulimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ package opts
import (
"fmt"

"github.com/docker/docker/pkg/ulimit"
"github.com/docker/go-units"
)

// UlimitOpt defines a map of Ulimits
type UlimitOpt struct {
values *map[string]*ulimit.Ulimit
values *map[string]*units.Ulimit
}

// NewUlimitOpt creates a new UlimitOpt
func NewUlimitOpt(ref *map[string]*ulimit.Ulimit) *UlimitOpt {
func NewUlimitOpt(ref *map[string]*units.Ulimit) *UlimitOpt {
if ref == nil {
ref = &map[string]*ulimit.Ulimit{}
ref = &map[string]*units.Ulimit{}
}
return &UlimitOpt{ref}
}

// Set validates a Ulimit and sets its name as a key in UlimitOpt
func (o *UlimitOpt) Set(val string) error {
l, err := ulimit.Parse(val)
l, err := units.ParseUlimit(val)
if err != nil {
return err
}
Expand All @@ -42,8 +42,8 @@ func (o *UlimitOpt) String() string {
}

// GetList returns a slice of pointers to Ulimits.
func (o *UlimitOpt) GetList() []*ulimit.Ulimit {
var ulimits []*ulimit.Ulimit
func (o *UlimitOpt) GetList() []*units.Ulimit {
var ulimits []*units.Ulimit
for _, v := range *o.values {
ulimits = append(ulimits, v)
}
Expand Down
4 changes: 2 additions & 2 deletions opts/ulimit_test.go → runconfig/opts/ulimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package opts
import (
"testing"

"github.com/docker/docker/pkg/ulimit"
"github.com/docker/go-units"
)

func TestUlimitOpt(t *testing.T) {
ulimitMap := map[string]*ulimit.Ulimit{
ulimitMap := map[string]*units.Ulimit{
"nofile": {"nofile", 1024, 512},
}

Expand Down
3 changes: 2 additions & 1 deletion runconfig/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/signal"
runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/docker/volume"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
Expand Down Expand Up @@ -63,7 +64,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
flLabels = opts.NewListOpts(opts.ValidateEnv)
flDevices = opts.NewListOpts(ValidateDevice)

flUlimits = opts.NewUlimitOpt(nil)
flUlimits = runconfigopts.NewUlimitOpt(nil)

flPublish = opts.NewListOpts(nil)
flExpose = opts.NewListOpts(nil)
Expand Down

0 comments on commit 5adbea7

Please sign in to comment.