diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/build.go | 2 | ||||
-rw-r--r-- | cmd/podman/checkpoint.go | 6 | ||||
-rw-r--r-- | cmd/podman/cliconfig/commands.go | 56 | ||||
-rw-r--r-- | cmd/podman/commands.go | 8 | ||||
-rw-r--r-- | cmd/podman/common.go | 3 | ||||
-rw-r--r-- | cmd/podman/container.go | 2 | ||||
-rw-r--r-- | cmd/podman/create.go | 38 | ||||
-rw-r--r-- | cmd/podman/exec.go | 10 | ||||
-rw-r--r-- | cmd/podman/exists.go | 9 | ||||
-rw-r--r-- | cmd/podman/generate_kube.go | 2 | ||||
-rw-r--r-- | cmd/podman/image.go | 9 | ||||
-rw-r--r-- | cmd/podman/images.go | 2 | ||||
-rw-r--r-- | cmd/podman/main.go | 2 | ||||
-rw-r--r-- | cmd/podman/play_kube.go | 11 | ||||
-rw-r--r-- | cmd/podman/port.go | 6 | ||||
-rw-r--r-- | cmd/podman/ps.go | 4 | ||||
-rw-r--r-- | cmd/podman/refresh.go | 1 | ||||
-rw-r--r-- | cmd/podman/restart.go | 2 | ||||
-rw-r--r-- | cmd/podman/rmi.go | 4 | ||||
-rw-r--r-- | cmd/podman/stop.go | 14 | ||||
-rw-r--r-- | cmd/podman/trust_set_show.go | 4 |
21 files changed, 136 insertions, 59 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go index 8ea9e6957..cfeabfb4e 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -53,7 +53,7 @@ func init() { flags.SetInterspersed(false) budFlags := buildahcli.GetBudFlags(&budFlagsValues) - flag := budFlags.Lookup("pull-always") + flag := budFlags.Lookup("pull") flag.Value.Set("true") flag.DefValue = "true" layerFlags := buildahcli.GetLayerFlags(&layerValues) diff --git a/cmd/podman/checkpoint.go b/cmd/podman/checkpoint.go index 8c4b8ad3c..367065766 100644 --- a/cmd/podman/checkpoint.go +++ b/cmd/podman/checkpoint.go @@ -32,9 +32,9 @@ var ( Args: func(cmd *cobra.Command, args []string) error { return checkAllAndLatest(cmd, args, false) }, - Example: `podman checkpoint --keep ctrID - podman checkpoint --all - podman checkpoint --leave-running --latest`, + Example: `podman container checkpoint --keep ctrID + podman container checkpoint --all + podman container checkpoint --leave-running --latest`, } ) 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/commands.go b/cmd/podman/commands.go index fd36e77d5..2f9a9cfe2 100644 --- a/cmd/podman/commands.go +++ b/cmd/podman/commands.go @@ -18,7 +18,7 @@ func getMainCommands() []*cobra.Command { _execCommand, _generateCommand, _playCommand, - _psCommand, + &_psCommand, _loginCommand, _logoutCommand, _logsCommand, @@ -54,6 +54,10 @@ func getImageSubCommands() []*cobra.Command { // Commands that the local client implements func getContainerSubCommands() []*cobra.Command { + + var _listSubCommand = _psCommand + _listSubCommand.Use = "list" + return []*cobra.Command{ _attachCommand, _checkpointCommand, @@ -64,8 +68,8 @@ func getContainerSubCommands() []*cobra.Command { _execCommand, _exportCommand, _killCommand, + &_listSubCommand, _logsCommand, - _psCommand, _mountCommand, _pauseCommand, _portCommand, diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 1fb06cf91..d3387b8f4 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -423,7 +423,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", ) @@ -527,7 +527,6 @@ func scrubServer(server string) string { func UsageTemplate() string { return `Usage:{{if .Runnable}} {{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} - {{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}} Aliases: diff --git a/cmd/podman/container.go b/cmd/podman/container.go index d2450fdd3..338bb005c 100644 --- a/cmd/podman/container.go +++ b/cmd/podman/container.go @@ -18,11 +18,13 @@ var containerCommand = cliconfig.PodmanCommand{ // Commands that are universally implemented. var containerCommands = []*cobra.Command{ _containerExistsCommand, + _inspectCommand, } func init() { containerCommand.AddCommand(containerCommands...) containerCommand.AddCommand(getContainerSubCommands()...) containerCommand.SetUsageTemplate(UsageTemplate()) + rootCmd.AddCommand(containerCommand.Command) } diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 2d93c149a..95cb732d9 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -67,7 +67,7 @@ func init() { getCreateFlags(&createCommand.PodmanCommand) flags := createCommand.Flags() - flags.SetInterspersed(true) + flags.SetInterspersed(false) } @@ -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/exec.go b/cmd/podman/exec.go index 032262497..4917fb606 100644 --- a/cmd/podman/exec.go +++ b/cmd/podman/exec.go @@ -105,5 +105,13 @@ func execCmd(c *cliconfig.ExecValues) error { envs = append(envs, fmt.Sprintf("%s=%s", k, v)) } - return ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir) + streams := new(libpod.AttachStreams) + streams.OutputStream = os.Stdout + streams.ErrorStream = os.Stderr + streams.InputStream = os.Stdin + streams.AttachOutput = true + streams.AttachError = true + streams.AttachInput = true + + return ctr.Exec(c.Tty, c.Privileged, envs, cmd, c.User, c.Workdir, streams) } diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go index c01a6a081..109831e74 100644 --- a/cmd/podman/exists.go +++ b/cmd/podman/exists.go @@ -40,7 +40,8 @@ var ( imageExistsCommand.GlobalFlags = MainGlobalOpts return imageExistsCmd(&imageExistsCommand) }, - Example: `podman image exists imageID`, + Example: `podman image exists imageID + podman image exists alpine || podman pull alpine`, } _containerExistsCommand = &cobra.Command{ @@ -53,7 +54,8 @@ var ( return containerExistsCmd(&containerExistsCommand) }, - Example: `podman container exists containerID`, + Example: `podman container exists containerID + podman container exists myctr || podman run --name myctr [etc...]`, } _podExistsCommand = &cobra.Command{ @@ -65,7 +67,8 @@ var ( podExistsCommand.GlobalFlags = MainGlobalOpts return podExistsCmd(&podExistsCommand) }, - Example: `podman pod exists podID`, + Example: `podman pod exists podID + podman pod exists mypod || podman pod create --name mypod`, } ) diff --git a/cmd/podman/generate_kube.go b/cmd/podman/generate_kube.go index 090f99495..fa2872b77 100644 --- a/cmd/podman/generate_kube.go +++ b/cmd/podman/generate_kube.go @@ -17,7 +17,7 @@ var ( containerKubeCommand cliconfig.GenerateKubeValues containerKubeDescription = "Generate Kubernetes Pod YAML" _containerKubeCommand = &cobra.Command{ - Use: "kube CONTAINER | POD", + Use: "kube [flags] CONTAINER | POD", Short: "Generate Kubernetes pod YAML for a container or pod", Long: containerKubeDescription, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/image.go b/cmd/podman/image.go index aaa1866c4..b5c1c3ccf 100644 --- a/cmd/podman/image.go +++ b/cmd/podman/image.go @@ -15,6 +15,7 @@ var ( }, } _imagesSubCommand = _imagesCommand + _rmSubCommand = _rmiCommand ) //imageSubCommands are implemented both in local and remote clients @@ -28,7 +29,6 @@ var imageSubCommands = []*cobra.Command{ _pruneImagesCommand, _pullCommand, _pushCommand, - _rmiCommand, _saveCommand, _tagCommand, } @@ -38,7 +38,12 @@ func init() { imageCommand.AddCommand(imageSubCommands...) imageCommand.AddCommand(getImageSubCommands()...) - _imagesSubCommand.Aliases = []string{"ls", "list"} + // Setup of "images" to appear as "list" + _imagesSubCommand.Use = "list" + _imagesSubCommand.Aliases = []string{"ls"} imageCommand.AddCommand(&_imagesSubCommand) + // Setup of "rmi" to appears as "rm" + _rmSubCommand.Use = "rm" + imageCommand.AddCommand(&_rmSubCommand) } diff --git a/cmd/podman/images.go b/cmd/podman/images.go index c7f80c34a..e6f4d9a60 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -88,7 +88,7 @@ var ( imagesDescription = "lists locally stored images." _imagesCommand = cobra.Command{ - Use: "images", + Use: "images [flags] [IMAGE]", Short: "List images in local storage", Long: imagesDescription, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/main.go b/cmd/podman/main.go index d36270853..98e2f23ca 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -47,7 +47,7 @@ var mainCommands = []*cobra.Command{ podCommand.Command, _pullCommand, _pushCommand, - _rmiCommand, + &_rmiCommand, _saveCommand, _tagCommand, _versionCommand, diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go index 6f23e340e..ac46ad5c6 100644 --- a/cmd/podman/play_kube.go +++ b/cmd/podman/play_kube.go @@ -90,8 +90,17 @@ func playKubeYAMLCmd(c *cliconfig.KubePlayValues) error { return errors.Wrapf(err, "unable to read %s as YAML", args[0]) } + // check for name collision between pod and container + podName := podYAML.ObjectMeta.Name + for _, n := range podYAML.Spec.Containers { + if n.Name == podName { + fmt.Printf("a container exists with the same name (%s) as the pod in your YAML file; changing pod name to %s_pod\n", podName, podName) + podName = fmt.Sprintf("%s_pod", podName) + } + } + podOptions = append(podOptions, libpod.WithInfraContainer()) - podOptions = append(podOptions, libpod.WithPodName(podYAML.ObjectMeta.Name)) + podOptions = append(podOptions, libpod.WithPodName(podName)) // TODO for now we just used the default kernel namespaces; we need to add/subtract this from yaml nsOptions, err := shared.GetNamespaceOptions(strings.Split(DefaultKernelNamespaces, ",")) diff --git a/cmd/podman/port.go b/cmd/podman/port.go index 1c3086536..ffb5749fb 100644 --- a/cmd/podman/port.go +++ b/cmd/podman/port.go @@ -128,9 +128,6 @@ func portCmd(c *cliconfig.PortValues) error { if state, _ := con.State(); state != libpod.ContainerStateRunning { continue } - if c.All { - fmt.Println(con.ID()) - } portmappings, err := con.PortMappings() if err != nil { @@ -143,6 +140,9 @@ func portCmd(c *cliconfig.PortValues) error { if hostIP == "" { hostIP = "0.0.0.0" } + if c.All { + fmt.Printf("%s\t", con.ID()[:12]) + } // If not searching by port or port/proto, then dump what we see if port == "" { fmt.Printf("%d/%s -> %s:%d\n", v.ContainerPort, v.Protocol, hostIP, v.HostPort) diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index d6edcabcb..acb5fd7da 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -157,7 +157,7 @@ func (a psSortedSize) Less(i, j int) bool { var ( psCommand cliconfig.PsValues psDescription = "Prints out information about the containers" - _psCommand = &cobra.Command{ + _psCommand = cobra.Command{ Use: "ps", Args: noSubArgs, Short: "List containers", @@ -174,7 +174,7 @@ var ( ) func init() { - psCommand.Command = _psCommand + psCommand.Command = &_psCommand psCommand.SetUsageTemplate(UsageTemplate()) flags := psCommand.Flags() flags.BoolVarP(&psCommand.All, "all", "a", false, "Show all the containers, default is only running containers") diff --git a/cmd/podman/refresh.go b/cmd/podman/refresh.go index 2eb3d25a8..1e4a31a52 100644 --- a/cmd/podman/refresh.go +++ b/cmd/podman/refresh.go @@ -27,6 +27,7 @@ var ( ) func init() { + _refreshCommand.Hidden = true refreshCommand.Command = _refreshCommand refreshCommand.SetUsageTemplate(UsageTemplate()) } 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/rmi.go b/cmd/podman/rmi.go index e5bb9b486..5b8bf1ea3 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -14,7 +14,7 @@ import ( var ( rmiCommand cliconfig.RmiValues rmiDescription = "Removes one or more locally stored images." - _rmiCommand = &cobra.Command{ + _rmiCommand = cobra.Command{ Use: "rmi [flags] IMAGE [IMAGE...]", Short: "Removes one or more images from local storage", Long: rmiDescription, @@ -30,7 +30,7 @@ var ( ) func init() { - rmiCommand.Command = _rmiCommand + rmiCommand.Command = &_rmiCommand rmiCommand.SetUsageTemplate(UsageTemplate()) flags := rmiCommand.Flags() flags.BoolVarP(&rmiCommand.All, "all", "a", false, "Remove all images") 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(), diff --git a/cmd/podman/trust_set_show.go b/cmd/podman/trust_set_show.go index 0a4783d0a..746854249 100644 --- a/cmd/podman/trust_set_show.go +++ b/cmd/podman/trust_set_show.go @@ -23,7 +23,7 @@ var ( showTrustCommand cliconfig.ShowTrustValues setTrustDescription = "Set default trust policy or add a new trust policy for a registry" _setTrustCommand = &cobra.Command{ - Use: "set", + Use: "set [flags] REGISTRY", Short: "Set default trust policy or a new trust policy for a registry", Long: setTrustDescription, Example: "", @@ -36,7 +36,7 @@ var ( showTrustDescription = "Display trust policy for the system" _showTrustCommand = &cobra.Command{ - Use: "show", + Use: "show [flags] [REGISTRY]", Short: "Display trust policy for the system", Long: showTrustDescription, RunE: func(cmd *cobra.Command, args []string) error { |