Open briandealwis opened 4 years ago
Reproducible with java -jar cram-xxx.jar --docker gcr.io/distroless/static image target
where target
is a directory. This causes target
to be placed in /
. Specifying target:/path
works as /path
's parent is not null.
I don't think there's any harm in having an explicit entry for /
, is there? Maybe we can just go with the quick fix you suggested.
Lets not generate this entry: /
for now.
Adding a directory into "/" was the first thing I tried. It would be nice if this worked.
Environment:
Description of the issue:
Seeing NPEs when using jib-core to create a layer with content placed at "/":
The code in question: https://github.com/GoogleContainerTools/jib/blob/a692b8b0cde1f982f6e28309dd08ca80460950e2/jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java#L73-L76
The layer configurations had been built with
LayerConfiguration.Builder.addEntryRecursive()
In this case,
tarEntryPath.getName()
is/
(the root directory).namePath
is asun.nio.fs.UnixPath
on "/" with filesystem of typesun.nio.fs.MacOSXFileSystem
. ButnamePath.getParent()
returnsnull
, which adheres to the contract ofPath#getParent()
: Returns the parent path, ornull
if this path does not have a parent.So an obvious fix is to change this guard to
But should we be adding a tar entry for the root directory?