Don't ignore containerfiles outside of build context

[NO NEW TESTS NEEDED]

Signed-off-by: Aleksei Kosyrev <albnnc@gmail.com>
This commit is contained in:
Aleksei Kosyrev 2023-10-06 16:00:13 +03:00
parent d36c90868f
commit 3fdb6ee2df
1 changed files with 13 additions and 9 deletions

View File

@ -695,6 +695,9 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
} }
name = filepath.ToSlash(path) name = filepath.ToSlash(path)
} }
// If name is absolute path, then it has to be containerfile outside of build context.
// If not, we should check it for being excluded via pattern matcher.
if !filepath.IsAbs(name) {
excluded, err := pm.Matches(name) //nolint:staticcheck excluded, err := pm.Matches(name) //nolint:staticcheck
if err != nil { if err != nil {
return fmt.Errorf("checking if %q is excluded: %w", name, err) return fmt.Errorf("checking if %q is excluded: %w", name, err)
@ -705,6 +708,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
// are required to visit all files. :( // are required to visit all files. :(
return nil return nil
} }
}
switch { switch {
case dentry.Type().IsRegular(): // add file item case dentry.Type().IsRegular(): // add file item
info, err := dentry.Info() info, err := dentry.Info()