@@ -1092,7 +1092,7 @@ func Test_goArchToArchitectureLabel(t *testing.T) {
10921092 }
10931093}
10941094
1095- func Test_Build_mergeDefaultLabelsAndAnnotations (t * testing.T ) {
1095+ func Test_Build_processLabelsAndAnnotations (t * testing.T ) {
10961096 g := NewWithT (t )
10971097
10981098 t .Run ("should add default labels and annotations with provided values" , func (t * testing.T ) {
@@ -1104,15 +1104,15 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
11041104 },
11051105 }
11061106
1107- labels , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1107+ err := c .processLabelsAndAnnotations ()
11081108 g .Expect (err ).ToNot (HaveOccurred ())
11091109
1110- g .Expect (labels ).To (Equal ([]string {
1110+ g .Expect (c . mergedLabels ).To (Equal ([]string {
11111111 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
11121112 "org.opencontainers.image.source=https://github.com/org/repo" ,
11131113 "org.opencontainers.image.revision=abc123" ,
11141114 }))
1115- g .Expect (annotations ).To (Equal ([]string {
1115+ g .Expect (c . mergedAnnotations ).To (Equal ([]string {
11161116 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
11171117 "org.opencontainers.image.source=https://github.com/org/repo" ,
11181118 "org.opencontainers.image.revision=abc123" ,
@@ -1124,15 +1124,15 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
11241124 Params : & BuildParams {},
11251125 }
11261126
1127- labels , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1127+ err := c .processLabelsAndAnnotations ()
11281128 g .Expect (err ).ToNot (HaveOccurred ())
11291129
1130- g .Expect (labels ).To (ConsistOf (
1130+ g .Expect (c . mergedLabels ).To (ConsistOf (
11311131 MatchRegexp (`^org.opencontainers.image.created=.+Z$` ),
11321132 ))
1133- g .Expect (annotations ).To (Equal (labels ))
1133+ g .Expect (c . mergedAnnotations ).To (Equal (c . mergedLabels ))
11341134
1135- imageCreated := labels [0 ]
1135+ imageCreated := c . mergedLabels [0 ]
11361136
11371137 _ , rfc3339time , _ := strings .Cut (imageCreated , "=" )
11381138 timestamp , err := time .Parse (time .RFC3339 , rfc3339time )
@@ -1158,17 +1158,17 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
11581158 },
11591159 }
11601160
1161- labels , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1161+ err := c .processLabelsAndAnnotations ()
11621162 g .Expect (err ).ToNot (HaveOccurred ())
11631163
1164- g .Expect (labels ).To (Equal ([]string {
1164+ g .Expect (c . mergedLabels ).To (Equal ([]string {
11651165 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
11661166 "org.opencontainers.image.source=https://github.com/org/repo" ,
11671167 "org.opencontainers.image.revision=abc123" ,
11681168 "some-label=foo" ,
11691169 "org.opencontainers.image.revision=main" ,
11701170 }))
1171- g .Expect (annotations ).To (Equal ([]string {
1171+ g .Expect (c . mergedAnnotations ).To (Equal ([]string {
11721172 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
11731173 "org.opencontainers.image.source=https://github.com/org/repo" ,
11741174 "org.opencontainers.image.revision=abc123" ,
@@ -1188,11 +1188,11 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
11881188 },
11891189 }
11901190
1191- labels , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1191+ err := c .processLabelsAndAnnotations ()
11921192 g .Expect (err ).ToNot (HaveOccurred ())
11931193
11941194 arch := goArchToArchitectureLabel (runtime .GOARCH )
1195- g .Expect (labels ).To (Equal ([]string {
1195+ g .Expect (c . mergedLabels ).To (Equal ([]string {
11961196 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
11971197 "org.opencontainers.image.source=https://github.com/org/repo" ,
11981198 "org.opencontainers.image.revision=abc123" ,
@@ -1203,7 +1203,7 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
12031203 "vcs-type=git" ,
12041204 }))
12051205 // Should be added *only* as labels, not as annotations
1206- g .Expect (annotations ).To (Equal ([]string {
1206+ g .Expect (c . mergedAnnotations ).To (Equal ([]string {
12071207 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
12081208 "org.opencontainers.image.source=https://github.com/org/repo" ,
12091209 "org.opencontainers.image.revision=abc123" ,
@@ -1218,14 +1218,14 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
12181218 },
12191219 }
12201220
1221- labels , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1221+ err := c .processLabelsAndAnnotations ()
12221222 g .Expect (err ).ToNot (HaveOccurred ())
12231223
1224- g .Expect (labels ).To (ContainElements (
1224+ g .Expect (c . mergedLabels ).To (ContainElements (
12251225 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
12261226 "build-date=2026-01-01T00:00:00Z" ,
12271227 ))
1228- g .Expect (annotations ).To (ContainElements (
1228+ g .Expect (c . mergedAnnotations ).To (ContainElements (
12291229 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
12301230 ))
12311231 })
@@ -1237,11 +1237,11 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
12371237 },
12381238 }
12391239
1240- labels , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1240+ err := c .processLabelsAndAnnotations ()
12411241 g .Expect (err ).ToNot (HaveOccurred ())
12421242
1243- g .Expect (labels ).To (ContainElement ("quay.expires-after=2w" ))
1244- g .Expect (annotations ).ToNot (ContainElement ("quay.expires-after=2w" ))
1243+ g .Expect (c . mergedLabels ).To (ContainElement ("quay.expires-after=2w" ))
1244+ g .Expect (c . mergedAnnotations ).ToNot (ContainElement ("quay.expires-after=2w" ))
12451245 })
12461246
12471247 t .Run ("should return error for invalid legacy-build-timestamp" , func (t * testing.T ) {
@@ -1251,7 +1251,7 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
12511251 },
12521252 }
12531253
1254- _ , _ , err := c .mergeDefaultLabelsAndAnnotations ()
1254+ err := c .processLabelsAndAnnotations ()
12551255 g .Expect (err ).To (HaveOccurred ())
12561256 g .Expect (err .Error ()).To (ContainSubstring ("determining build timestamp: parsing legacy-build-timestamp:" ))
12571257 })
@@ -1263,7 +1263,7 @@ func Test_Build_mergeDefaultLabelsAndAnnotations(t *testing.T) {
12631263 },
12641264 }
12651265
1266- _ , _ , err := c .mergeDefaultLabelsAndAnnotations ()
1266+ err := c .processLabelsAndAnnotations ()
12671267 g .Expect (err ).To (HaveOccurred ())
12681268 g .Expect (err .Error ()).To (ContainSubstring ("determining build timestamp: parsing source-date-epoch:" ))
12691269 })
@@ -1289,9 +1289,9 @@ with.hash.char=this comment # is not a comment
12891289 },
12901290 }
12911291
1292- _ , annotations , err := c .mergeDefaultLabelsAndAnnotations ()
1292+ err := c .processLabelsAndAnnotations ()
12931293 g .Expect (err ).ToNot (HaveOccurred ())
1294- g .Expect (annotations ).To (Equal ([]string {
1294+ g .Expect (c . mergedAnnotations ).To (Equal ([]string {
12951295 // always added
12961296 "org.opencontainers.image.created=2026-01-01T00:00:00Z" ,
12971297 // from file, sorted alphabetically
@@ -1308,7 +1308,7 @@ with.hash.char=this comment # is not a comment
13081308 },
13091309 }
13101310
1311- _ , _ , err := c .mergeDefaultLabelsAndAnnotations ()
1311+ err := c .processLabelsAndAnnotations ()
13121312 g .Expect (err ).To (HaveOccurred ())
13131313 g .Expect (err .Error ()).To (MatchRegexp ("parsing annotations file: .* /nonexistent/annotations.cfg" ))
13141314 })
@@ -1325,7 +1325,7 @@ with.hash.char=this comment # is not a comment
13251325 },
13261326 }
13271327
1328- _ , _ , err := c .mergeDefaultLabelsAndAnnotations ()
1328+ err := c .processLabelsAndAnnotations ()
13291329 g .Expect (err ).To (HaveOccurred ())
13301330 g .Expect (err .Error ()).To (MatchRegexp ("parsing annotations file: .*annotations.cfg:1: expected arg=value" ))
13311331 })
0 commit comments