directory resolver should join path and target directory for retrieving contents

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza
2020-07-15 09:59:40 -04:00
parent 429c28720c
commit 2f626bf9fd
2 changed files with 49 additions and 7 deletions
+8 -1
View File
@@ -74,7 +74,14 @@ func (s DirectoryResolver) FilesByGlob(patterns ...string) ([]file.Reference, er
func (s DirectoryResolver) MultipleFileContentsByRef(f ...file.Reference) (map[file.Reference]string, error) {
refContents := make(map[file.Reference]string)
for _, fileRef := range f {
contents, err := fileContents(fileRef.Path)
resolvedPath := path.Join(s.Path, string(fileRef.Path))
_, err := os.Stat(resolvedPath)
if os.IsNotExist(err) {
continue
} else if err != nil {
log.Errorf("path (%s) is not valid: %v", resolvedPath, err)
}
contents, err := fileContents(file.Path(resolvedPath))
if err != nil {
return refContents, fmt.Errorf("could not read contents of file: %s", fileRef.Path)
}