@@ -401,15 +401,32 @@ type decoderWrapper struct {
401
401
}
402
402
403
403
func (decoder * decoderWrapper ) Decode (entry * Manifest2822Entry ) error {
404
+ // reset Architectures and SharedTags so that they can be either inherited or replaced, not additive
405
+ sharedTags := entry .SharedTags
406
+ entry .SharedTags = nil
407
+ arches := entry .Architectures
408
+ entry .Architectures = nil
409
+
404
410
for {
405
411
err := decoder .Decoder .Decode (entry )
406
412
if err != nil {
407
413
return err
408
414
}
415
+
409
416
// ignore empty paragraphs (blank lines at the start, excess blank lines between paragraphs, excess blank lines at EOF)
410
- if len (entry .Paragraph .Order ) > 0 {
411
- return nil
417
+ if len (entry .Paragraph .Order ) == 0 {
418
+ continue
419
+ }
420
+
421
+ // if we had no SharedTags or Architectures, restore our "default" (original) values
422
+ if len (entry .SharedTags ) == 0 {
423
+ entry .SharedTags = sharedTags
424
+ }
425
+ if len (entry .Architectures ) == 0 {
426
+ entry .Architectures = arches
412
427
}
428
+
429
+ return nil
413
430
}
414
431
}
415
432
@@ -442,10 +459,6 @@ func Parse2822(readerIn io.Reader) (*Manifest2822, error) {
442
459
for {
443
460
entry := manifest .Global .Clone ()
444
461
445
- // reset Architectures and SharedTags so that they can be either inherited or replaced, not additive
446
- entry .SharedTags = nil
447
- entry .Architectures = nil
448
-
449
462
err := decoder .Decode (& entry )
450
463
if err == io .EOF {
451
464
break
@@ -454,13 +467,6 @@ func Parse2822(readerIn io.Reader) (*Manifest2822, error) {
454
467
return nil , err
455
468
}
456
469
457
- if len (entry .SharedTags ) == 0 {
458
- entry .SharedTags = manifest .Global .SharedTags
459
- }
460
- if len (entry .Architectures ) == 0 {
461
- entry .Architectures = manifest .Global .Architectures
462
- }
463
-
464
470
if ! GitFetchRegex .MatchString (entry .GitFetch ) {
465
471
return nil , fmt .Errorf (`Tags %q has invalid GitFetch (must be "refs/heads/..." or "refs/tags/..."): %q` , entry .TagsString (), entry .GitFetch )
466
472
}
0 commit comments