Skip to content

Commit 66e7aa3

Browse files
committed
Exclude OWNERS files when pulling devfile stack
1 parent 1821103 commit 66e7aa3

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

registry-library/library/library.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func PullStackByMediaTypesFromRegistry(registry string, stack string, allowedMed
329329
// Decompress archive.tar
330330
archivePath := filepath.Join(destDir, "archive.tar")
331331
if _, err := os.Stat(archivePath); err == nil {
332-
err := decompress(destDir, archivePath)
332+
err := decompress(destDir, archivePath, []string{"OWNERS"})
333333
if err != nil {
334334
return err
335335
}
@@ -349,7 +349,7 @@ func PullStackFromRegistry(registry string, stack string, destDir string, option
349349
}
350350

351351
// decompress extracts the archive file
352-
func decompress(targetDir string, tarFile string) error {
352+
func decompress(targetDir string, tarFile string, excludeFiles []string) error {
353353
reader, err := os.Open(tarFile)
354354
if err != nil {
355355
return err
@@ -370,6 +370,9 @@ func decompress(targetDir string, tarFile string) error {
370370
} else if err != nil {
371371
return err
372372
}
373+
if isExcluded(header.Name, excludeFiles) {
374+
continue
375+
}
373376

374377
target := path.Join(targetDir, header.Name)
375378
switch header.Typeflag {
@@ -396,6 +399,16 @@ func decompress(targetDir string, tarFile string) error {
396399
return nil
397400
}
398401

402+
func isExcluded(name string, excludeFiles []string) bool {
403+
basename := filepath.Base(name)
404+
for _, excludeFile := range excludeFiles {
405+
if basename == excludeFile {
406+
return true
407+
}
408+
}
409+
return false
410+
}
411+
399412
//setHeaders sets the request headers
400413
func setHeaders(headers *http.Header, options RegistryOptions) {
401414
t := options.Telemetry

0 commit comments

Comments
 (0)