fix: 'failed to resolve symlink' error messaging

This error message currently does not provide useful information, because the `src` value that is interleaved will have been overridden by the call to `osi.ResolveSymbolicLink`. This stores the original `src` before the `osi.ResolveSymbolicLink` call so the error message can be useful.

Signed-off-by: June Rhodes <504826+hach-que@users.noreply.github.com>
This commit is contained in:
June Rhodes 2023-03-17 05:12:43 +11:00 committed by GitHub
parent e208c24256
commit 3193650f13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,9 +67,10 @@ func parseMount(osi osinterface.OS, mount *runtime.Mount) (*runtimespec.Mount, e
}
}
var err error
originalSrc := src
src, err = osi.ResolveSymbolicLink(src)
if err != nil {
return nil, fmt.Errorf("failed to resolve symlink %q: %w", src, err)
return nil, fmt.Errorf("failed to resolve symlink '%q' (resolved to '%q'): %w", originalSrc, src, err)
}
// hcsshim requires clean path, especially '/' -> '\'. Additionally,
// for the destination, absolute paths should have the C: prefix.