aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common/completion.go10
-rw-r--r--cmd/podman/common/create.go2
-rw-r--r--cmd/podman/containers/checkpoint.go10
-rw-r--r--cmd/podman/containers/ps.go5
-rw-r--r--cmd/podman/containers/restore.go11
-rw-r--r--cmd/podman/images/build.go10
-rw-r--r--cmd/podman/images/search.go47
-rw-r--r--cmd/podman/play/kube.go15
-rw-r--r--cmd/podman/pods/ps.go5
-rw-r--r--cmd/podman/root.go2
10 files changed, 105 insertions, 12 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index 83fe0723c..d01842998 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -982,9 +982,10 @@ func AutocompletePsFilters(cmd *cobra.Command, args []string, toComplete string)
return []string{define.HealthCheckHealthy,
define.HealthCheckUnhealthy}, cobra.ShellCompDirectiveNoFileComp
},
- "label=": nil,
- "exited=": nil,
- "until=": nil,
+ "network=": func(s string) ([]string, cobra.ShellCompDirective) { return getNetworks(cmd, s) },
+ "label=": nil,
+ "exited=": nil,
+ "until=": nil,
}
return completeKeyValues(toComplete, kv)
}
@@ -1004,7 +1005,8 @@ func AutocompletePodPsFilters(cmd *cobra.Command, args []string, toComplete stri
"ctr-status=": func(_ string) ([]string, cobra.ShellCompDirective) {
return containerStatuses, cobra.ShellCompDirectiveNoFileComp
},
- "label=": nil,
+ "network=": func(s string) ([]string, cobra.ShellCompDirective) { return getNetworks(cmd, s) },
+ "label=": nil,
}
return completeKeyValues(toComplete, kv)
}
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index bbd4f6bae..24703eda2 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -336,7 +336,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
createFlags.BoolVar(
&cf.HTTPProxy,
- "http-proxy", true,
+ "http-proxy", containerConfig.Containers.HTTPProxy,
"Set proxy environment variables in the container based on the host proxy vars",
)
diff --git a/cmd/podman/containers/checkpoint.go b/cmd/podman/containers/checkpoint.go
index b6dc21348..14abfd5a7 100644
--- a/cmd/podman/containers/checkpoint.go
+++ b/cmd/podman/containers/checkpoint.go
@@ -57,6 +57,10 @@ func init() {
_ = checkpointCommand.RegisterFlagCompletionFunc(exportFlagName, completion.AutocompleteDefault)
flags.BoolVar(&checkpointOptions.IgnoreRootFS, "ignore-rootfs", false, "Do not include root file-system changes when exporting")
+ flags.BoolVar(&checkpointOptions.IgnoreVolumes, "ignore-volumes", false, "Do not export volumes associated with container")
+ flags.BoolVarP(&checkpointOptions.PreCheckPoint, "pre-checkpoint", "P", false, "Dump container's memory information only, leave the container running")
+ flags.BoolVar(&checkpointOptions.WithPrevious, "with-previous", false, "Checkpoint container with pre-checkpoint images")
+
validate.AddLatestFlag(checkpointCommand, &checkpointOptions.Latest)
}
@@ -68,6 +72,12 @@ func checkpoint(cmd *cobra.Command, args []string) error {
if checkpointOptions.Export == "" && checkpointOptions.IgnoreRootFS {
return errors.Errorf("--ignore-rootfs can only be used with --export")
}
+ if checkpointOptions.Export == "" && checkpointOptions.IgnoreVolumes {
+ return errors.Errorf("--ignore-volumes can only be used with --export")
+ }
+ if checkpointOptions.WithPrevious && checkpointOptions.PreCheckPoint {
+ return errors.Errorf("--with-previous can not be used with --pre-checkpoint")
+ }
responses, err := registry.ContainerEngine().ContainerCheckpoint(context.Background(), args, checkpointOptions)
if err != nil {
return err
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 5d08e6163..d23771fc5 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -392,6 +392,11 @@ func (l psReporter) Names() string {
return l.ListContainer.Names[0]
}
+// Networks returns the container network names in string format
+func (l psReporter) Networks() string {
+ return strings.Join(l.ListContainer.Networks, ",")
+}
+
// Ports converts from Portmappings to the string form
// required by ps
func (l psReporter) Ports() string {
diff --git a/cmd/podman/containers/restore.go b/cmd/podman/containers/restore.go
index 6a1d2b319..49c0be88e 100644
--- a/cmd/podman/containers/restore.go
+++ b/cmd/podman/containers/restore.go
@@ -59,9 +59,14 @@ func init() {
flags.StringVarP(&restoreOptions.Name, nameFlagName, "n", "", "Specify new name for container restored from exported checkpoint (only works with --import)")
_ = restoreCommand.RegisterFlagCompletionFunc(nameFlagName, completion.AutocompleteNone)
+ importPreviousFlagName := "import-previous"
+ flags.StringVar(&restoreOptions.ImportPrevious, importPreviousFlagName, "", "Restore from exported pre-checkpoint archive (tar.gz)")
+ _ = restoreCommand.RegisterFlagCompletionFunc(importPreviousFlagName, completion.AutocompleteDefault)
+
flags.BoolVar(&restoreOptions.IgnoreRootFS, "ignore-rootfs", false, "Do not apply root file-system changes when importing from exported checkpoint")
flags.BoolVar(&restoreOptions.IgnoreStaticIP, "ignore-static-ip", false, "Ignore IP address set via --static-ip")
flags.BoolVar(&restoreOptions.IgnoreStaticMAC, "ignore-static-mac", false, "Ignore MAC address set via --mac-address")
+ flags.BoolVar(&restoreOptions.IgnoreVolumes, "ignore-volumes", false, "Do not export volumes associated with container")
validate.AddLatestFlag(restoreCommand, &restoreOptions.Latest)
}
@@ -70,9 +75,15 @@ func restore(_ *cobra.Command, args []string) error {
if rootless.IsRootless() {
return errors.New("restoring a container requires root")
}
+ if restoreOptions.Import == "" && restoreOptions.ImportPrevious != "" {
+ return errors.Errorf("--import-previous can only be used with --import")
+ }
if restoreOptions.Import == "" && restoreOptions.IgnoreRootFS {
return errors.Errorf("--ignore-rootfs can only be used with --import")
}
+ if restoreOptions.Import == "" && restoreOptions.IgnoreVolumes {
+ return errors.Errorf("--ignore-volumes can only be used with --import")
+ }
if restoreOptions.Import == "" && restoreOptions.Name != "" {
return errors.Errorf("--name can only be used with --import")
}
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 3aca104e3..c0aa27ca1 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -135,6 +135,16 @@ func buildFlags(cmd *cobra.Command) {
logrus.Errorf("error setting up build flags: %v", err)
os.Exit(1)
}
+ // --http-proxy flag
+ // containers.conf defaults to true but we want to force false by default for remote, since settings do not apply
+ if registry.IsRemote() {
+ flag = fromAndBudFlags.Lookup("http-proxy")
+ buildOpts.HTTPProxy = false
+ if err := flag.Value.Set("false"); err != nil {
+ logrus.Errorf("unable to set --https-proxy to %v: %v", false, err)
+ }
+ flag.DefValue = "false"
+ }
flags.AddFlagSet(&fromAndBudFlags)
// Add the completion functions
fromAndBudFlagsCompletions := buildahCLI.GetFromAndBudFlagsCompletions()
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index c2ef7d767..c8ea4b04a 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -26,6 +26,12 @@ type searchOptionsWrapper struct {
Format string // For go templating
}
+// listEntryTag is a utility structure used for json serialization.
+type listEntryTag struct {
+ Name string
+ Tags []string
+}
+
var (
searchOptions = searchOptionsWrapper{}
searchDescription = `Search registries for a given image. Can search all the default registries or a specific registry.
@@ -149,14 +155,13 @@ func imageSearch(cmd *cobra.Command, args []string) error {
if len(searchOptions.Filters) != 0 {
return errors.Errorf("filters are not applicable to list tags result")
}
+ if report.IsJSON(searchOptions.Format) {
+ listTagsEntries := buildListTagsJson(searchReport)
+ return printJson(listTagsEntries)
+ }
row = "{{.Name}}\t{{.Tag}}\n"
case report.IsJSON(searchOptions.Format):
- prettyJSON, err := json.MarshalIndent(searchReport, "", " ")
- if err != nil {
- return err
- }
- fmt.Println(string(prettyJSON))
- return nil
+ return printJson(searchReport)
case cmd.Flags().Changed("format"):
renderHeaders = parse.HasTable(searchOptions.Format)
row = report.NormalizeFormat(searchOptions.Format)
@@ -180,3 +185,33 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return tmpl.Execute(w, searchReport)
}
+
+func printJson(v interface{}) error {
+ prettyJSON, err := json.MarshalIndent(v, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(prettyJSON))
+ return nil
+}
+
+func buildListTagsJson(searchReport []entities.ImageSearchReport) []listEntryTag {
+ entries := []listEntryTag{}
+
+ReportLoop:
+ for _, report := range searchReport {
+ for idx, entry := range entries {
+ if entry.Name == report.Name {
+ entries[idx].Tags = append(entries[idx].Tags, report.Tag)
+ continue ReportLoop
+ }
+ }
+ newElem := listEntryTag{
+ report.Name,
+ []string{report.Tag},
+ }
+
+ entries = append(entries, newElem)
+ }
+ return entries
+}
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index db7280b1d..1f54db203 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/util"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -130,6 +131,8 @@ func kube(cmd *cobra.Command, args []string) error {
}
}
+ ctrsFailed := 0
+
for _, pod := range report.Pods {
fmt.Printf("Pod:\n")
fmt.Println(pod.ID)
@@ -145,9 +148,21 @@ func kube(cmd *cobra.Command, args []string) error {
for _, ctr := range pod.Containers {
fmt.Println(ctr)
}
+ ctrsFailed += len(pod.ContainerErrors)
+ // If We have errors, add a newline
+ if len(pod.ContainerErrors) > 0 {
+ fmt.Println()
+ }
+ for _, err := range pod.ContainerErrors {
+ fmt.Fprintf(os.Stderr, err+"\n")
+ }
// Empty line for space for next block
fmt.Println()
}
+ if ctrsFailed > 0 {
+ return errors.Errorf("failed to start %d containers", ctrsFailed)
+ }
+
return nil
}
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index 99d324411..a27ab4859 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -191,6 +191,11 @@ func (l ListPodReporter) Labels() map[string]string {
return l.ListPodsReport.Labels
}
+// Networks returns the infra container network names in string format
+func (l ListPodReporter) Networks() string {
+ return strings.Join(l.ListPodsReport.Networks, ",")
+}
+
// NumberOfContainers returns an int representation for
// the number of containers belonging to the pod
func (l ListPodReporter) NumberOfContainers() int {
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 1f613a4c5..0ee530242 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -158,7 +158,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
// Prep the engines
if _, err := registry.NewImageEngine(cmd, args); err != nil {
- return err
+ return errors.Wrapf(err, "Cannot connect to the Podman socket, make sure there is a Podman REST API service running.")
}
if _, err := registry.NewContainerEngine(cmd, args); err != nil {
return err