summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/cliconfig/config.go2
-rw-r--r--cmd/podman/errors.go13
-rw-r--r--cmd/podman/errors_remote.go20
-rw-r--r--cmd/podman/generate_systemd.go2
-rw-r--r--cmd/podman/libpodruntime/runtime.go4
-rw-r--r--cmd/podman/main.go2
-rw-r--r--cmd/podman/main_local.go1
-rw-r--r--cmd/podman/restore.go1
-rw-r--r--cmd/podman/rm.go13
-rw-r--r--cmd/podman/rmi.go1
-rw-r--r--cmd/podman/shared/create.go18
-rw-r--r--cmd/podman/shared/parse/parse.go5
-rw-r--r--cmd/podman/system_df.go8
-rw-r--r--cmd/podman/varlink/io.podman.varlink3
14 files changed, 70 insertions, 23 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index 025f40cf6..d5098ee51 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -16,6 +16,7 @@ type MainFlags struct {
CniConfigDir string
ConmonPath string
DefaultMountsFile string
+ EventsBackend string
HooksDir []string
MaxWorks int
Namespace string
@@ -436,6 +437,7 @@ type RestoreValues struct {
Import string
Name string
IgnoreRootfs bool
+ IgnoreStaticIP bool
}
type RmValues struct {
diff --git a/cmd/podman/errors.go b/cmd/podman/errors.go
index 9731037f4..ae9e73e62 100644
--- a/cmd/podman/errors.go
+++ b/cmd/podman/errors.go
@@ -8,6 +8,8 @@ import (
"os/exec"
"syscall"
+ "github.com/containers/libpod/libpod/define"
+ "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -24,3 +26,14 @@ func outputError(err error) {
fmt.Fprintln(os.Stderr, "Error:", err.Error())
}
}
+
+func setExitCode(err error) int {
+ cause := errors.Cause(err)
+ switch cause {
+ case define.ErrNoSuchCtr:
+ return 1
+ case define.ErrCtrStateInvalid:
+ return 2
+ }
+ return exitCode
+}
diff --git a/cmd/podman/errors_remote.go b/cmd/podman/errors_remote.go
index 1e276be10..19df2d2d8 100644
--- a/cmd/podman/errors_remote.go
+++ b/cmd/podman/errors_remote.go
@@ -9,6 +9,7 @@ import (
"syscall"
"github.com/containers/libpod/cmd/podman/varlink"
+ "github.com/containers/libpod/libpod/define"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -43,3 +44,22 @@ func outputError(err error) {
fmt.Fprintln(os.Stderr, "Error:", ne.Error())
}
}
+
+func setExitCode(err error) int {
+ cause := errors.Cause(err)
+ switch e := cause.(type) {
+ // For some reason golang wont let me list them with commas so listing them all.
+ case *iopodman.ContainerNotFound:
+ return 1
+ case *iopodman.InvalidState:
+ return 2
+ default:
+ switch e {
+ case define.ErrNoSuchCtr:
+ return 1
+ case define.ErrCtrStateInvalid:
+ return 2
+ }
+ }
+ return exitCode
+}
diff --git a/cmd/podman/generate_systemd.go b/cmd/podman/generate_systemd.go
index 8be097c83..222fc4c98 100644
--- a/cmd/podman/generate_systemd.go
+++ b/cmd/podman/generate_systemd.go
@@ -30,7 +30,7 @@ var (
}
return nil
},
- Example: `podman generate kube ctrID
+ Example: `podman generate systemd ctrID
`,
}
)
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go
index 570288837..ee9e57966 100644
--- a/cmd/podman/libpodruntime/runtime.go
+++ b/cmd/podman/libpodruntime/runtime.go
@@ -118,6 +118,10 @@ func getRuntime(ctx context.Context, c *cliconfig.PodmanCommand, renumber, migra
options = append(options, libpod.WithNetworkCmdPath(c.GlobalFlags.NetworkCmdPath))
}
+ if c.Flags().Changed("events-backend") {
+ options = append(options, libpod.WithEventsLogger(c.GlobalFlags.EventsBackend))
+ }
+
if c.Flags().Changed("cgroup-manager") {
options = append(options, libpod.WithCgroupManager(c.GlobalFlags.CGroupManager))
} else {
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index f24c8c19c..dc44a9110 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -91,7 +91,7 @@ func init() {
rootCmd.Version = version.Version
// Override default --help information of `--version` global flag
var dummyVersion bool
- rootCmd.PersistentFlags().BoolVar(&dummyVersion, "version", false, "Version for podman")
+ rootCmd.Flags().BoolVarP(&dummyVersion, "version", "v", false, "Version of podman")
rootCmd.AddCommand(mainCommands...)
rootCmd.AddCommand(getMainCommands()...)
}
diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go
index 1e8cc1143..0f43e0b88 100644
--- a/cmd/podman/main_local.go
+++ b/cmd/podman/main_local.go
@@ -48,6 +48,7 @@ func init() {
if err := rootCmd.PersistentFlags().MarkHidden("default-mounts-file"); err != nil {
logrus.Error("unable to mark default-mounts-file flag as hidden")
}
+ rootCmd.PersistentFlags().StringVar(&MainGlobalOpts.EventsBackend, "events-backend", "", "Events backend to use")
// Override default --help information of `--help` global flag
var dummyHelp bool
rootCmd.PersistentFlags().BoolVar(&dummyHelp, "help", false, "Help for podman")
diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go
index 3ae141d41..90d0b2dc4 100644
--- a/cmd/podman/restore.go
+++ b/cmd/podman/restore.go
@@ -46,6 +46,7 @@ func init() {
flags.StringVarP(&restoreCommand.Import, "import", "i", "", "Restore from exported checkpoint archive (tar.gz)")
flags.StringVarP(&restoreCommand.Name, "name", "n", "", "Specify new name for container restored from exported checkpoint (only works with --import)")
flags.BoolVar(&restoreCommand.IgnoreRootfs, "ignore-rootfs", false, "Do not apply root file-system changes when importing from exported checkpoint")
+ flags.BoolVar(&restoreCommand.IgnoreStaticIP, "ignore-static-ip", false, "Ignore IP address set via --static-ip")
markFlagHiddenForRemoteClient("latest", flags)
}
diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go
index 958ca1c60..9e3ce4d0b 100644
--- a/cmd/podman/rm.go
+++ b/cmd/podman/rm.go
@@ -4,7 +4,6 @@ import (
"fmt"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/adapter"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -65,18 +64,16 @@ func rmCmd(c *cliconfig.RmValues) error {
ok, failures, err := runtime.RemoveContainers(getContext(), c)
if err != nil {
- if errors.Cause(err) == define.ErrNoSuchCtr {
- if len(c.InputArgs) > 1 {
- exitCode = 125
- } else {
- exitCode = 1
- }
+ if len(c.InputArgs) < 2 {
+ exitCode = setExitCode(err)
}
return err
}
if len(failures) > 0 {
- exitCode = 125
+ for _, err := range failures {
+ exitCode = setExitCode(err)
+ }
}
return printCmdResults(ok, failures)
diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go
index 57e78c34a..3f621116e 100644
--- a/cmd/podman/rmi.go
+++ b/cmd/podman/rmi.go
@@ -74,6 +74,7 @@ func rmiCmd(c *cliconfig.RmiValues) error {
fmt.Printf("A container associated with containers/storage, i.e. via Buildah, CRI-O, etc., may be associated with this image: %-12.12s\n", img.ID())
}
if !adapter.IsImageNotFound(err) {
+ exitCode = 2
failureCnt++
}
if lastError != nil {
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index 9578eb17d..4de68e4bc 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
- "github.com/containers/libpod/pkg/errorhandling"
"io"
"os"
"path/filepath"
@@ -18,6 +17,7 @@ import (
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/image"
ann "github.com/containers/libpod/pkg/annotations"
+ "github.com/containers/libpod/pkg/errorhandling"
"github.com/containers/libpod/pkg/inspect"
ns "github.com/containers/libpod/pkg/namespaces"
"github.com/containers/libpod/pkg/rootless"
@@ -77,7 +77,13 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
writer = os.Stderr
}
- newImage, err := runtime.ImageRuntime().New(ctx, c.InputArgs[0], rtc.SignaturePolicyPath, GetAuthFile(""), writer, nil, image.SigningOptions{}, false, nil)
+ name := ""
+ if len(c.InputArgs) != 0 {
+ name = c.InputArgs[0]
+ } else {
+ return nil, nil, errors.Errorf("error, no input arguments were provided")
+ }
+ newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, GetAuthFile(""), writer, nil, image.SigningOptions{}, false, nil)
if err != nil {
return nil, nil, err
}
@@ -681,7 +687,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
DNSServers: c.StringSlice("dns"),
Entrypoint: entrypoint,
Env: env,
- //ExposedPorts: ports,
+ // ExposedPorts: ports,
GroupAdd: c.StringSlice("group-add"),
Hostname: c.String("hostname"),
HostAdd: c.StringSlice("add-host"),
@@ -693,16 +699,16 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
Image: imageName,
ImageID: imageID,
Interactive: c.Bool("interactive"),
- //IP6Address: c.String("ipv6"), // Not implemented yet - needs CNI support for static v6
+ // 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
+ // LinkLocalIP: c.StringSlice("link-local-ip"), // Not implemented yet
LogDriver: logDriver,
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?
+ // NetworkAlias: c.StringSlice("network-alias"), // Not implemented - does this make sense in Podman?
IpcMode: ipcMode,
NetMode: netMode,
UtsMode: utsMode,
diff --git a/cmd/podman/shared/parse/parse.go b/cmd/podman/shared/parse/parse.go
index 9fbc92fc3..3a75ff7a8 100644
--- a/cmd/podman/shared/parse/parse.go
+++ b/cmd/podman/shared/parse/parse.go
@@ -126,8 +126,9 @@ func parseEnv(env map[string]string, line string) error {
}
} else {
// if only a pass-through variable is given, clean it up.
- val, _ := os.LookupEnv(name)
- env[name] = val
+ if val, ok := os.LookupEnv(name); ok {
+ env[name] = val
+ }
}
}
return nil
diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go
index 6b9824a79..44582a802 100644
--- a/cmd/podman/system_df.go
+++ b/cmd/podman/system_df.go
@@ -460,11 +460,11 @@ func getImageVerboseDiskUsage(ctx context.Context, images []*image.Image, images
}
var repo string
var tag string
- if len(img.Names()) == 0 {
- repo = "<none>"
- tag = "<none>"
+ var repotags []string
+ if len(img.Names()) != 0 {
+ repotags = []string{img.Names()[0]}
}
- repopairs, err := image.ReposToMap([]string{img.Names()[0]})
+ repopairs, err := image.ReposToMap(repotags)
if err != nil {
logrus.Errorf("error finding tag/digest for %s", img.ID())
}
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index f5f3250f7..b867dccc1 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -228,7 +228,8 @@ type InfoHost (
hostname: string,
kernel: string,
os: string,
- uptime: string
+ uptime: string,
+ eventlogger: string
)
# InfoGraphStatus describes the detailed status of the storage driver