@@ -47,13 +47,16 @@ const (
4747 DevfilePNGLogoMediaType = "image/png"
4848 DevfileArchiveMediaType = "application/x-tar"
4949
50+ OwnersFile = "OWNERS"
51+
5052 httpRequestTimeout = 30 * time .Second // httpRequestTimeout configures timeout of all HTTP requests
5153 responseHeaderTimeout = 30 * time .Second // responseHeaderTimeout is the timeout to retrieve the server's response headers
5254)
5355
5456var (
5557 DevfileMediaTypeList = []string {DevfileMediaType }
5658 DevfileAllMediaTypesList = []string {DevfileMediaType , DevfilePNGLogoMediaType , DevfileSVGLogoMediaType , DevfileVSXMediaType , DevfileArchiveMediaType }
59+ ExcludedFiles = []string {OwnersFile }
5760)
5861
5962type Registry struct {
@@ -237,7 +240,8 @@ func PrintRegistry(registryURLs string, devfileType string, options RegistryOpti
237240 return nil
238241}
239242
240- // PullStackByMediaTypesFromRegistry pulls a specified stack with allowed media types from a given registry URL to the destination directory
243+ // PullStackByMediaTypesFromRegistry pulls a specified stack with allowed media types from a given registry URL to the destination directory.
244+ // OWNERS files present in the registry will be excluded
241245func PullStackByMediaTypesFromRegistry (registry string , stack string , allowedMediaTypes []string , destDir string , options RegistryOptions ) error {
242246 var requestVersion string
243247 if strings .Contains (stack , ":" ) {
@@ -329,7 +333,7 @@ func PullStackByMediaTypesFromRegistry(registry string, stack string, allowedMed
329333 // Decompress archive.tar
330334 archivePath := filepath .Join (destDir , "archive.tar" )
331335 if _ , err := os .Stat (archivePath ); err == nil {
332- err := decompress (destDir , archivePath )
336+ err := decompress (destDir , archivePath , ExcludedFiles )
333337 if err != nil {
334338 return err
335339 }
@@ -349,7 +353,7 @@ func PullStackFromRegistry(registry string, stack string, destDir string, option
349353}
350354
351355// decompress extracts the archive file
352- func decompress (targetDir string , tarFile string ) error {
356+ func decompress (targetDir string , tarFile string , excludeFiles [] string ) error {
353357 reader , err := os .Open (tarFile )
354358 if err != nil {
355359 return err
@@ -370,6 +374,9 @@ func decompress(targetDir string, tarFile string) error {
370374 } else if err != nil {
371375 return err
372376 }
377+ if isExcluded (header .Name , excludeFiles ) {
378+ continue
379+ }
373380
374381 target := path .Join (targetDir , header .Name )
375382 switch header .Typeflag {
@@ -396,6 +403,16 @@ func decompress(targetDir string, tarFile string) error {
396403 return nil
397404}
398405
406+ func isExcluded (name string , excludeFiles []string ) bool {
407+ basename := filepath .Base (name )
408+ for _ , excludeFile := range excludeFiles {
409+ if basename == excludeFile {
410+ return true
411+ }
412+ }
413+ return false
414+ }
415+
399416//setHeaders sets the request headers
400417func setHeaders (headers * http.Header , options RegistryOptions ) {
401418 t := options .Telemetry
0 commit comments