mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
manifest, push: use source as destination if not specified
`manifest push <source>` must work as-is if `source` is actually a valid path and no destination is provided, `podman` must internally choose `source` as its `destination` just like `podman push` See: https://github.com/containers/podman/blob/main/cmd/podman/images/push.go#L161 Closes: https://github.com/containers/podman/issues/18360 Signed-off-by: Aditya R <arajan@redhat.com>
This commit is contained in:
@ -36,7 +36,7 @@ var (
|
|||||||
Long: "Pushes manifest lists and image indexes to registries.",
|
Long: "Pushes manifest lists and image indexes to registries.",
|
||||||
RunE: push,
|
RunE: push,
|
||||||
Example: `podman manifest push mylist:v1.11 docker://quay.io/myuser/image:v1.11`,
|
Example: `podman manifest push mylist:v1.11 docker://quay.io/myuser/image:v1.11`,
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.RangeArgs(1, 2),
|
||||||
ValidArgsFunction: common.AutocompleteImages,
|
ValidArgsFunction: common.AutocompleteImages,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -114,7 +114,7 @@ func push(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
listImageSpec := args[0]
|
listImageSpec := args[0]
|
||||||
destSpec := args[1]
|
destSpec := args[len(args)-1]
|
||||||
if listImageSpec == "" {
|
if listImageSpec == "" {
|
||||||
return fmt.Errorf(`invalid image name "%s"`, listImageSpec)
|
return fmt.Errorf(`invalid image name "%s"`, listImageSpec)
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ func push(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
manifestPushOpts.SkipTLSVerify = types.NewOptionalBool(manifestPushOpts.Insecure)
|
manifestPushOpts.SkipTLSVerify = types.NewOptionalBool(manifestPushOpts.Insecure)
|
||||||
}
|
}
|
||||||
digest, err := registry.ImageEngine().ManifestPush(registry.Context(), args[0], args[1], manifestPushOpts.ImagePushOptions)
|
digest, err := registry.ImageEngine().ManifestPush(registry.Context(), listImageSpec, destSpec, manifestPushOpts.ImagePushOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ var _ = Describe("Podman manifest", func() {
|
|||||||
f := CurrentGinkgoTestDescription()
|
f := CurrentGinkgoTestDescription()
|
||||||
processTestResult(f)
|
processTestResult(f)
|
||||||
})
|
})
|
||||||
It("create w/o image", func() {
|
It("create w/o image and attempt push w/o dest", func() {
|
||||||
for _, amend := range []string{"--amend", "-a"} {
|
for _, amend := range []string{"--amend", "-a"} {
|
||||||
session := podmanTest.Podman([]string{"manifest", "create", "foo"})
|
session := podmanTest.Podman([]string{"manifest", "create", "foo"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
@ -56,6 +56,13 @@ var _ = Describe("Podman manifest", func() {
|
|||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).To(ExitWithError())
|
Expect(session).To(ExitWithError())
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"manifest", "push", "--all", "foo"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).To(ExitWithError())
|
||||||
|
// Push should actually fail since its not valid registry
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("requested access to the resource is denied"))
|
||||||
|
Expect(session.OutputToString()).To(Not(ContainSubstring("accepts 2 arg(s), received 1")))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"manifest", "create", amend, "foo"})
|
session = podmanTest.Podman([]string{"manifest", "create", amend, "foo"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(Exit(0))
|
Expect(session).Should(Exit(0))
|
||||||
|
@ -313,6 +313,16 @@ var _ = Describe("Podman push", func() {
|
|||||||
push.WaitWithDefaultTimeout()
|
push.WaitWithDefaultTimeout()
|
||||||
Expect(push).Should(Exit(0))
|
Expect(push).Should(Exit(0))
|
||||||
Expect(push.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"))
|
Expect(push.ErrorToString()).To(ContainSubstring("Writing manifest to image destination"))
|
||||||
|
|
||||||
|
// create and push manifest
|
||||||
|
session = podmanTest.Podman([]string{"manifest", "create", "localhost:5000/manifesttest"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"manifest", "push", "--creds=podmantest:test", "--tls-verify=false", "--all", "localhost:5000/manifesttest"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
Expect(session.ErrorToString()).To(ContainSubstring("Writing manifest list to image destination"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman push and encrypt to oci", func() {
|
It("podman push and encrypt to oci", func() {
|
||||||
|
Reference in New Issue
Block a user