summaryrefslogtreecommitdiff
path: root/cmd/podmanV2
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podmanV2')
-rw-r--r--cmd/podmanV2/containers/kill.go7
-rw-r--r--cmd/podmanV2/containers/wait.go2
-rw-r--r--cmd/podmanV2/images/load.go42
-rw-r--r--cmd/podmanV2/images/tag.go11
-rw-r--r--cmd/podmanV2/pods/create.go15
5 files changed, 67 insertions, 10 deletions
diff --git a/cmd/podmanV2/containers/kill.go b/cmd/podmanV2/containers/kill.go
index 6e6debfec..3155d1f34 100644
--- a/cmd/podmanV2/containers/kill.go
+++ b/cmd/podmanV2/containers/kill.go
@@ -2,6 +2,7 @@ package containers
import (
"context"
+ "errors"
"fmt"
"github.com/containers/libpod/cmd/podmanV2/parse"
@@ -54,9 +55,13 @@ func kill(cmd *cobra.Command, args []string) error {
)
// Check if the signalString provided by the user is valid
// Invalid signals will return err
- if _, err = signal.ParseSignalNameOrNumber(killOptions.Signal); err != nil {
+ sig, err := signal.ParseSignalNameOrNumber(killOptions.Signal)
+ if err != nil {
return err
}
+ if sig < 1 || sig > 64 {
+ return errors.New("valid signals are 1 through 64")
+ }
responses, err := registry.ContainerEngine().ContainerKill(context.Background(), args, killOptions)
if err != nil {
return err
diff --git a/cmd/podmanV2/containers/wait.go b/cmd/podmanV2/containers/wait.go
index 29a0e5546..2171f2073 100644
--- a/cmd/podmanV2/containers/wait.go
+++ b/cmd/podmanV2/containers/wait.go
@@ -70,7 +70,7 @@ func wait(cmd *cobra.Command, args []string) error {
}
for _, r := range responses {
if r.Error == nil {
- fmt.Println(r.Id)
+ fmt.Println(r.ExitCode)
} else {
errs = append(errs, r.Error)
}
diff --git a/cmd/podmanV2/images/load.go b/cmd/podmanV2/images/load.go
index f60dc4908..315dbed3a 100644
--- a/cmd/podmanV2/images/load.go
+++ b/cmd/podmanV2/images/load.go
@@ -3,11 +3,18 @@ package images
import (
"context"
"fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "github.com/containers/image/v5/docker/reference"
+ "github.com/containers/libpod/cmd/podmanV2/parse"
"github.com/containers/libpod/cmd/podmanV2/registry"
- "github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/util"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
+ "golang.org/x/crypto/ssh/terminal"
)
var (
@@ -46,11 +53,40 @@ func init() {
func load(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
- repo, err := image.NormalizedTag(args[0])
+ ref, err := reference.Parse(args[0])
if err != nil {
return err
}
- loadOpts.Name = repo.Name()
+ if t, ok := ref.(reference.Tagged); ok {
+ loadOpts.Tag = t.Tag()
+ } else {
+ loadOpts.Tag = "latest"
+ }
+ if r, ok := ref.(reference.Named); ok {
+ fmt.Println(r.Name())
+ loadOpts.Name = r.Name()
+ }
+ }
+ if len(loadOpts.Input) > 0 {
+ if err := parse.ValidateFileName(loadOpts.Input); err != nil {
+ return err
+ }
+ } else {
+ if terminal.IsTerminal(int(os.Stdin.Fd())) {
+ return errors.Errorf("cannot read from terminal. Use command-line redirection or the --input flag.")
+ }
+ outFile, err := ioutil.TempFile(util.Tmpdir(), "podman")
+ if err != nil {
+ 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)
+ }
+ loadOpts.Input = outFile.Name()
}
response, err := registry.ImageEngine().Load(context.Background(), loadOpts)
if err != nil {
diff --git a/cmd/podmanV2/images/tag.go b/cmd/podmanV2/images/tag.go
index f66fe7857..f8799d4a7 100644
--- a/cmd/podmanV2/images/tag.go
+++ b/cmd/podmanV2/images/tag.go
@@ -9,11 +9,12 @@ import (
var (
tagDescription = "Adds one or more additional names to locally-stored image."
tagCommand = &cobra.Command{
- Use: "tag [flags] IMAGE TARGET_NAME [TARGET_NAME...]",
- Short: "Add an additional name to a local image",
- Long: tagDescription,
- RunE: tag,
- Args: cobra.MinimumNArgs(2),
+ Use: "tag [flags] IMAGE TARGET_NAME [TARGET_NAME...]",
+ Short: "Add an additional name to a local image",
+ Long: tagDescription,
+ RunE: tag,
+ PreRunE: preRunE,
+ Args: cobra.MinimumNArgs(2),
Example: `podman tag 0e3bbc2 fedora:latest
podman tag imageID:latest myNewImage:newTag
podman tag httpd myregistryhost:5000/fedora/httpd:v2`,
diff --git a/cmd/podmanV2/pods/create.go b/cmd/podmanV2/pods/create.go
index ab8957ee3..2aaf0cd2c 100644
--- a/cmd/podmanV2/pods/create.go
+++ b/cmd/podmanV2/pods/create.go
@@ -123,6 +123,21 @@ func create(cmd *cobra.Command, args []string) error {
}
}
+ if !createOptions.Infra {
+ if cmd.Flag("infra-command").Changed {
+ return errors.New("cannot set infra-command without an infra container")
+ }
+ createOptions.InfraCommand = ""
+ if cmd.Flag("infra-image").Changed {
+ return errors.New("cannot set infra-image without an infra container")
+ }
+ createOptions.InfraImage = ""
+ if cmd.Flag("share").Changed {
+ return errors.New("cannot set share namespaces without an infra container")
+ }
+ createOptions.Share = nil
+ }
+
response, err := registry.ContainerEngine().PodCreate(context.Background(), createOptions)
if err != nil {
return err