@@ -18,7 +18,7 @@ const (
1818 devfile = "devfile.yaml"
1919 devfileHidden = ".devfile.yaml"
2020 extraDevfileEntries = "extraDevfileEntries.yaml"
21- stackYaml = "stack.yaml"
21+ stackYaml = "stack.yaml"
2222)
2323
2424// MissingArchError is an error if the architecture list is empty
@@ -103,7 +103,7 @@ func validateIndexComponent(indexComponent schema.Schema, componentType schema.D
103103 if version .Links == nil || len (version .Links ) == 0 {
104104 return fmt .Errorf ("index component version %s: links are empty" , version .Version )
105105 }
106- if version .Resources == nil || len (version .Resources ) == 0 {
106+ if version .Resources == nil || len (version .Resources ) == 0 {
107107 return fmt .Errorf ("index component version %s: resources are empty" , version .Version )
108108 }
109109 if version .Default {
@@ -119,7 +119,7 @@ func validateIndexComponent(indexComponent schema.Schema, componentType schema.D
119119 }
120120 }
121121 } else if componentType == schema .SampleDevfileType {
122- if indexComponent .Versions != nil && len (indexComponent .Versions ) > 0 {
122+ if indexComponent .Versions != nil && len (indexComponent .Versions ) > 0 {
123123 defaultFound := false
124124 for _ , version := range indexComponent .Versions {
125125 if version .Version == "" {
@@ -176,8 +176,8 @@ func fileExists(filepath string) bool {
176176
177177func dirExists (dirpath string ) error {
178178 dir , err := os .Stat (dirpath )
179- if os .IsNotExist (err ){
180- return fmt .Errorf ("path: %s does not exist: %w" ,dirpath , err )
179+ if os .IsNotExist (err ) {
180+ return fmt .Errorf ("path: %s does not exist: %w" , dirpath , err )
181181 }
182182 if ! dir .IsDir () {
183183 return fmt .Errorf ("%s is not a directory" , dirpath )
@@ -213,7 +213,7 @@ func parseDevfileRegistry(registryDirPath string, force bool) ([]schema.Schema,
213213 }
214214 }
215215
216- i := 0
216+ i := 0
217217 for i < len (indexComponent .Versions ) {
218218 versionComponent := indexComponent .Versions [i ]
219219 if versionComponent .Git != nil {
@@ -231,6 +231,14 @@ func parseDevfileRegistry(registryDirPath string, force bool) ([]schema.Schema,
231231 indexComponent .Versions [i ] = versionComponent
232232 i ++
233233 }
234+
235+ for _ , version := range indexComponent .Versions {
236+ // if a particular version supports all architectures, the top architecture List should be empty (support all) as well
237+ if version .Architectures == nil || len (version .Architectures ) == 0 {
238+ indexComponent .Architectures = nil
239+ break
240+ }
241+ }
234242 } else { // if stack.yaml not exist, old stack repo struct, directly lookfor & parse devfile.yaml
235243 versionComponent := schema.Version {}
236244 err := parseStackDevfile (stackFolderPath , stackFolderDir .Name (), force , & versionComponent , & indexComponent )
@@ -276,7 +284,7 @@ func parseStackDevfile(devfileDirPath string, stackName string, force bool, vers
276284
277285 if ! force {
278286 // Devfile validation
279- devfileObj ,_ , err := devfileParser .ParseDevfileAndValidate (parser.ParserArgs {Path : devfilePath })
287+ devfileObj , _ , err := devfileParser .ParseDevfileAndValidate (parser.ParserArgs {Path : devfilePath })
280288 if err != nil {
281289 return fmt .Errorf ("%s devfile is not valid: %v" , devfileDirPath , err )
282290 }
@@ -292,7 +300,6 @@ func parseStackDevfile(devfileDirPath string, stackName string, force bool, vers
292300 return fmt .Errorf ("failed to read %s: %v" , devfilePath , err )
293301 }
294302
295-
296303 var devfile schema.Devfile
297304 err = yaml .Unmarshal (bytes , & devfile )
298305 if err != nil {
@@ -412,7 +419,7 @@ func parseExtraDevfileEntries(registryDirPath string, force bool) ([]schema.Sche
412419 // Can't handle during registry build since we don't have access to devfile library/parser
413420 if indexComponent .Type == schema .SampleDevfileType && validateSamples {
414421 if indexComponent .Versions != nil && len (indexComponent .Versions ) > 0 {
415- for _ , version := range indexComponent .Versions {
422+ for _ , version := range indexComponent .Versions {
416423 sampleVersonDirPath := filepath .Join (samplesDir , devfileEntry .Name , version .Version )
417424 devfilePath := filepath .Join (sampleVersonDirPath , "devfile.yaml" )
418425 _ , err := os .Stat (filepath .Join (devfilePath ))
@@ -497,7 +504,7 @@ func checkForRequiredMetadata(devfileObj parser.DevfileObj) []error {
497504 return metadataErrors
498505}
499506
500- func validateStackInfo (stackInfo schema.Schema , stackfolderDir string ) []error {
507+ func validateStackInfo (stackInfo schema.Schema , stackfolderDir string ) []error {
501508 var errors []error
502509
503510 if stackInfo .Name == "" {
@@ -537,7 +544,6 @@ func validateStackInfo (stackInfo schema.Schema, stackfolderDir string) []error
537544 return errors
538545}
539546
540-
541547// In checks if the value is in the array
542548func inArray (arr []string , value string ) bool {
543549 for _ , item := range arr {
@@ -546,4 +552,4 @@ func inArray(arr []string, value string) bool {
546552 }
547553 }
548554 return false
549- }
555+ }
0 commit comments