diff options
author | TomSweeneyRedHat <tsweeney@redhat.com> | 2018-03-06 11:05:17 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-06 23:55:46 +0000 |
commit | 042139673e68c4d99bc9cbdc33648d27940cd6a1 (patch) | |
tree | 3026aac8a63a145f498675ae8f8079af1a5d0b8a /cmd | |
parent | e8fbe93e29028aa6c140c5c42bfe58917860ed81 (diff) | |
download | podman-042139673e68c4d99bc9cbdc33648d27940cd6a1.tar.gz podman-042139673e68c4d99bc9cbdc33648d27940cd6a1.tar.bz2 podman-042139673e68c4d99bc9cbdc33648d27940cd6a1.zip |
Add buildah bud options from common.go
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Closes: #453
Approved by: rhatdan
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/build.go | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go index c7f95f5e5..92823f72b 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "os/exec" "strconv" @@ -11,6 +12,8 @@ import ( var ( buildFlags = []cli.Flag{ + // The following flags are emulated from: + // src/github.com/projectatomic/buildah/cmd/bud.go cli.StringFlag{ Name: "authfile", Usage: "path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json", @@ -65,6 +68,61 @@ var ( Name: "tls-verify", Usage: "require HTTPS and verify certificates when accessing the registry", }, + // The following flags are emulated from: + // src/github.com/projectatomic/buildah/cmd/common.go fromAndBudFlags + cli.StringSliceFlag{ + Name: "add-host", + Usage: "add a custom host-to-IP mapping (host:ip) (default [])", + }, + cli.StringFlag{ + Name: "cgroup-parent", + Usage: "optional parent cgroup for the container", + }, + cli.Uint64Flag{ + Name: "cpu-period", + Usage: "limit the CPU CFS (Completely Fair Scheduler) period", + }, + cli.Int64Flag{ + Name: "cpu-quota", + Usage: "limit the CPU CFS (Completely Fair Scheduler) quota", + }, + cli.Uint64Flag{ + Name: "cpu-shares", + Usage: "CPU shares (relative weight)", + }, + cli.StringFlag{ + Name: "cpuset-cpus", + Usage: "CPUs in which to allow execution (0-3, 0,1)", + }, + cli.StringFlag{ + Name: "cpuset-mems", + Usage: "memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.", + }, + cli.StringFlag{ + Name: "memory, m", + Usage: "memory limit (format: <number>[<unit>], where unit = b, k, m or g)", + }, + cli.StringFlag{ + Name: "memory-swap", + Usage: "swap limit equal to memory plus swap: '-1' to enable unlimited swap", + }, + cli.StringSliceFlag{ + Name: "security-opt", + Usage: "security Options (default [])", + }, + cli.StringFlag{ + Name: "shm-size", + Usage: "size of `/dev/shm`. The format is `<number><unit>`.", + Value: "65536k", + }, + cli.StringSliceFlag{ + Name: "ulimit", + Usage: "ulimit options (default [])", + }, + cli.StringSliceFlag{ + Name: "volume, v", + Usage: "bind mount a volume into the container (default [])", + }, } buildDescription = "podman build launches the Buildah command to build an OCI Image. Buildah must be installed for this command to work." buildCommand = cli.Command{ @@ -81,6 +139,7 @@ func buildCmd(c *cli.Context) error { budCmdArgs := []string{} + // Handle Global Options logLevel := c.GlobalString("log-level") if logLevel == "debug" { budCmdArgs = append(budCmdArgs, "--debug") @@ -100,6 +159,7 @@ func buildCmd(c *cli.Context) error { budCmdArgs = append(budCmdArgs, "bud") + // Buildah bud specific options if c.IsSet("authfile") { budCmdArgs = append(budCmdArgs, "--authfile", c.String("authfile")) } @@ -142,6 +202,47 @@ func buildCmd(c *cli.Context) error { budCmdArgs = append(budCmdArgs, tlsParam) } + // Buildah bud and from options from cmd/buildah/common.go + for _, addHostArg := range c.StringSlice("add-host") { + budCmdArgs = append(budCmdArgs, "--add-host", addHostArg) + } + if c.IsSet("cgroup-parent") { + budCmdArgs = append(budCmdArgs, "--cgroup-parent", c.String("cgroup-parent")) + } + if c.IsSet("cpu-period") { + budCmdArgs = append(budCmdArgs, "--cpu-period", fmt.Sprintf("%v", c.Int64("cpu-period"))) + } + if c.IsSet("cpu-quota") { + budCmdArgs = append(budCmdArgs, "--cpu-quota", fmt.Sprintf("%v", c.Uint64("cpu-quota"))) + } + if c.IsSet("cpu-shares") { + budCmdArgs = append(budCmdArgs, "--cpu-shares", fmt.Sprintf("%v", c.Uint64("cpu-shares"))) + } + if c.IsSet("cpuset-cpus") { + budCmdArgs = append(budCmdArgs, "--cpuset-cpus", c.String("cpuset-cpus")) + } + if c.IsSet("cpuset-mems") { + budCmdArgs = append(budCmdArgs, "--cpuset-mems", c.String("cpuset-mems")) + } + if c.IsSet("memory") { + budCmdArgs = append(budCmdArgs, "--memory", c.String("memory")) + } + if c.IsSet("memory-swap") { + budCmdArgs = append(budCmdArgs, "--memory-swap", c.String("memory-swap")) + } + for _, securityOptArg := range c.StringSlice("security-opt") { + budCmdArgs = append(budCmdArgs, "--security-opt", securityOptArg) + } + if c.IsSet("shm-size") { + budCmdArgs = append(budCmdArgs, "--shm-size", c.String("shm-size")) + } + for _, ulimitArg := range c.StringSlice("ulimit") { + budCmdArgs = append(budCmdArgs, "--ulimit", ulimitArg) + } + for _, volumeArg := range c.StringSlice("volume") { + budCmdArgs = append(budCmdArgs, "--volume", volumeArg) + } + if len(c.Args()) > 0 { budCmdArgs = append(budCmdArgs, c.Args()...) } |