@@ -14,6 +14,7 @@ import (
1414 "github.com/containers/podman/v5/utils"
1515 . "github.com/onsi/ginkgo/v2"
1616 . "github.com/onsi/gomega"
17+ imgspec "github.com/opencontainers/image-spec/specs-go/v1"
1718)
1819
1920const (
@@ -99,7 +100,10 @@ var _ = Describe("Podman artifact", func() {
99100 It ("podman artifact add with options" , func () {
100101 yamlType := "text/yaml"
101102 artifact1Name := "localhost/test/artifact1"
103+ artifact2Name := "localhost/test/artifact2"
104+ artifact3Name := "localhost/test/artifact3"
102105 artifact1File , err := createArtifactFile (1024 )
106+ artifact2File , err := createArtifactFile (1024 )
103107 Expect (err ).ToNot (HaveOccurred ())
104108
105109 artifactType := "octet/foobar"
@@ -115,9 +119,26 @@ var _ = Describe("Podman artifact", func() {
115119 Expect (a .Manifest .Layers [0 ].Annotations ["flavor" ]).To (Equal ("lemon" ))
116120 Expect (a .Manifest .Layers [0 ].MediaType ).To (Equal (yamlType ))
117121
118- failSession := podmanTest .Podman ([]string {"artifact" , "add" , "--annotation" , "org.opencontainers.image.title=foobar" , "foobar" , artifact1File })
122+ title := RandomString (12 )
123+ annotation3 := fmt .Sprintf ("%s=%s" , imgspec .AnnotationTitle , title )
124+ podmanTest .PodmanExitCleanly ("artifact" , "add" , "--annotation" , annotation3 , artifact2Name , artifact1File )
125+ a = podmanTest .InspectArtifact (artifact2Name )
126+ Expect (a .Manifest .Layers [0 ].Annotations [imgspec .AnnotationTitle ]).To (Equal (title ))
127+
128+ failSession := podmanTest .Podman ([]string {"artifact" , "add" , "--append" , "--annotation" , annotation3 , artifact2Name , artifact2File })
119129 failSession .WaitWithDefaultTimeout ()
120- Expect (failSession ).Should (ExitWithError (125 , "Error: cannot override filename with org.opencontainers.image.title annotation" ))
130+ Expect (failSession ).Should (ExitWithError (125 , "Error: duplicate layers org.opencontainers.image.title labels within an artifact not allowed" ))
131+
132+ title = RandomString (12 )
133+ annotation3 = fmt .Sprintf ("%s=%s" , imgspec .AnnotationTitle , title )
134+ podmanTest .PodmanExitCleanly ("artifact" , "add" , "--append" , "--annotation" , annotation3 , artifact2Name , artifact2File )
135+ a = podmanTest .InspectArtifact (artifact2Name )
136+ Expect (a .Manifest .Layers [1 ].Annotations [imgspec .AnnotationTitle ]).To (Equal (title ))
137+
138+ failSession = podmanTest .Podman ([]string {"artifact" , "add" , "--annotation" , annotation3 , artifact3Name , artifact1File , artifact2File })
139+ failSession .WaitWithDefaultTimeout ()
140+ Expect (failSession ).Should (ExitWithError (125 , "Error: duplicate layers org.opencontainers.image.title labels within an artifact not allowed" ))
141+
121142 })
122143
123144 It ("podman artifact add multiple" , func () {
@@ -480,9 +501,9 @@ var _ = Describe("Podman artifact", func() {
480501 Expect (a .Manifest .Layers ).To (HaveLen (3 ))
481502
482503 for _ , l := range a .Manifest .Layers {
483- layersNames [l .Annotations ["org.opencontainers.image.title" ]] += 1
504+ layersNames [l.Annotations [imgspec. AnnotationTitle ]] += 1
484505
485- if l .Annotations ["org.opencontainers.image.title" ] == filepath .Base (artifact3File ) {
506+ if l .Annotations [imgspec . AnnotationTitle ] == filepath .Base (artifact3File ) {
486507 Expect (l .Annotations ["color" ]).To (Equal ("blue" ))
487508 } else {
488509 Expect (l .Annotations ).To (HaveLen (1 ))
0 commit comments