diff --git a/cmd/buildah/manifest.go b/cmd/buildah/manifest.go index 049f523fbc8..29b276a1a14 100644 --- a/cmd/buildah/manifest.go +++ b/cmd/buildah/manifest.go @@ -432,25 +432,22 @@ func manifestAddCmd(c *cobra.Command, args []string, opts manifestAddOpts) error switch len(args) { case 0, 1: return errors.New("At least a list image and an image or artifact to add must be specified") - case 2: + default: listImageSpec = args[0] if listImageSpec == "" { - return fmt.Errorf(`Invalid image name "%s"`, args[0]) + return fmt.Errorf("Invalid image name %q", args[0]) } if opts.artifact { artifactSpec = args[1:] } else { + if len(args) > 2 { + return errors.New("Too many arguments: expected list and image add to list") + } imageSpec = args[1] if imageSpec == "" { - return fmt.Errorf(`Invalid image name "%s"`, args[1]) + return fmt.Errorf("Invalid image name %q", args[1]) } } - default: - if opts.artifact { - artifactSpec = args[1:] - } else { - return errors.New("Too many arguments: expected list and image add to list") - } } store, err := getStore(c) diff --git a/tests/lists.bats b/tests/lists.bats index d4776073807..8a7e1399230 100644 --- a/tests/lists.bats +++ b/tests/lists.bats @@ -75,6 +75,14 @@ IMAGE_LIST_S390X_INSTANCE_DIGEST=sha256:882a20ee0df7399a445285361d38b711c299ca09 run_buildah manifest rm foo } +@test "manifest-add-multiple-artifacts" { + run_buildah manifest create foo + createrandom $TEST_SCRATCH_DIR/randomfile4 + createrandom $TEST_SCRATCH_DIR/randomfile3 + run_buildah manifest add --artifact foo $TEST_SCRATCH_DIR/randomfile3 $TEST_SCRATCH_DIR/randomfile4 + run_buildah manifest push --all foo oci:$TEST_SCRATCH_DIR/pushed +} + @test "manifest-add local image" { target=scratch-image run_buildah bud $WITH_POLICY_JSON -t ${target} $BUDFILES/from-scratch