summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/cliconfig/commands.go56
-rw-r--r--cmd/podman/common.go2
-rw-r--r--cmd/podman/create.go36
-rw-r--r--cmd/podman/restart.go2
-rw-r--r--cmd/podman/stop.go14
5 files changed, 78 insertions, 32 deletions
diff --git a/cmd/podman/cliconfig/commands.go b/cmd/podman/cliconfig/commands.go
index 7d1e762d9..3361c14b8 100644
--- a/cmd/podman/cliconfig/commands.go
+++ b/cmd/podman/cliconfig/commands.go
@@ -1,5 +1,7 @@
package cliconfig
+import "github.com/sirupsen/logrus"
+
// GlobalIsSet is a compatibility method for urfave
func (p *PodmanCommand) GlobalIsSet(opt string) bool {
flag := p.PersistentFlags().Lookup(opt)
@@ -22,9 +24,13 @@ func (p *PodmanCommand) IsSet(opt string) bool {
func (p *PodmanCommand) Bool(opt string) bool {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return false
}
- val, _ := p.Flags().GetBool(opt)
+ val, err := p.Flags().GetBool(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -32,9 +38,13 @@ func (p *PodmanCommand) Bool(opt string) bool {
func (p *PodmanCommand) String(opt string) string {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return ""
}
- val, _ := p.Flags().GetString(opt)
+ val, err := p.Flags().GetString(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -42,9 +52,13 @@ func (p *PodmanCommand) String(opt string) string {
func (p *PodmanCommand) StringArray(opt string) []string {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return []string{}
}
- val, _ := p.Flags().GetStringArray(opt)
+ val, err := p.Flags().GetStringArray(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -52,9 +66,13 @@ func (p *PodmanCommand) StringArray(opt string) []string {
func (p *PodmanCommand) StringSlice(opt string) []string {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return []string{}
}
- val, _ := p.Flags().GetStringSlice(opt)
+ val, err := p.Flags().GetStringSlice(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -62,9 +80,13 @@ func (p *PodmanCommand) StringSlice(opt string) []string {
func (p *PodmanCommand) Int(opt string) int {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return 0
}
- val, _ := p.Flags().GetInt(opt)
+ val, err := p.Flags().GetInt(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -72,9 +94,13 @@ func (p *PodmanCommand) Int(opt string) int {
func (p *PodmanCommand) Uint(opt string) uint {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return 0
}
- val, _ := p.Flags().GetUint(opt)
+ val, err := p.Flags().GetUint(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -82,9 +108,13 @@ func (p *PodmanCommand) Uint(opt string) uint {
func (p *PodmanCommand) Int64(opt string) int64 {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return 0
}
- val, _ := p.Flags().GetInt64(opt)
+ val, err := p.Flags().GetInt64(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -92,9 +122,13 @@ func (p *PodmanCommand) Int64(opt string) int64 {
func (p *PodmanCommand) Uint64(opt string) uint64 {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return 0
}
- val, _ := p.Flags().GetUint64(opt)
+ val, err := p.Flags().GetUint64(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
@@ -102,8 +136,12 @@ func (p *PodmanCommand) Uint64(opt string) uint64 {
func (p *PodmanCommand) Float64(opt string) float64 {
flag := p.Flags().Lookup(opt)
if flag == nil {
+ logrus.Errorf("Could not find flag %s", opt)
return 0
}
- val, _ := p.Flags().GetFloat64(opt)
+ val, err := p.Flags().GetFloat64(opt)
+ if err != nil {
+ logrus.Errorf("Error getting flag %s: %v", opt, err)
+ }
return val
}
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index e297f3921..f9dfa3759 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -415,7 +415,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"stop-signal", "",
"Signal to stop a container. Default is SIGTERM",
)
- createFlags.Int(
+ createFlags.Uint(
"stop-timeout", libpod.CtrRemoveTimeout,
"Timeout (in seconds) to stop a container. Default is 10",
)
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 696d10d8e..95cb732d9 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -408,7 +408,7 @@ func parseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l
return nil, err
}
- if err = parseVolumesFrom(c.StringArray("volumes-from")); err != nil {
+ if err = parseVolumesFrom(c.StringSlice("volumes-from")); err != nil {
return nil, err
}
@@ -707,23 +707,23 @@ func parseCreateOpts(ctx context.Context, c *cliconfig.PodmanCommand, runtime *l
Entrypoint: entrypoint,
Env: env,
//ExposedPorts: ports,
- GroupAdd: c.StringSlice("group-add"),
- Hostname: c.String("hostname"),
- HostAdd: c.StringSlice("add-host"),
- IDMappings: idmappings,
- Image: imageName,
- ImageID: imageID,
- Interactive: c.Bool("interactive"),
- IP6Address: c.String("ipv6"),
- IPAddress: c.String("ip"),
- Labels: labels,
- LinkLocalIP: c.StringSlice("link-local-ip"),
- LogDriver: c.String("log-driver"),
- LogDriverOpt: c.StringSlice("log-opt"),
- MacAddress: c.String("mac-address"),
- Name: c.String("name"),
- Network: network,
- NetworkAlias: c.StringSlice("network-alias"),
+ GroupAdd: c.StringSlice("group-add"),
+ Hostname: c.String("hostname"),
+ HostAdd: c.StringSlice("add-host"),
+ IDMappings: idmappings,
+ Image: imageName,
+ ImageID: imageID,
+ Interactive: c.Bool("interactive"),
+ //IP6Address: c.String("ipv6"), // Not implemented yet - needs CNI support for static v6
+ IPAddress: c.String("ip"),
+ Labels: labels,
+ //LinkLocalIP: c.StringSlice("link-local-ip"), // Not implemented yet
+ LogDriver: c.String("log-driver"),
+ LogDriverOpt: c.StringSlice("log-opt"),
+ MacAddress: c.String("mac-address"),
+ Name: c.String("name"),
+ Network: network,
+ //NetworkAlias: c.StringSlice("network-alias"), // Not implemented - does this make sense in Podman?
IpcMode: ipcMode,
NetMode: netMode,
UtsMode: utsMode,
diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go
index 2bebde4f9..5aa12070e 100644
--- a/cmd/podman/restart.go
+++ b/cmd/podman/restart.go
@@ -73,7 +73,7 @@ func restartCmd(c *cliconfig.RestartValues) error {
defer runtime.Shutdown(false)
timeout := c.Timeout
- useTimeout := c.Flag("timeout").Changed
+ useTimeout := c.Flag("timeout").Changed || c.Flag("time").Changed
// Handle --latest
if c.Latest {
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go
index d86894a6f..ab9a2cf38 100644
--- a/cmd/podman/stop.go
+++ b/cmd/podman/stop.go
@@ -73,21 +73,29 @@ func stopCmd(c *cliconfig.StopValues) error {
fmt.Println(err.Error())
}
+ if c.Flag("timeout").Changed && c.Flag("time").Changed {
+ return errors.New("the --timeout and --time flags are mutually exclusive")
+ }
+
var stopFuncs []shared.ParallelWorkerInput
for _, ctr := range containers {
con := ctr
var stopTimeout uint
- if c.Flag("timeout").Changed {
+ if c.Flag("timeout").Changed || c.Flag("time").Changed {
stopTimeout = c.Timeout
} else {
stopTimeout = ctr.StopTimeout()
+ logrus.Debugf("Set timeout to container %s default (%d)", ctr.ID(), stopTimeout)
}
f := func() error {
- if err := con.StopWithTimeout(stopTimeout); err != nil && errors.Cause(err) != libpod.ErrCtrStopped {
+ if err := con.StopWithTimeout(stopTimeout); err != nil {
+ if errors.Cause(err) == libpod.ErrCtrStopped {
+ logrus.Debugf("Container %s already stopped", con.ID())
+ return nil
+ }
return err
}
return nil
-
}
stopFuncs = append(stopFuncs, shared.ParallelWorkerInput{
ContainerID: con.ID(),