/** * Tags the image referenced by {@code originalImageReference} with a new image reference {@code * newImageReference}. * * @param originalImageReference the existing image reference on the Docker daemon * @param newImageReference the new image reference * @see <a * href="https://docs.docker.com/engine/reference/commandline/tag/">https://docs.docker.com/engine/reference/commandline/tag/</a> * @throws InterruptedException if the 'docker tag' process is interrupted. * @throws IOException if an I/O exception occurs or {@code docker tag} failed */ public void tag(ImageReference originalImageReference, ImageReference newImageReference) throws IOException, InterruptedException { // Runs 'docker tag'. Process dockerProcess = docker("tag", originalImageReference.toString(), newImageReference.toString()); if (dockerProcess.waitFor() != 0) { try (InputStreamReader stderr = new InputStreamReader(dockerProcess.getErrorStream(), StandardCharsets.UTF_8)) { throw new IOException( "'docker tag' command failed with error: " + CharStreams.toString(stderr)); } } }
private static String buildMessageWithTargetImageReferences( ImageReference targetImageReference, Set<String> additionalTags, String prefix, String suffix) { StringJoiner successMessageBuilder = new StringJoiner(", ", prefix, suffix); successMessageBuilder.add(colorCyan(targetImageReference.toString())); for (String tag : additionalTags) { successMessageBuilder.add(colorCyan(targetImageReference.withTag(tag).toString())); } return successMessageBuilder.toString(); }
private static String buildMessageWithTargetImageReferences( ImageReference targetImageReference, Set<String> additionalTags, String prefix, String suffix) { StringJoiner successMessageBuilder = new StringJoiner(", ", prefix, suffix); successMessageBuilder.add(colorCyan(targetImageReference.toString())); for (String tag : additionalTags) { successMessageBuilder.add(colorCyan(targetImageReference.withTag(tag).toString())); } return successMessageBuilder.toString(); }
/** * Tags the image referenced by {@code originalImageReference} with a new image reference {@code * newImageReference}. * * @param originalImageReference the existing image reference on the Docker daemon * @param newImageReference the new image reference * @see <a * href="https://docs.docker.com/engine/reference/commandline/tag/">https://docs.docker.com/engine/reference/commandline/tag/</a> * @throws InterruptedException if the 'docker tag' process is interrupted. * @throws IOException if an I/O exception occurs or {@code docker tag} failed */ public void tag(ImageReference originalImageReference, ImageReference newImageReference) throws IOException, InterruptedException { // Runs 'docker tag'. Process dockerProcess = docker("tag", originalImageReference.toString(), newImageReference.toString()); if (dockerProcess.waitFor() != 0) { try (InputStreamReader stderr = new InputStreamReader(dockerProcess.getErrorStream(), StandardCharsets.UTF_8)) { throw new IOException( "'docker tag' command failed with error: " + CharStreams.toString(stderr)); } } }
/** * Tags the image referenced by {@code originalImageReference} with a new image reference {@code * newImageReference}. * * @param originalImageReference the existing image reference on the Docker daemon * @param newImageReference the new image reference * @see <a * href="https://docs.docker.com/engine/reference/commandline/tag/">https://docs.docker.com/engine/reference/commandline/tag/</a> * @throws InterruptedException if the 'docker tag' process is interrupted. * @throws IOException if an I/O exception occurs or {@code docker tag} failed */ public void tag(ImageReference originalImageReference, ImageReference newImageReference) throws IOException, InterruptedException { // Runs 'docker tag'. Process dockerProcess = docker("tag", originalImageReference.toString(), newImageReference.toString()); if (dockerProcess.waitFor() != 0) { try (InputStreamReader stderr = new InputStreamReader(dockerProcess.getErrorStream(), StandardCharsets.UTF_8)) { throw new IOException( "'docker tag' command failed with error: " + CharStreams.toString(stderr)); } } }