@@ -14,6 +14,7 @@ import (
14
14
"github.com/containers/podman/v5/utils"
15
15
. "github.com/onsi/ginkgo/v2"
16
16
. "github.com/onsi/gomega"
17
+ imgspec "github.com/opencontainers/image-spec/specs-go/v1"
17
18
)
18
19
19
20
const (
@@ -99,8 +100,12 @@ var _ = Describe("Podman artifact", func() {
99
100
It ("podman artifact add with options" , func () {
100
101
yamlType := "text/yaml"
101
102
artifact1Name := "localhost/test/artifact1"
103
+ artifact2Name := "localhost/test/artifact2"
104
+ artifact3Name := "localhost/test/artifact3"
102
105
artifact1File , err := createArtifactFile (1024 )
103
106
Expect (err ).ToNot (HaveOccurred ())
107
+ artifact2File , err := createArtifactFile (1024 )
108
+ Expect (err ).ToNot (HaveOccurred ())
104
109
105
110
artifactType := "octet/foobar"
106
111
annotation1 := "color=blue"
@@ -115,9 +120,26 @@ var _ = Describe("Podman artifact", func() {
115
120
Expect (a .Manifest .Layers [0 ].Annotations ["flavor" ]).To (Equal ("lemon" ))
116
121
Expect (a .Manifest .Layers [0 ].MediaType ).To (Equal (yamlType ))
117
122
118
- failSession := podmanTest .Podman ([]string {"artifact" , "add" , "--annotation" , "org.opencontainers.image.title=foobar" , "foobar" , artifact1File })
123
+ title := RandomString (12 )
124
+ annotation3 := fmt .Sprintf ("%s=%s" , imgspec .AnnotationTitle , title )
125
+ podmanTest .PodmanExitCleanly ("artifact" , "add" , "--annotation" , annotation3 , artifact2Name , artifact1File )
126
+ a = podmanTest .InspectArtifact (artifact2Name )
127
+ Expect (a .Manifest .Layers [0 ].Annotations [imgspec .AnnotationTitle ]).To (Equal (title ))
128
+
129
+ failSession := podmanTest .Podman ([]string {"artifact" , "add" , "--append" , "--annotation" , annotation3 , artifact2Name , artifact2File })
119
130
failSession .WaitWithDefaultTimeout ()
120
- Expect (failSession ).Should (ExitWithError (125 , "Error: cannot override filename with org.opencontainers.image.title annotation" ))
131
+ Expect (failSession ).Should (ExitWithError (125 , "Error: duplicate layers org.opencontainers.image.title labels within an artifact not allowed" ))
132
+
133
+ title = RandomString (12 )
134
+ annotation3 = fmt .Sprintf ("%s=%s" , imgspec .AnnotationTitle , title )
135
+ podmanTest .PodmanExitCleanly ("artifact" , "add" , "--append" , "--annotation" , annotation3 , artifact2Name , artifact2File )
136
+ a = podmanTest .InspectArtifact (artifact2Name )
137
+ Expect (a .Manifest .Layers [1 ].Annotations [imgspec .AnnotationTitle ]).To (Equal (title ))
138
+
139
+ failSession = podmanTest .Podman ([]string {"artifact" , "add" , "--annotation" , annotation3 , artifact3Name , artifact1File , artifact2File })
140
+ failSession .WaitWithDefaultTimeout ()
141
+ Expect (failSession ).Should (ExitWithError (125 , "Error: duplicate layers org.opencontainers.image.title labels within an artifact not allowed" ))
142
+
121
143
})
122
144
123
145
It ("podman artifact add multiple" , func () {
@@ -480,9 +502,9 @@ var _ = Describe("Podman artifact", func() {
480
502
Expect (a .Manifest .Layers ).To (HaveLen (3 ))
481
503
482
504
for _ , l := range a .Manifest .Layers {
483
- layersNames [l .Annotations ["org.opencontainers.image.title" ]] += 1
505
+ layersNames [l.Annotations [imgspec. AnnotationTitle ]] += 1
484
506
485
- if l .Annotations ["org.opencontainers.image.title" ] == filepath .Base (artifact3File ) {
507
+ if l .Annotations [imgspec . AnnotationTitle ] == filepath .Base (artifact3File ) {
486
508
Expect (l .Annotations ["color" ]).To (Equal ("blue" ))
487
509
} else {
488
510
Expect (l .Annotations ).To (HaveLen (1 ))
0 commit comments