@@ -376,6 +376,41 @@ type InitConfigData struct {
376
376
ConfigVariant string `json:"coreos-assembler.config-variant"`
377
377
}
378
378
379
+ func getStreamAndOsVersionFromManifest () (string , string , error ) {
380
+ // Look for the right manifest, taking into account the variant
381
+ var manifest ManifestData
382
+ var pathToManifest string
383
+ pathToInitConfig := filepath .Join (Options .CosaWorkdir , "src/config.json" )
384
+ initConfigFile , err := os .ReadFile (pathToInitConfig )
385
+ if os .IsNotExist (err ) {
386
+ // No variant config found. Let's read the default manifest
387
+ pathToManifest = filepath .Join (Options .CosaWorkdir , "src/config/manifest.yaml" )
388
+ } else if err != nil {
389
+ // Unexpected error
390
+ return "" , "" , err
391
+ } else {
392
+ // Figure out the variant and read the corresponding manifests
393
+ var initConfig InitConfigData
394
+ err = json .Unmarshal (initConfigFile , & initConfig )
395
+ if err != nil {
396
+ return "" , "" , err
397
+ }
398
+ pathToManifest = filepath .Join (Options .CosaWorkdir , fmt .Sprintf ("src/config/manifest-%s.yaml" , initConfig .ConfigVariant ))
399
+ }
400
+ manifestFile , err := os .ReadFile (pathToManifest )
401
+ if err != nil {
402
+ return "" , "" , err
403
+ }
404
+ err = yaml .Unmarshal (manifestFile , & manifest )
405
+ if err != nil {
406
+ return "" , "" , err
407
+ }
408
+
409
+ stream := manifest .Variables .Stream
410
+ osversion := manifest .Variables .OsVersion
411
+ return stream , osversion , nil
412
+ }
413
+
379
414
func ParseDenyListYaml (pltfrm string ) error {
380
415
var objs []DenyListObj
381
416
@@ -401,37 +436,10 @@ func ParseDenyListYaml(pltfrm string) error {
401
436
402
437
// Get the stream and osversion variables from the manifest since DenylistStream is not specified
403
438
if len (DenylistStream ) == 0 {
404
- // Look for the right manifest, taking into account the variant
405
- var manifest ManifestData
406
- var pathToManifest string
407
- pathToInitConfig := filepath .Join (Options .CosaWorkdir , "src/config.json" )
408
- initConfigFile , err := os .ReadFile (pathToInitConfig )
409
- if os .IsNotExist (err ) {
410
- // No variant config found. Let's read the default manifest
411
- pathToManifest = filepath .Join (Options .CosaWorkdir , "src/config/manifest.yaml" )
412
- } else if err != nil {
413
- // Unexpected error
414
- return err
415
- } else {
416
- // Figure out the variant and read the corresponding manifests
417
- var initConfig InitConfigData
418
- err = json .Unmarshal (initConfigFile , & initConfig )
419
- if err != nil {
420
- return err
421
- }
422
- pathToManifest = filepath .Join (Options .CosaWorkdir , fmt .Sprintf ("src/config/manifest-%s.yaml" , initConfig .ConfigVariant ))
423
- }
424
- manifestFile , err := os .ReadFile (pathToManifest )
425
- if err != nil {
426
- return err
427
- }
428
- err = yaml .Unmarshal (manifestFile , & manifest )
439
+ stream , osversion , err = getStreamAndOsVersionFromManifest ()
429
440
if err != nil {
430
441
return err
431
442
}
432
-
433
- stream = manifest .Variables .Stream
434
- osversion = manifest .Variables .OsVersion
435
443
} else {
436
444
stream = DenylistStream
437
445
}
0 commit comments