From d5b32b0f083a2f6cb5d979a1dc2c34fd26d2beda Mon Sep 17 00:00:00 2001 From: Aditya R Date: Mon, 1 May 2023 14:56:00 +0530 Subject: [PATCH] manifest, push: use source as destination if not specified `manifest push ` must work as-is if source is actually a valid path and no destination is provided, buildah must internally choose source as its destination just like `podman push`. PR is similar to: https://github.com/containers/podman/pull/18395 Signed-off-by: Aditya R --- cmd/buildah/manifest.go | 18 +++++++++--------- tests/push.bats | 4 ++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/buildah/manifest.go b/cmd/buildah/manifest.go index b3a8ad62cbf..233ccf9b5b5 100644 --- a/cmd/buildah/manifest.go +++ b/cmd/buildah/manifest.go @@ -210,7 +210,7 @@ func init() { return manifestPushCmd(cmd, args, manifestPushOpts) }, Example: `buildah manifest push mylist:v1.11 transport:imageName`, - Args: cobra.MinimumNArgs(2), + Args: cobra.MinimumNArgs(1), } manifestPushCommand.SetUsageTemplate(UsageTemplate()) flags = manifestPushCommand.Flags() @@ -830,20 +830,20 @@ func manifestPushCmd(c *cobra.Command, args []string, opts pushOptions) error { case 0: return errors.New("At least a source list ID must be specified") case 1: - return errors.New("Two arguments are necessary to push: source and destination") + listImageSpec = args[0] + destSpec = "docker://"+listImageSpec case 2: listImageSpec = args[0] destSpec = args[1] - if listImageSpec == "" { - return fmt.Errorf(`invalid image name "%s"`, listImageSpec) - } - if destSpec == "" { - return fmt.Errorf(`invalid image name "%s"`, destSpec) - } default: return errors.New("Only two arguments are necessary to push: source and destination") } - + if listImageSpec == "" { + return fmt.Errorf(`invalid image name "%s"`, listImageSpec) + } + if destSpec == "" { + return fmt.Errorf(`invalid image name "%s"`, destSpec) + } store, err := getStore(c) if err != nil { return err diff --git a/tests/push.bats b/tests/push.bats index 73450a59b5a..aaa48dbed43 100644 --- a/tests/push.bats +++ b/tests/push.bats @@ -199,6 +199,10 @@ load helpers run_buildah login --authfile ${TEST_SCRATCH_DIR}/tmp/test.auth --username testuser --password testpassword --tls-verify=false localhost:${REGISTRY_PORT} run_buildah push --authfile ${TEST_SCRATCH_DIR}/tmp/test.auth $WITH_POLICY_JSON --tls-verify=false busybox docker://localhost:${REGISTRY_PORT}/buildah/busybox:latest expect_output --substring "Copying" + + run_buildah manifest create localhost:${REGISTRY_PORT}/testmanifest + run_buildah manifest push --authfile ${TEST_SCRATCH_DIR}/tmp/test.auth $WITH_POLICY_JSON --tls-verify=false localhost:${REGISTRY_PORT}/testmanifest + expect_output --substring "Writing manifest list to image destination" } @test "push with --quiet" {