Skip to content

Commit

Permalink
Strip off preceding '.' from layer header names if present.
Browse files Browse the repository at this point in the history
- Some images (e.g. VMware photon) have file headers in the format
  ./etc/... rather than /etc/...
  • Loading branch information
robdimsdale authored and sophiewigmore committed Sep 12, 2023
1 parent 1790df8 commit 0b5e3c6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/ihop/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ func findFile(image v1.Image, filepath string) (*tar.Header, io.Reader, error) {
return nil, nil, err
}

if strings.TrimPrefix(hdr.Name, "/") == strings.TrimPrefix(filepath, "/") {
// Some images have filepaths with a preceding '.'
// e.g. './etc/...' instead of '/etc/...'
// Strip it off if it exists
headerName := strings.TrimPrefix(hdr.Name, ".")

if strings.TrimPrefix(headerName, "/") == strings.TrimPrefix(filepath, "/") {
found = true
if hdr.Typeflag == tar.TypeSymlink {
header, reader, err = findFile(image, path.Join(path.Dir(filepath), hdr.Linkname))
Expand Down

0 comments on commit 0b5e3c6

Please # to comment.