@@ -398,7 +398,7 @@ type yamlArchive struct {
398398 Version string `yaml:"version"`
399399 Suites []string `yaml:"suites"`
400400 Components []string `yaml:"components"`
401- Priority int `yaml:"priority"`
401+ Priority * int `yaml:"priority"`
402402 Default bool `yaml:"default"`
403403 PubKeys []string `yaml:"public-keys"`
404404}
@@ -542,6 +542,7 @@ func parseRelease(baseDir, filePath string, data []byte) (*Release, error) {
542542 // not being used, we will revert back to the default archive behaviour.
543543 hasPriority := false
544544 var defaultArchive string
545+ var archiveNoPriority string
545546 for archiveName , details := range yamlVar .Archives {
546547 if details .Version == "" {
547548 return nil , fmt .Errorf ("%s: archive %q missing version field" , fileName , archiveName )
@@ -572,18 +573,28 @@ func parseRelease(baseDir, filePath string, data []byte) (*Release, error) {
572573 }
573574 archiveKeys = append (archiveKeys , key )
574575 }
575- if details .Priority > MaxArchivePriority || details .Priority < MinArchivePriority {
576- return nil , fmt .Errorf ("%s: archive %q has invalid priority value of %d" , fileName , archiveName , details .Priority )
577- }
578- if details .Priority != 0 {
576+ priority := 0
577+ if details .Priority != nil {
579578 hasPriority = true
579+ if archiveNoPriority != "" {
580+ return nil , fmt .Errorf ("%s: archive %q missing priority" , fileName , archiveNoPriority )
581+ }
582+ priority = * details .Priority
583+ if priority > MaxArchivePriority || priority < MinArchivePriority {
584+ return nil , fmt .Errorf ("%s: archive %q has invalid priority value of %d" , fileName , archiveName , priority )
585+ }
586+ } else {
587+ if hasPriority {
588+ return nil , fmt .Errorf ("%s: archive %q missing priority" , fileName , archiveName )
589+ }
590+ archiveNoPriority = archiveName
580591 }
581592 release .Archives [archiveName ] = & Archive {
582593 Name : archiveName ,
583594 Version : details .Version ,
584595 Suites : details .Suites ,
585596 Components : details .Components ,
586- Priority : details . Priority ,
597+ Priority : priority ,
587598 PubKeys : archiveKeys ,
588599 }
589600 }
0 commit comments