summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/commands.go2
-rw-r--r--cmd/podman/container.go1
-rw-r--r--cmd/podman/create.go2
-rw-r--r--cmd/podman/export.go51
-rw-r--r--cmd/podman/image.go1
-rw-r--r--cmd/podman/import.go77
-rw-r--r--cmd/podman/main.go2
-rw-r--r--cmd/podman/play_kube.go2
-rw-r--r--cmd/podman/pull.go2
-rw-r--r--cmd/podman/runlabel.go2
-rw-r--r--cmd/podman/shared/container.go2
-rw-r--r--cmd/podman/sign.go2
-rw-r--r--cmd/podman/varlink/io.podman.varlink5
13 files changed, 28 insertions, 123 deletions
diff --git a/cmd/podman/commands.go b/cmd/podman/commands.go
index 718717009..d8fdd556f 100644
--- a/cmd/podman/commands.go
+++ b/cmd/podman/commands.go
@@ -12,8 +12,6 @@ func getAppCommands() []cli.Command {
createCommand,
diffCommand,
execCommand,
- exportCommand,
- importCommand,
killCommand,
kubeCommand,
loadCommand,
diff --git a/cmd/podman/container.go b/cmd/podman/container.go
index acbcbb644..29300a6a4 100644
--- a/cmd/podman/container.go
+++ b/cmd/podman/container.go
@@ -8,6 +8,7 @@ import (
var (
containerSubCommands = []cli.Command{
+ exportCommand,
inspectCommand,
}
containerDescription = "Manage containers"
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index c56efa153..2d85abd35 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -134,7 +134,7 @@ func createContainer(c *cli.Context, runtime *libpod.Runtime) (*libpod.Container
writer = os.Stderr
}
- newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", writer, nil, image.SigningOptions{}, false)
+ newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", writer, nil, image.SigningOptions{}, false, nil)
if err != nil {
return nil, nil, err
}
diff --git a/cmd/podman/export.go b/cmd/podman/export.go
index c0e63bd2a..eaa4e38a2 100644
--- a/cmd/podman/export.go
+++ b/cmd/podman/export.go
@@ -1,12 +1,9 @@
package main
import (
- "io/ioutil"
"os"
- "strconv"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/adapter"
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -43,7 +40,7 @@ func exportCmd(c *cli.Context) error {
rootless.SetSkipStorageSetup(true)
}
- runtime, err := libpodruntime.GetRuntime(c)
+ runtime, err := adapter.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
@@ -58,52 +55,18 @@ func exportCmd(c *cli.Context) error {
}
output := c.String("output")
+ if runtime.Remote && (output == "/dev/stdout" || len(output) == 0) {
+ return errors.New("remote client usage must specify an output file (-o)")
+ }
if output == "/dev/stdout" {
file := os.Stdout
if logrus.IsTerminal(file) {
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
}
}
+
if err := validateFileName(output); err != nil {
return err
}
-
- ctr, err := runtime.LookupContainer(args[0])
- if err != nil {
- return errors.Wrapf(err, "error looking up container %q", args[0])
- }
-
- if os.Geteuid() != 0 {
- state, err := ctr.State()
- if err != nil {
- return errors.Wrapf(err, "cannot read container state %q", ctr.ID())
- }
- if state == libpod.ContainerStateRunning || state == libpod.ContainerStatePaused {
- data, err := ioutil.ReadFile(ctr.Config().ConmonPidFile)
- if err != nil {
- return errors.Wrapf(err, "cannot read conmon PID file %q", ctr.Config().ConmonPidFile)
- }
- conmonPid, err := strconv.Atoi(string(data))
- if err != nil {
- return errors.Wrapf(err, "cannot parse PID %q", data)
- }
- became, ret, err := rootless.JoinDirectUserAndMountNS(uint(conmonPid))
- if err != nil {
- return err
- }
- if became {
- os.Exit(ret)
- }
- } else {
- became, ret, err := rootless.BecomeRootInUserNS()
- if err != nil {
- return err
- }
- if became {
- os.Exit(ret)
- }
- }
- }
-
- return ctr.Export(output)
+ return runtime.Export(args[0], c.String("output"))
}
diff --git a/cmd/podman/image.go b/cmd/podman/image.go
index a51a90b0e..6b451a1ca 100644
--- a/cmd/podman/image.go
+++ b/cmd/podman/image.go
@@ -8,6 +8,7 @@ import (
var (
imageSubCommands = []cli.Command{
+ importCommand,
historyCommand,
imageExistsCommand,
inspectCommand,
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
index 144354fa6..661bd5a65 100644
--- a/cmd/podman/import.go
+++ b/cmd/podman/import.go
@@ -2,16 +2,8 @@ package main
import (
"fmt"
- "io"
- "io/ioutil"
- "net/http"
- "net/url"
- "os"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/libpod/image"
- "github.com/containers/libpod/pkg/util"
- "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
@@ -51,7 +43,7 @@ func importCmd(c *cli.Context) error {
return err
}
- runtime, err := libpodruntime.GetRuntime(c)
+ runtime, err := adapter.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
@@ -60,7 +52,6 @@ func importCmd(c *cli.Context) error {
var (
source string
reference string
- writer io.Writer
)
args := c.Args()
@@ -80,67 +71,13 @@ func importCmd(c *cli.Context) error {
return err
}
- changes := v1.ImageConfig{}
- if c.IsSet("change") || c.IsSet("c") {
- changes, err = util.GetImageConfig(c.StringSlice("change"))
- if err != nil {
- return errors.Wrapf(err, "error adding config changes to image %q", source)
- }
+ quiet := c.Bool("quiet")
+ if runtime.Remote {
+ quiet = false
}
-
- history := []v1.History{
- {Comment: c.String("message")},
- }
-
- config := v1.Image{
- Config: changes,
- History: history,
- }
-
- writer = nil
- if !c.Bool("quiet") {
- writer = os.Stderr
- }
-
- // if source is a url, download it and save to a temp file
- u, err := url.ParseRequestURI(source)
- if err == nil && u.Scheme != "" {
- file, err := downloadFromURL(source)
- if err != nil {
- return err
- }
- defer os.Remove(file)
- source = file
- }
-
- newImage, err := runtime.ImageRuntime().Import(getContext(), source, reference, writer, image.SigningOptions{}, config)
+ iid, err := runtime.Import(getContext(), source, reference, c.StringSlice("change"), c.String("message"), quiet)
if err == nil {
- fmt.Println(newImage.ID())
+ fmt.Println(iid)
}
return err
}
-
-// donwloadFromURL downloads an image in the format "https:/example.com/myimage.tar"
-// and temporarily saves in it /var/tmp/importxyz, which is deleted after the image is imported
-func downloadFromURL(source string) (string, error) {
- fmt.Printf("Downloading from %q\n", source)
-
- outFile, err := ioutil.TempFile("/var/tmp", "import")
- if err != nil {
- return "", errors.Wrap(err, "error creating file")
- }
- defer outFile.Close()
-
- response, err := http.Get(source)
- if err != nil {
- return "", errors.Wrapf(err, "error downloading %q", source)
- }
- defer response.Body.Close()
-
- _, err = io.Copy(outFile, response.Body)
- if err != nil {
- return "", errors.Wrapf(err, "error saving %s to %s", source, outFile.Name())
- }
-
- return outFile.Name(), nil
-}
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index c10590006..1ca8882eb 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -88,9 +88,11 @@ func main() {
app.Commands = []cli.Command{
containerCommand,
+ exportCommand,
historyCommand,
imageCommand,
imagesCommand,
+ importCommand,
infoCommand,
inspectCommand,
pullCommand,
diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go
index 2ce2e21bb..4753dd0a6 100644
--- a/cmd/podman/play_kube.go
+++ b/cmd/podman/play_kube.go
@@ -146,7 +146,7 @@ func playKubeYAMLCmd(c *cli.Context) error {
}
for _, container := range podYAML.Spec.Containers {
- newImage, err := runtime.ImageRuntime().New(ctx, container.Image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, false)
+ newImage, err := runtime.ImageRuntime().New(ctx, container.Image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, false, nil)
if err != nil {
return err
}
diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go
index 2a78d0c54..f70e5cded 100644
--- a/cmd/podman/pull.go
+++ b/cmd/podman/pull.go
@@ -123,7 +123,7 @@ func pullCmd(c *cli.Context) error {
imgID = newImage[0].ID()
} else {
authfile := getAuthFile(c.String("authfile"))
- newImage, err := runtime.New(getContext(), image, c.String("signature-policy"), authfile, writer, &dockerRegistryOptions, image2.SigningOptions{}, true)
+ newImage, err := runtime.New(getContext(), image, c.String("signature-policy"), authfile, writer, &dockerRegistryOptions, image2.SigningOptions{}, true, nil)
if err != nil {
return errors.Wrapf(err, "error pulling image %q", image)
}
diff --git a/cmd/podman/runlabel.go b/cmd/podman/runlabel.go
index 48a296260..b16a93fd9 100644
--- a/cmd/podman/runlabel.go
+++ b/cmd/podman/runlabel.go
@@ -166,7 +166,7 @@ func runlabelCmd(c *cli.Context) error {
return err
}
if runLabel == "" {
- return nil
+ return errors.Errorf("%s does not have a label of %s", runlabelImage, label)
}
cmd, env, err := shared.GenerateRunlabelCommand(runLabel, imageName, c.String("name"), opts, extraArgs)
diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go
index 9040c4a5c..f84fb8261 100644
--- a/cmd/podman/shared/container.go
+++ b/cmd/podman/shared/container.go
@@ -609,7 +609,7 @@ func GetRunlabel(label string, runlabelImage string, ctx context.Context, runtim
registryCreds = creds
}
dockerRegistryOptions.DockerRegistryCreds = registryCreds
- newImage, err = runtime.ImageRuntime().New(ctx, runlabelImage, signaturePolicyPath, authfile, output, &dockerRegistryOptions, image.SigningOptions{}, false)
+ newImage, err = runtime.ImageRuntime().New(ctx, runlabelImage, signaturePolicyPath, authfile, output, &dockerRegistryOptions, image.SigningOptions{}, false, &label)
} else {
newImage, err = runtime.ImageRuntime().NewFromLocal(runlabelImage)
}
diff --git a/cmd/podman/sign.go b/cmd/podman/sign.go
index 1d9aecdc9..22aa07230 100644
--- a/cmd/podman/sign.go
+++ b/cmd/podman/sign.go
@@ -104,7 +104,7 @@ func signCmd(c *cli.Context) error {
}
// create the signstore file
- newImage, err := runtime.ImageRuntime().New(getContext(), signimage, runtime.GetConfig().SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{SignBy: signby}, false)
+ newImage, err := runtime.ImageRuntime().New(getContext(), signimage, runtime.GetConfig().SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{SignBy: signby}, false, nil)
if err != nil {
return errors.Wrapf(err, "error pulling image %s", signimage)
}
diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink
index 8b02057a1..101232b0c 100644
--- a/cmd/podman/varlink/io.podman.varlink
+++ b/cmd/podman/varlink/io.podman.varlink
@@ -688,7 +688,7 @@ method Commit(name: string, image_name: string, changes: []string, author: strin
# ImportImage imports an image from a source (like tarball) into local storage. The image can have additional
# descriptions added to it using the message and changes options. See also [ExportImage](ExportImage).
-method ImportImage(source: string, reference: string, message: string, changes: []string) -> (image: string)
+method ImportImage(source: string, reference: string, message: string, changes: []string, delete: bool) -> (image: string)
# ExportImage takes the name or ID of an image and exports it to a destination like a tarball. There is also
# a booleon option to force compression. It also takes in a string array of tags to be able to save multiple
@@ -1050,6 +1050,9 @@ method ContainerInspectData(name: string) -> (config: string)
# development of Podman only and generally should not be used.
method ContainerStateData(name: string) -> (config: string)
+method SendFile(type: string, length: int) -> (file_handle: string)
+method ReceiveFile(path: string, delete: bool) -> (len: int)
+
# ImageNotFound means the image could not be found by the provided name or ID in local storage.
error ImageNotFound (name: string)