diff --git a/cmd/buildah/manifest.go b/cmd/buildah/manifest.go index b6360e49549..d8d1cadcb36 100644 --- a/cmd/buildah/manifest.go +++ b/cmd/buildah/manifest.go @@ -111,7 +111,7 @@ func manifestInit() { flags := manifestCreateCommand.Flags() flags.BoolVar(&manifestCreateOpts.all, "all", false, "add all of the lists' images if the images to add are lists") flags.BoolVar(&manifestCreateOpts.amend, "amend", false, "modify an existing list if one with the desired name already exists") - flags.StringSliceVar(&manifestCreateOpts.annotations, "annotation", nil, "set an `annotation` for the image index") + flags.StringArrayVar(&manifestCreateOpts.annotations, "annotation", nil, "set an `annotation` for the image index") flags.StringVar(&manifestCreateOpts.os, "os", "", "if any of the specified images is a list, choose the one for `os`") if err := flags.MarkHidden("os"); err != nil { panic(fmt.Sprintf("error marking --os as hidden: %v", err)) @@ -213,7 +213,7 @@ func manifestInit() { flags.StringVar(&manifestAnnotateOpts.osVersion, "os-version", "", "override the os `version` of the specified image") flags.StringSliceVar(&manifestAnnotateOpts.features, "features", nil, "override the `features` of the specified image") flags.StringSliceVar(&manifestAnnotateOpts.osFeatures, "os-features", nil, "override the os `features` of the specified image") - flags.StringSliceVar(&manifestAnnotateOpts.annotations, "annotation", nil, "set an `annotation` for the specified image") + flags.StringArrayVar(&manifestAnnotateOpts.annotations, "annotation", nil, "set an `annotation` for the specified image") flags.StringVar(&manifestAnnotateOpts.subject, "subject", "", "set a subject for the image index") manifestAnnotateCommand.SetUsageTemplate(UsageTemplate()) manifestCommand.AddCommand(manifestAnnotateCommand) diff --git a/tests/lists.bats b/tests/lists.bats index feccaf7e223..1c2e7c23e40 100644 --- a/tests/lists.bats +++ b/tests/lists.bats @@ -21,10 +21,11 @@ IMAGE_LIST_S390X_INSTANCE_DIGEST=sha256:882a20ee0df7399a445285361d38b711c299ca09 assert "$output" =~ "that name is already in use" run_buildah manifest create --amend foo assert "$output" == "$listid" - run_buildah manifest create --amend --annotation red=blue foo busybox + run_buildah manifest create --amend --annotation red=blue --annotation green=yellow,orange,purple foo busybox assert "$output" == "$listid" run_buildah manifest inspect foo assert "$output" =~ '"red": "blue"' + assert "$output" =~ '"green": "yellow,orange,purple"' assert "$output" =~ "${imagedigest}" # since manifest exists in local storage this should exit with `0` run_buildah manifest exists foo @@ -60,10 +61,11 @@ IMAGE_LIST_S390X_INSTANCE_DIGEST=sha256:882a20ee0df7399a445285361d38b711c299ca09 digest="${output##* }" alg="${digest%%:*}" encoded="${digest##*:}" - run_buildah manifest annotate --annotation red=blue foo $TEST_SCRATCH_DIR/randomfile + run_buildah manifest annotate --annotation red=blue --annotation green=yellow,orange,purple foo $TEST_SCRATCH_DIR/randomfile run_buildah manifest inspect foo assert "$output" =~ '"image/png"' assert "$output" =~ '"red": "blue"' + assert "$output" =~ '"green": "yellow,orange,purple"' run_buildah manifest push --all foo oci:$TEST_SCRATCH_DIR/pushed run cmp $TEST_SCRATCH_DIR/randomfile $TEST_SCRATCH_DIR/pushed/blobs/sha256/$blobencoded assert "$status" -eq 0 "pushed copy of random file did not match original" @@ -120,9 +122,10 @@ IMAGE_LIST_S390X_INSTANCE_DIGEST=sha256:882a20ee0df7399a445285361d38b711c299ca09 _prefetch busybox run_buildah manifest create foo run_buildah manifest add foo busybox - run_buildah manifest annotate --index --annotation red=blue foo + run_buildah manifest annotate --index --annotation red=blue --annotation green=yellow,orange,purple foo run_buildah manifest inspect foo assert "$output" =~ '"red": "blue"' + assert "$output" =~ '"green": "yellow,orange,purple"' } @test "manifest-annotate instance annotation" { @@ -130,7 +133,7 @@ IMAGE_LIST_S390X_INSTANCE_DIGEST=sha256:882a20ee0df7399a445285361d38b711c299ca09 run_buildah manifest create foo run_buildah manifest add foo busybox instance="${output##* }" - run_buildah manifest annotate --annotation red=blue foo "${instance}" + run_buildah manifest annotate --annotation red=blue --annotation green=yellow,orange,purple foo "${instance}" run_buildah manifest annotate --os OperatingSystem foo "${instance}" run_buildah manifest annotate --arch aRCHITECTURE foo "${instance}" run_buildah manifest annotate --variant vARIANT foo "${instance}" @@ -138,6 +141,7 @@ IMAGE_LIST_S390X_INSTANCE_DIGEST=sha256:882a20ee0df7399a445285361d38b711c299ca09 run_buildah manifest annotate --os-features OSFEATURE1 --os-features OSFEATURE2 foo "${instance}" run_buildah manifest inspect foo assert "$output" =~ '"red": "blue"' + assert "$output" =~ '"green": "yellow,orange,purple"' assert "$output" =~ '"os": "OperatingSystem"' assert "$output" =~ '"architecture": "aRCHITECTURE"' assert "$output" =~ '"variant": "vARIANT"'