Skip to content

Commit

Permalink
fix: tag the image in push rock
Browse files Browse the repository at this point in the history
  • Loading branch information
vpa1977 committed Oct 7, 2024
1 parent ddc6daa commit 333835a
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void pushRock(RockProjectSettings settings, RockcraftOptions optio
String imageVersion = String.valueOf(rockcraft.get(IRockcraftNames.ROCKCRAFT_VERSION));
Path rockDestPath = settings.getRockOutput().resolve(IRockcraftNames.ROCK_OUTPUT);
for (File file : rockDestPath.toFile().listFiles((dir, file) -> file.endsWith(".rock"))) {
copyInDocker(file, imageName);
copyInDocker(file, imageName, imageVersion);
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public static void buildRock(RockProjectSettings settings, RockcraftOptions opti
}
}

private static void copyInDocker(File ociImage, String imageName) throws IOException, InterruptedException {
private static void copyInDocker(File ociImage, String imageName, String imageVersion) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder("rockcraft.skopeo",
"copy",
String.format("oci-archive:%s", ociImage.getAbsolutePath()),
Expand All @@ -106,6 +106,15 @@ private static void copyInDocker(File ociImage, String imageName) throws IOExcep
Process process = pb.start();
int result = process.waitFor();
if (result != 0)
throw new UnsupportedOperationException("Failed to copy " + ociImage.getAbsolutePath() + " to docker image " + imageName);
throw new UnsupportedOperationException("Failed to copy " + ociImage.getAbsolutePath() + " to docker image " + String.format("%s:latest", imageName));

pb = new ProcessBuilder("docker", "tag", imageName,
String.format("%s:%s", imageName, imageVersion))
.directory(ociImage.getParentFile())
.inheritIO();
process = pb.start();
result = process.waitFor();
if (result != 0)
throw new UnsupportedOperationException("Failed to tag " + String.format("%s:%s", imageName, imageVersion));
}
}

0 comments on commit 333835a

Please sign in to comment.