summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-01-15 03:49:42 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2021-01-15 13:24:34 -0500
commitcf51c7ed9f955390a0e417f208046e0b8fbadb26 (patch)
treee20cf39ccab111aa9a86745fc9951f0a5f45ecf8 /cmd
parent5a166b297339d547d89fbf14248c3aff129eb960 (diff)
downloadpodman-cf51c7ed9f955390a0e417f208046e0b8fbadb26.tar.gz
podman-cf51c7ed9f955390a0e417f208046e0b8fbadb26.tar.bz2
podman-cf51c7ed9f955390a0e417f208046e0b8fbadb26.zip
Allow podman push to push manifest lists
When doing a podman images, manifests lists look just like images, so it is logical that users would assume that they can just podman push them to a registry. The problem is we throw out weird errors when this happens and users need to somehow figure out this is a manifest list rather then an image, and frankly the user will not understand the difference. This PR will make podman push just do the right thing, by failing over and attempting to push the manifest if it fails to push the image. Fix up handling of manifest push Protocol should bring back a digest string, which can either be printed or stored in a file. We should not reimplement the manifest push setup code in the tunnel code but take advantage of the api path, to make sure remote and local work the same way. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-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)
}