cli: podman manifest add --annotation use StringArray()

This option accepts arbitrary input so we should allow commas in it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2023-12-08 18:18:24 +01:00
parent 3e10a68328
commit d8c3e5b3c1
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
2 changed files with 3 additions and 3 deletions

View File

@ -48,7 +48,7 @@ func init() {
flags.BoolVar(&manifestAddOpts.All, "all", false, "add all of the list's images if the image is a list")
annotationFlagName := "annotation"
flags.StringSliceVar(&manifestAddOpts.Annotation, annotationFlagName, nil, "set an `annotation` for the specified image")
flags.StringArrayVar(&manifestAddOpts.Annotation, annotationFlagName, nil, "set an `annotation` for the specified image")
_ = addCmd.RegisterFlagCompletionFunc(annotationFlagName, completion.AutocompleteNone)
archFlagName := "arch"

View File

@ -314,7 +314,7 @@ add_compression = ["zstd"]`), 0o644)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(125))
Expect(session.ErrorToString()).To(ContainSubstring("no value given for annotation"))
session = podmanTest.Podman([]string{"manifest", "add", "--annotation", "hoge=fuga", "foo", imageList})
session = podmanTest.Podman([]string{"manifest", "add", "--annotation", "hoge=fuga", "--annotation", "key=val,withcomma", "foo", imageList})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
session = podmanTest.Podman([]string{"manifest", "inspect", "foo"})
@ -324,7 +324,7 @@ add_compression = ["zstd"]`), 0o644)
var inspect define.ManifestListData
err := json.Unmarshal(session.Out.Contents(), &inspect)
Expect(err).ToNot(HaveOccurred())
Expect(inspect.Manifests[0].Annotations).To(Equal(map[string]string{"hoge": "fuga"}))
Expect(inspect.Manifests[0].Annotations).To(Equal(map[string]string{"hoge": "fuga", "key": "val,withcomma"}))
})
It("add --os", func() {