aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create.go1
-rw-r--r--cmd/podman/common/create_opts.go7
-rw-r--r--cmd/podman/common/createparse.go1
-rw-r--r--cmd/podman/containers/attach.go1
-rw-r--r--cmd/podman/containers/ps.go16
-rw-r--r--cmd/podman/containers/restore.go1
-rw-r--r--cmd/podman/containers/wait.go1
-rw-r--r--cmd/podman/generate/systemd.go1
-rw-r--r--cmd/podman/images/build.go75
-rw-r--r--cmd/podman/images/list.go1
-rw-r--r--cmd/podman/images/prune.go1
-rw-r--r--cmd/podman/images/pull.go2
-rw-r--r--cmd/podman/images/search.go10
-rw-r--r--cmd/podman/images/trust_show.go1
-rw-r--r--cmd/podman/networks/create.go1
-rw-r--r--cmd/podman/networks/inspect.go1
-rw-r--r--cmd/podman/networks/list.go1
-rw-r--r--cmd/podman/play/kube.go1
-rw-r--r--cmd/podman/pods/inspect.go1
-rw-r--r--cmd/podman/root.go2
-rw-r--r--cmd/podman/shell_completion_test.go4
-rw-r--r--cmd/podman/system/df.go1
-rw-r--r--cmd/podman/system/prune.go1
-rw-r--r--cmd/podman/system/renumber.go1
24 files changed, 93 insertions, 40 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 915ff63b6..3ea1a40d0 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -796,5 +796,4 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
"Configure cgroup v2 (key=value)",
)
_ = cmd.RegisterFlagCompletionFunc(cgroupConfFlagName, completion.AutocompleteNone)
-
}
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index d86a6d364..5fcbda0ce 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -222,7 +222,11 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
// publish
for port, pbs := range cc.HostConfig.PortBindings {
for _, pb := range pbs {
- hostport, err := strconv.Atoi(pb.HostPort)
+ var hostport int
+ var err error
+ if pb.HostPort != "" {
+ hostport, err = strconv.Atoi(pb.HostPort)
+ }
if err != nil {
return nil, nil, err
}
@@ -268,7 +272,6 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup
endpointsConfig := cc.NetworkingConfig.EndpointsConfig
cniNetworks := make([]string, 0, len(endpointsConfig))
for netName, endpoint := range endpointsConfig {
-
cniNetworks = append(cniNetworks, netName)
if endpoint == nil {
diff --git a/cmd/podman/common/createparse.go b/cmd/podman/common/createparse.go
index 3a69f11b6..140518cf7 100644
--- a/cmd/podman/common/createparse.go
+++ b/cmd/podman/common/createparse.go
@@ -26,5 +26,4 @@ func (c *ContainerCLIOpts) validate() error {
return errors.Errorf("invalid image-volume type %q. Pick one of bind, tmpfs, or ignore", c.ImageVolume)
}
return nil
-
}
diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go
index f00c5378b..7c7d780bc 100644
--- a/cmd/podman/containers/attach.go
+++ b/cmd/podman/containers/attach.go
@@ -68,7 +68,6 @@ func init() {
})
attachFlags(containerAttachCommand)
validate.AddLatestFlag(containerAttachCommand, &attachOpts.Latest)
-
}
func attach(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 23baca70f..0c6cbab42 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -22,6 +22,7 @@ import (
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/docker/go-units"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -253,12 +254,12 @@ func ps(cmd *cobra.Command, _ []string) error {
// responses will grow to the largest number of processes reported on, but will not thrash the gc
var responses []psReporter
for ; ; responses = responses[:0] {
- if ctnrs, err := getResponses(); err != nil {
+ ctnrs, err := getResponses()
+ if err != nil {
return err
- } else {
- for _, r := range ctnrs {
- responses = append(responses, psReporter{r})
- }
+ }
+ for _, r := range ctnrs {
+ responses = append(responses, psReporter{r})
}
tm.Clear()
@@ -392,6 +393,11 @@ func (l psReporter) Command() string {
// Size returns the rootfs and virtual sizes in human duration in
// and output form (string) suitable for ps
func (l psReporter) Size() string {
+ if l.ListContainer.Size == nil {
+ logrus.Errorf("Size format requires --size option")
+ return ""
+ }
+
virt := units.HumanSizeWithPrecision(float64(l.ListContainer.Size.RootFsSize), 3)
s := units.HumanSizeWithPrecision(float64(l.ListContainer.Size.RwSize), 3)
return fmt.Sprintf("%s (virtual %s)", s, virt)
diff --git a/cmd/podman/containers/restore.go b/cmd/podman/containers/restore.go
index 49c0be88e..61bd84219 100644
--- a/cmd/podman/containers/restore.go
+++ b/cmd/podman/containers/restore.go
@@ -118,5 +118,4 @@ func restore(_ *cobra.Command, args []string) error {
}
}
return errs.PrintErrors()
-
}
diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go
index 7a531b98a..7831ef1c9 100644
--- a/cmd/podman/containers/wait.go
+++ b/cmd/podman/containers/wait.go
@@ -56,7 +56,6 @@ func waitFlags(cmd *cobra.Command) {
conditionFlagName := "condition"
flags.StringVar(&waitCondition, conditionFlagName, "stopped", "Condition to wait on")
_ = cmd.RegisterFlagCompletionFunc(conditionFlagName, common.AutocompleteWaitCondition)
-
}
func init() {
diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go
index f9099d3b8..7b2d9ebb7 100644
--- a/cmd/podman/generate/systemd.go
+++ b/cmd/podman/generate/systemd.go
@@ -128,7 +128,6 @@ func systemd(cmd *cobra.Command, args []string) error {
default:
return errors.Errorf("unknown --format argument: %s", format)
}
-
}
func printDefault(units map[string]string) error {
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index a35fea442..abd3ced5b 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -1,9 +1,11 @@
package images
import (
+ "io"
"os"
"path/filepath"
"strings"
+ "time"
"github.com/containers/buildah"
"github.com/containers/buildah/imagebuildah"
@@ -11,6 +13,8 @@ import (
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
+ encconfig "github.com/containers/ocicrypt/config"
+ enchelpers "github.com/containers/ocicrypt/helpers"
"github.com/containers/podman/v2/cmd/podman/common"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
@@ -78,7 +82,8 @@ func useLayers() string {
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+
Command: buildCmd,
})
buildFlags(buildCmd)
@@ -151,8 +156,21 @@ func buildFlags(cmd *cobra.Command) {
// Add the completion functions
fromAndBudFlagsCompletions := buildahCLI.GetFromAndBudFlagsCompletions()
completion.CompleteCommandFlags(cmd, fromAndBudFlagsCompletions)
- _ = flags.MarkHidden("signature-policy")
flags.SetNormalizeFunc(buildahCLI.AliasFlags)
+ if registry.IsRemote() {
+ flag = flags.Lookup("isolation")
+ buildOpts.Isolation = buildah.OCI
+ if err := flag.Value.Set(buildah.OCI); err != nil {
+ logrus.Errorf("unable to set --isolation to %v: %v", buildah.OCI, err)
+ }
+ flag.DefValue = buildah.OCI
+ _ = flags.MarkHidden("disable-content-trust")
+ _ = flags.MarkHidden("cache-from")
+ _ = flags.MarkHidden("sign-by")
+ _ = flags.MarkHidden("signature-policy")
+ _ = flags.MarkHidden("tls-verify")
+ _ = flags.MarkHidden("compress")
+ }
}
// build executes the build command.
@@ -246,7 +264,18 @@ func build(cmd *cobra.Command, args []string) error {
return err
}
- _, err = registry.ImageEngine().Build(registry.GetContext(), containerFiles, *apiBuildOpts)
+ report, err := registry.ImageEngine().Build(registry.GetContext(), containerFiles, *apiBuildOpts)
+
+ if cmd.Flag("iidfile").Changed {
+ f, err := os.Create(buildOpts.Iidfile)
+ if err != nil {
+ return err
+ }
+ if _, err := f.WriteString("sha256:" + report.ID); err != nil {
+ return err
+ }
+ }
+
return err
}
@@ -308,6 +337,10 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
flags.Layers = false
}
+ var stdin io.Reader
+ if flags.Stdin {
+ stdin = os.Stdin
+ }
var stdout, stderr, reporter *os.File
stdout = os.Stdout
stderr = os.Stderr
@@ -402,10 +435,21 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
}
+ imageOS, arch, err := parse.PlatformFromOptions(c)
+ if err != nil {
+ return nil, err
+ }
+
+ decConfig, err := getDecryptConfig(flags.DecryptionKeys)
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to obtain decrypt config")
+ }
+
opts := imagebuildah.BuildOptions{
AddCapabilities: flags.CapAdd,
AdditionalTags: tags,
Annotations: flags.Annotation,
+ Architecture: arch,
Args: args,
BlobDirectory: flags.BlobCache,
CNIConfigDir: flags.CNIConfigDir,
@@ -433,17 +477,25 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
DropCapabilities: flags.CapDrop,
Err: stderr,
ForceRmIntermediateCtrs: flags.ForceRm,
+ From: flags.From,
IDMappingOptions: idmappingOptions,
- IIDFile: flags.Iidfile,
+ In: stdin,
Isolation: isolation,
+ Jobs: &flags.Jobs,
Labels: flags.Label,
Layers: flags.Layers,
+ LogRusage: flags.LogRusage,
+ Manifest: flags.Manifest,
+ MaxPullPushRetries: 3,
NamespaceOptions: nsValues,
NoCache: flags.NoCache,
+ OS: imageOS,
+ OciDecryptConfig: decConfig,
Out: stdout,
Output: output,
OutputFormat: format,
PullPolicy: pullPolicy,
+ PullPushRetryDelay: 2 * time.Second,
Quiet: flags.Quiet,
RemoveIntermediateCtrs: flags.Rm,
ReportWriter: reporter,
@@ -459,3 +511,18 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
return &entities.BuildOptions{BuildOptions: opts}, nil
}
+
+func getDecryptConfig(decryptionKeys []string) (*encconfig.DecryptConfig, error) {
+ decConfig := &encconfig.DecryptConfig{}
+ if len(decryptionKeys) > 0 {
+ // decryption
+ dcc, err := enchelpers.CreateCryptoConfig([]string{}, decryptionKeys)
+ if err != nil {
+ return nil, errors.Wrapf(err, "invalid decryption keys")
+ }
+ cc := encconfig.CombineCryptoConfigs([]encconfig.CryptoConfig{dcc})
+ decConfig = cc.DecryptConfig
+ }
+
+ return decConfig, nil
+}
diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go
index 8a7951923..65486e3ba 100644
--- a/cmd/podman/images/list.go
+++ b/cmd/podman/images/list.go
@@ -275,7 +275,6 @@ func tokenRepoTag(ref string) (string, string, error) {
}
return name, tag, nil
-
}
func sortFunc(key string, data []imageReporter) func(i, j int) bool {
diff --git a/cmd/podman/images/prune.go b/cmd/podman/images/prune.go
index 268a68681..8ded8d352 100644
--- a/cmd/podman/images/prune.go
+++ b/cmd/podman/images/prune.go
@@ -48,7 +48,6 @@ func init() {
flags.StringArrayVar(&filter, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')")
//TODO: add completion for filters
_ = pruneCmd.RegisterFlagCompletionFunc(filterFlagName, completion.AutocompleteNone)
-
}
func prune(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/images/pull.go b/cmd/podman/images/pull.go
index fe92baebe..3b2595757 100644
--- a/cmd/podman/images/pull.go
+++ b/cmd/podman/images/pull.go
@@ -110,11 +110,9 @@ func pullFlags(cmd *cobra.Command) {
_ = cmd.RegisterFlagCompletionFunc(authfileFlagName, completion.AutocompleteDefault)
if !registry.IsRemote() {
-
certDirFlagName := "cert-dir"
flags.StringVar(&pullOptions.CertDir, certDirFlagName, "", "`Pathname` of a directory containing TLS certificates and keys")
_ = cmd.RegisterFlagCompletionFunc(certDirFlagName, completion.AutocompleteDefault)
-
}
_ = flags.MarkHidden("signature-policy")
}
diff --git a/cmd/podman/images/search.go b/cmd/podman/images/search.go
index c8ea4b04a..b8274cfce 100644
--- a/cmd/podman/images/search.go
+++ b/cmd/podman/images/search.go
@@ -156,12 +156,12 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return errors.Errorf("filters are not applicable to list tags result")
}
if report.IsJSON(searchOptions.Format) {
- listTagsEntries := buildListTagsJson(searchReport)
- return printJson(listTagsEntries)
+ listTagsEntries := buildListTagsJSON(searchReport)
+ return printArbitraryJSON(listTagsEntries)
}
row = "{{.Name}}\t{{.Tag}}\n"
case report.IsJSON(searchOptions.Format):
- return printJson(searchReport)
+ return printArbitraryJSON(searchReport)
case cmd.Flags().Changed("format"):
renderHeaders = parse.HasTable(searchOptions.Format)
row = report.NormalizeFormat(searchOptions.Format)
@@ -186,7 +186,7 @@ func imageSearch(cmd *cobra.Command, args []string) error {
return tmpl.Execute(w, searchReport)
}
-func printJson(v interface{}) error {
+func printArbitraryJSON(v interface{}) error {
prettyJSON, err := json.MarshalIndent(v, "", " ")
if err != nil {
return err
@@ -195,7 +195,7 @@ func printJson(v interface{}) error {
return nil
}
-func buildListTagsJson(searchReport []entities.ImageSearchReport) []listEntryTag {
+func buildListTagsJSON(searchReport []entities.ImageSearchReport) []listEntryTag {
entries := []listEntryTag{}
ReportLoop:
diff --git a/cmd/podman/images/trust_show.go b/cmd/podman/images/trust_show.go
index dc35dc6a1..89733a1aa 100644
--- a/cmd/podman/images/trust_show.go
+++ b/cmd/podman/images/trust_show.go
@@ -42,7 +42,6 @@ func init() {
_ = showFlags.MarkHidden("policypath")
showFlags.StringVar(&showTrustOptions.RegistryPath, "registrypath", "", "")
_ = showFlags.MarkHidden("registrypath")
-
}
func showTrust(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go
index 1a091f111..d1cbe253f 100644
--- a/cmd/podman/networks/create.go
+++ b/cmd/podman/networks/create.go
@@ -80,7 +80,6 @@ func init() {
Parent: networkCmd,
})
networkCreateFlags(networkCreateCommand)
-
}
func networkCreate(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/networks/inspect.go b/cmd/podman/networks/inspect.go
index 671b0265f..bd9f76ea9 100644
--- a/cmd/podman/networks/inspect.go
+++ b/cmd/podman/networks/inspect.go
@@ -39,5 +39,4 @@ func init() {
func networkInspect(_ *cobra.Command, args []string) error {
inspectOpts.Type = inspect.NetworkType
return inspect.Inspect(args, *inspectOpts)
-
}
diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go
index 16ae980dc..6f63e97cc 100644
--- a/cmd/podman/networks/list.go
+++ b/cmd/podman/networks/list.go
@@ -51,7 +51,6 @@ func networkListFlags(flags *pflag.FlagSet) {
filterFlagName := "filter"
flags.StringArrayVarP(&filters, filterFlagName, "f", nil, "Provide filter values (e.g. 'name=podman')")
_ = networklistCommand.RegisterFlagCompletionFunc(filterFlagName, common.AutocompleteNetworkFilters)
-
}
func init() {
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index 4c44fa30f..511e208cf 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -77,7 +77,6 @@ func init() {
_ = kubeCmd.RegisterFlagCompletionFunc(authfileFlagName, completion.AutocompleteDefault)
if !registry.IsRemote() {
-
certDirFlagName := "cert-dir"
flags.StringVar(&kubeOptions.CertDir, certDirFlagName, "", "`Pathname` of a directory containing TLS certificates and keys")
_ = kubeCmd.RegisterFlagCompletionFunc(certDirFlagName, completion.AutocompleteDefault)
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index e809be0c9..0fbb730ce 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -50,7 +50,6 @@ func init() {
}
func inspect(cmd *cobra.Command, args []string) error {
-
if len(args) < 1 && !inspectOptions.Latest {
return errors.Errorf("you must provide the name or id of a running pod")
}
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 0ee530242..1f613a4c5 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 errors.Wrapf(err, "Cannot connect to the Podman socket, make sure there is a Podman REST API service running.")
+ return err
}
if _, err := registry.NewContainerEngine(cmd, args); err != nil {
return err
diff --git a/cmd/podman/shell_completion_test.go b/cmd/podman/shell_completion_test.go
index d2b500b09..3f6f56fbe 100644
--- a/cmd/podman/shell_completion_test.go
+++ b/cmd/podman/shell_completion_test.go
@@ -26,14 +26,11 @@ import (
)
func TestShellCompletionFunctions(t *testing.T) {
-
rootCmd := parseCommands()
checkCommand(t, rootCmd)
-
}
func checkCommand(t *testing.T, cmd *cobra.Command) {
-
if cmd.HasSubCommands() {
for _, childCmd := range cmd.Commands() {
checkCommand(t, childCmd)
@@ -46,7 +43,6 @@ func checkCommand(t *testing.T, cmd *cobra.Command) {
// loop over all local flags
cmd.LocalFlags().VisitAll(func(flag *pflag.Flag) {
-
// an error means that there is a completion function for this flag
err := cmd.RegisterFlagCompletionFunc(flag.Name, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveDefault
diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go
index a9eab24bb..68b244e35 100644
--- a/cmd/podman/system/df.go
+++ b/cmd/podman/system/df.go
@@ -50,7 +50,6 @@ func init() {
formatFlagName := "format"
flags.StringVar(&dfOptions.Format, formatFlagName, "", "Pretty-print images using a Go template")
_ = dfSystemCommand.RegisterFlagCompletionFunc(formatFlagName, completion.AutocompleteNone)
-
}
func df(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go
index 5e96a654a..7ec08366e 100644
--- a/cmd/podman/system/prune.go
+++ b/cmd/podman/system/prune.go
@@ -51,7 +51,6 @@ func init() {
filterFlagName := "filter"
flags.StringArrayVar(&filters, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')")
_ = pruneCommand.RegisterFlagCompletionFunc(filterFlagName, completion.AutocompleteNone)
-
}
func prune(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/system/renumber.go b/cmd/podman/system/renumber.go
index b1683395f..37f9a5865 100644
--- a/cmd/podman/system/renumber.go
+++ b/cmd/podman/system/renumber.go
@@ -39,7 +39,6 @@ func init() {
Command: renumberCommand,
Parent: systemCmd,
})
-
}
func renumber(cmd *cobra.Command, args []string) {
// Shutdown all running engines, `renumber` will hijack all methods