Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create parent directories for imageDigestOutputPath, imageIdOutputPath and imageJsonOutputPath #4208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,17 @@ public JibContainer runBuild()

// when an image is built, write out the digest and id
if (imageDigestOutputPath != null) {
createParentDirectories(imageDigestOutputPath);
String imageDigest = jibContainer.getDigest().toString();
Files.write(imageDigestOutputPath, imageDigest.getBytes(StandardCharsets.UTF_8));
}
if (imageIdOutputPath != null) {
createParentDirectories(imageIdOutputPath);
String imageId = jibContainer.getImageId().toString();
Files.write(imageIdOutputPath, imageId.getBytes(StandardCharsets.UTF_8));
}
if (imageJsonOutputPath != null) {
createParentDirectories(imageJsonOutputPath);
ImageMetadataOutput metadataOutput = ImageMetadataOutput.fromJibContainer(jibContainer);
String imageJson = metadataOutput.toJson();
Files.write(imageJsonOutputPath, imageJson.getBytes(StandardCharsets.UTF_8));
Expand Down Expand Up @@ -326,4 +329,11 @@ public JibBuildRunner writeImageJson(@Nullable Path imageJsonOutputPath) {
this.imageJsonOutputPath = imageJsonOutputPath;
return this;
}

private static void createParentDirectories(Path filePath) throws IOException {
Path parent = filePath.getParent();
if (parent != null)
Files.createDirectories(parent);
}

}