summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-17 06:52:35 -0500
committerGitHub <noreply@github.com>2021-01-17 06:52:35 -0500
commit341c4b1fd94dda26be5ce588490e3d7284a54dbb (patch)
tree82f8c6bfa113b8b350aa069e81436b88bddf3080 /cmd/podman
parent73b036db566a8f3606f0b376728efe03fcf8685d (diff)
parentcf51c7ed9f955390a0e417f208046e0b8fbadb26 (diff)
downloadpodman-341c4b1fd94dda26be5ce588490e3d7284a54dbb.tar.gz
podman-341c4b1fd94dda26be5ce588490e3d7284a54dbb.tar.bz2
podman-341c4b1fd94dda26be5ce588490e3d7284a54dbb.zip
Merge pull request #8942 from rhatdan/push
Allow podman push to push manifest lists
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/images/push.go2
-rw-r--r--cmd/podman/manifest/push.go19
-rw-r--r--cmd/podman/utils/alias.go2
3 files changed, 19 insertions, 4 deletions
diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go
index d82083cd8..d53a9c066 100644
--- a/cmd/podman/images/push.go
+++ b/cmd/podman/images/push.go
@@ -75,6 +75,8 @@ func init() {
func pushFlags(cmd *cobra.Command) {
flags := cmd.Flags()
+ // For now default All flag to true, for pushing of manifest lists
+ pushOptions.All = true
authfileFlagName := "authfile"
flags.StringVar(&pushOptions.Authfile, authfileFlagName, auth.GetDefaultAuthFile(), "Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
_ = cmd.RegisterFlagCompletionFunc(authfileFlagName, completion.AutocompleteDefault)
diff --git a/cmd/podman/manifest/push.go b/cmd/podman/manifest/push.go
index 96fea4a21..40b45c40e 100644
--- a/cmd/podman/manifest/push.go
+++ b/cmd/podman/manifest/push.go
@@ -1,11 +1,14 @@
package manifest
import (
+ "io/ioutil"
+
"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
"github.com/containers/image/v5/types"
"github.com/containers/podman/v2/cmd/podman/common"
"github.com/containers/podman/v2/cmd/podman/registry"
+ "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"
@@ -15,7 +18,7 @@ import (
// manifestPushOptsWrapper wraps entities.ManifestPushOptions and prevents leaking
// CLI-only fields into the API types.
type manifestPushOptsWrapper struct {
- entities.ManifestPushOptions
+ entities.ImagePushOptions
TLSVerifyCLI bool // CLI only
CredentialsCLI string
@@ -41,8 +44,8 @@ func init() {
Parent: manifestCmd,
})
flags := pushCmd.Flags()
- flags.BoolVar(&manifestPushOpts.Purge, "purge", false, "remove the manifest list if push succeeds")
- flags.BoolVar(&manifestPushOpts.All, "all", false, "also push the images in the list")
+ flags.BoolVar(&manifestPushOpts.Rm, "rm", false, "remove the manifest list if push succeeds")
+ flags.BoolVar(&manifestPushOpts.All, "all", true, "also push the images in the list")
authfileFlagName := "authfile"
flags.StringVar(&manifestPushOpts.Authfile, authfileFlagName, auth.GetDefaultAuthFile(), "path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override")
@@ -72,6 +75,7 @@ func init() {
flags.BoolVar(&manifestPushOpts.TLSVerifyCLI, "tls-verify", true, "require HTTPS and verify certificates when accessing the registry")
flags.BoolVarP(&manifestPushOpts.Quiet, "quiet", "q", false, "don't output progress information when pushing lists")
+ flags.SetNormalizeFunc(utils.AliasFlags)
if registry.IsRemote() {
_ = flags.MarkHidden("cert-dir")
@@ -107,8 +111,15 @@ func push(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("tls-verify") {
manifestPushOpts.SkipTLSVerify = types.NewOptionalBool(!manifestPushOpts.TLSVerifyCLI)
}
- if err := registry.ImageEngine().ManifestPush(registry.Context(), args[0], args[1], manifestPushOpts.ManifestPushOptions); err != nil {
+ digest, err := registry.ImageEngine().ManifestPush(registry.Context(), args[0], args[1], manifestPushOpts.ImagePushOptions)
+ if err != nil {
return err
}
+ if manifestPushOpts.DigestFile != "" {
+ if err := ioutil.WriteFile(manifestPushOpts.DigestFile, []byte(digest), 0644); err != nil {
+ return err
+ }
+ }
+
return nil
}
diff --git a/cmd/podman/utils/alias.go b/cmd/podman/utils/alias.go
index 10b96fa98..469233b59 100644
--- a/cmd/podman/utils/alias.go
+++ b/cmd/podman/utils/alias.go
@@ -23,6 +23,8 @@ func AliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
name = "ns"
case "storage":
name = "external"
+ case "purge":
+ name = "rm"
}
return pflag.NormalizedName(name)
}