mirror of https://github.com/containers/podman.git
Cleanup messages on podman load
If user does not specify file or redirect for stdin, then throw an error Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
ea54a1c2f5
commit
d0ee203986
|
|
@ -12,7 +12,7 @@ popularized by Kubernetes. Libpod also contains the Pod Manager tool `(Podman)`
|
||||||
|
|
||||||
At a high level, the scope of libpod and podman is the following:
|
At a high level, the scope of libpod and podman is the following:
|
||||||
|
|
||||||
* Support multiple image formats including the existing Docker/OCI image formats.
|
* Support multiple image formats including the OCI and Docker image formats.
|
||||||
* Support for multiple means to download images including trust & image verification.
|
* Support for multiple means to download images including trust & image verification.
|
||||||
* Container image management (managing image layers, overlay filesystems, etc).
|
* Container image management (managing image layers, overlay filesystems, etc).
|
||||||
* Full management of container lifecycle
|
* Full management of container lifecycle
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,24 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
"github.com/containers/libpod/cmd/podman/shared/parse"
|
"github.com/containers/libpod/cmd/podman/shared/parse"
|
||||||
"github.com/containers/libpod/pkg/adapter"
|
"github.com/containers/libpod/pkg/adapter"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
loadCommand cliconfig.LoadValues
|
loadCommand cliconfig.LoadValues
|
||||||
|
|
||||||
loadDescription = "Loads the image from docker-archive stored on the local machine."
|
loadDescription = "Loads an image from a locally stored archive (tar file) into container storage."
|
||||||
_loadCommand = &cobra.Command{
|
|
||||||
Use: "load [flags] [PATH]",
|
_loadCommand = &cobra.Command{
|
||||||
Short: "Load an image from docker archive",
|
Use: "load [flags] [NAME[:TAG]]",
|
||||||
|
Short: "Load an image from container archive",
|
||||||
Long: loadDescription,
|
Long: loadDescription,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
loadCommand.InputArgs = args
|
loadCommand.InputArgs = args
|
||||||
|
|
@ -60,49 +63,43 @@ func loadCmd(c *cliconfig.LoadValues) error {
|
||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer runtime.Shutdown(false)
|
||||||
|
|
||||||
input := c.Input
|
if len(c.Input) > 0 {
|
||||||
if runtime.Remote && len(input) == 0 {
|
if err := parse.ValidateFileName(c.Input); err != nil {
|
||||||
return errors.New("the remote client requires you to load via -i and a tarball")
|
|
||||||
}
|
|
||||||
if len(input) == 0 {
|
|
||||||
input = "/dev/stdin"
|
|
||||||
c.Input = input
|
|
||||||
|
|
||||||
fi, err := os.Stdin.Stat()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// checking if loading from pipe
|
} else {
|
||||||
if !fi.Mode().IsRegular() {
|
if terminal.IsTerminal(int(os.Stdin.Fd())) {
|
||||||
outFile, err := ioutil.TempFile("/var/tmp", "podman")
|
return errors.Errorf("cannot read from terminal. Use command-line redirection or the --input flag.")
|
||||||
if err != nil {
|
|
||||||
return errors.Errorf("error creating file %v", err)
|
|
||||||
}
|
|
||||||
defer os.Remove(outFile.Name())
|
|
||||||
defer outFile.Close()
|
|
||||||
|
|
||||||
inFile, err := os.OpenFile(input, 0, 0666)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Errorf("error reading file %v", err)
|
|
||||||
}
|
|
||||||
defer inFile.Close()
|
|
||||||
|
|
||||||
_, err = io.Copy(outFile, inFile)
|
|
||||||
if err != nil {
|
|
||||||
return errors.Errorf("error copying file %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
input = outFile.Name()
|
|
||||||
}
|
}
|
||||||
}
|
outFile, err := ioutil.TempFile("/var/tmp", "podman")
|
||||||
if err := parse.ValidateFileName(input); err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Errorf("error creating file %v", err)
|
||||||
|
}
|
||||||
|
defer os.Remove(outFile.Name())
|
||||||
|
defer outFile.Close()
|
||||||
|
|
||||||
|
_, err = io.Copy(outFile, os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Errorf("error copying file %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Input = outFile.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
names, err := runtime.LoadImage(getContext(), imageName, c)
|
names, err := runtime.LoadImage(getContext(), imageName, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(imageName) > 0 {
|
||||||
|
split := strings.Split(names, ",")
|
||||||
|
newImage, err := runtime.NewImageFromLocal(split[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := newImage.TagImage(imageName); err != nil {
|
||||||
|
return errors.Wrapf(err, "error adding '%s' to image %q", imageName, newImage.InputName)
|
||||||
|
}
|
||||||
|
}
|
||||||
fmt.Println("Loaded image(s): " + names)
|
fmt.Println("Loaded image(s): " + names)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
| [podman-info(1)](/docs/podman-info.1.md) | Display system information |[](https://asciinema.org/a/yKbi5fQ89y5TJ8e1RfJd4ivTD)|
|
| [podman-info(1)](/docs/podman-info.1.md) | Display system information |[](https://asciinema.org/a/yKbi5fQ89y5TJ8e1RfJd4ivTD)|
|
||||||
| [podman-inspect(1)](/docs/podman-inspect.1.md) | Display the configuration of a container or image |[](https://asciinema.org/a/133418)|
|
| [podman-inspect(1)](/docs/podman-inspect.1.md) | Display the configuration of a container or image |[](https://asciinema.org/a/133418)|
|
||||||
| [podman-kill(1)](/docs/podman-kill.1.md) | Kill the main process in one or more running containers |[](https://asciinema.org/a/3jNos0A5yzO4hChu7ddKkUPw7)|
|
| [podman-kill(1)](/docs/podman-kill.1.md) | Kill the main process in one or more running containers |[](https://asciinema.org/a/3jNos0A5yzO4hChu7ddKkUPw7)|
|
||||||
| [podman-load(1)](/docs/podman-load.1.md) | Load an image from docker archive or oci |[](https://asciinema.org/a/kp8kOaexEhEa20P1KLZ3L5X4g)|
|
| [podman-load(1)](/docs/podman-load.1.md) | Load an image from a container image archive |[](https://asciinema.org/a/kp8kOaexEhEa20P1KLZ3L5X4g)|
|
||||||
| [podman-login(1)](/docs/podman-login.1.md) | Login to a container registry |[](https://asciinema.org/a/oNiPgmfo1FjV2YdesiLpvihtV)|
|
| [podman-login(1)](/docs/podman-login.1.md) | Login to a container registry |[](https://asciinema.org/a/oNiPgmfo1FjV2YdesiLpvihtV)|
|
||||||
| [podman-logout(1)](/docs/podman-logout.1.md) | Logout of a container registry |[](https://asciinema.org/a/oNiPgmfo1FjV2YdesiLpvihtV)|
|
| [podman-logout(1)](/docs/podman-logout.1.md) | Logout of a container registry |[](https://asciinema.org/a/oNiPgmfo1FjV2YdesiLpvihtV)|
|
||||||
| [podman-logs(1)](/docs/podman-logs.1.md) | Display the logs of a container |[](https://asciinema.org/a/MZPTWD5CVs3dMREkBxQBY9C5z)|
|
| [podman-logs(1)](/docs/podman-logs.1.md) | Display the logs of a container |[](https://asciinema.org/a/MZPTWD5CVs3dMREkBxQBY9C5z)|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,24 @@
|
||||||
% podman-load(1)
|
% podman-load(1)
|
||||||
|
|
||||||
## NAME
|
## NAME
|
||||||
podman\-load - Load an image from docker archive
|
podman\-load - Load an image from a container image archive into container storage
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman load** [ARCHIVE]
|
**podman load** [*name*[:*tag*]]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
**podman load** copies an image from either **docker-archive** or **oci-archive** stored
|
**podman load** loads an image from either an **oci-archive** or **docker-archive** stored on the local machine into container storage. **podman load** reads from stdin by default or a file if the **input** option is set.
|
||||||
on the local machine. **podman load** reads from stdin by default or a file if the **input** flag is set.
|
You can also specify a name for the image if the archive does not contain a named reference, of if you want an additonal name for the local image.
|
||||||
The **quiet** flag suppresses the output when set.
|
|
||||||
|
The **quiet** option suppresses the progress output when set.
|
||||||
Note: `:` is a restricted character and cannot be part of the file name.
|
Note: `:` is a restricted character and cannot be part of the file name.
|
||||||
|
|
||||||
|
|
||||||
**podman [GLOBAL OPTIONS]**
|
**podman [GLOBAL OPTIONS]**
|
||||||
|
|
||||||
**podman load [GLOBAL OPTIONS]**
|
**podman load [GLOBAL OPTIONS]**
|
||||||
|
|
||||||
**podman load [OPTIONS] NAME[:TAG|@DIGEST]**
|
**podman load [OPTIONS] NAME[:TAG]**
|
||||||
|
|
||||||
## OPTIONS
|
## OPTIONS
|
||||||
|
|
||||||
|
|
@ -28,7 +30,7 @@ The remote client requires the use of this option.
|
||||||
|
|
||||||
**--quiet, -q**
|
**--quiet, -q**
|
||||||
|
|
||||||
Suppress the output
|
Suppress the progress output
|
||||||
|
|
||||||
**--signature-policy="PATHNAME"**
|
**--signature-policy="PATHNAME"**
|
||||||
|
|
||||||
|
|
@ -75,7 +77,7 @@ Loaded image: registry.fedoraproject.org/fedora:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## SEE ALSO
|
## SEE ALSO
|
||||||
podman(1), podman-save(1), crio(8)
|
podman(1), podman-save(1), podman-tag(1), crio(8)
|
||||||
|
|
||||||
## HISTORY
|
## HISTORY
|
||||||
July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com>
|
July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
% podman-save(1)
|
% podman-save(1)
|
||||||
|
|
||||||
## NAME
|
## NAME
|
||||||
podman\-save - Save an image to docker-archive or oci-archive
|
podman\-save - Save an image to a container archive
|
||||||
|
|
||||||
## SYNOPSIS
|
## SYNOPSIS
|
||||||
**podman save** [*options*] *name*[:*tag*]
|
**podman save** [*options*] *name*[:*tag*]
|
||||||
|
|
||||||
## DESCRIPTION
|
## DESCRIPTION
|
||||||
**podman save** saves an image to either **docker-archive**, **oci-archive**, **oci-dir** (directory
|
**podman save** saves an image to either **docker-archive**, **oci-archive**, **oci-dir** (directory with oci manifest type), or **docker-dir** (directory with v2s2 manifest type) on the local machine,
|
||||||
with oci manifest type), or **docker-dir** (directory with v2s2 manifest type) on the local machine,
|
|
||||||
default is **docker-archive**. **podman save** writes to STDOUT by default and can be redirected to a
|
default is **docker-archive**. **podman save** writes to STDOUT by default and can be redirected to a
|
||||||
file using the **output** flag. The **quiet** flag suppresses the output when set.
|
file using the **output** flag. The **quiet** flag suppresses the output when set.
|
||||||
Note: `:` is a restricted character and cannot be part of the file name.
|
Note: `:` is a restricted character and cannot be part of the file name.
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,6 @@ registries = []
|
||||||
# If you need to block pull access from a registry, uncomment the section below
|
# If you need to block pull access from a registry, uncomment the section below
|
||||||
# and add the registries fully-qualified name.
|
# and add the registries fully-qualified name.
|
||||||
#
|
#
|
||||||
# Docker only
|
|
||||||
[registries.block]
|
[registries.block]
|
||||||
registries = []
|
registries = []
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue