diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/AbstractBuildLog.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/AbstractBuildLog.java index 213745c254..7154d4ad43 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/AbstractBuildLog.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/AbstractBuildLog.java @@ -91,7 +91,7 @@ public abstract class AbstractBuildLog implements BuildLog { } @Override - public void createdTag(ImageReference tag) { + public void taggedImage(ImageReference tag) { log("Successfully created image tag '" + tag + "'"); log(); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildLog.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildLog.java index 23958ac09b..0acbbabd22 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildLog.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildLog.java @@ -104,7 +104,7 @@ public interface BuildLog { * Log that a tag has been created. * @param tag the tag reference */ - void createdTag(ImageReference tag); + void taggedImage(ImageReference tag); /** * Factory method that returns a {@link BuildLog} the outputs to {@link System#out}. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java index 9f47c6f30c..e7d3799eb4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java @@ -111,10 +111,9 @@ public class Builder { this.docker.image().load(ephemeralBuilder.getArchive(), UpdateListener.none()); try { executeLifecycle(request, ephemeralBuilder); - createTags(request.getName(), request.getTags()); + tagImage(request.getName(), request.getTags()); if (request.isPublish()) { - pushImage(request.getName()); - pushTags(request.getTags()); + pushImages(request.getName(), request.getTags()); } } finally { @@ -153,6 +152,20 @@ public class Builder { } } + private void tagImage(ImageReference sourceReference, List tags) throws IOException { + for (ImageReference tag : tags) { + this.docker.image().tag(sourceReference, tag); + this.log.taggedImage(tag); + } + } + + private void pushImages(ImageReference name, List tags) throws IOException { + pushImage(name); + for (ImageReference tag : tags) { + pushImage(tag); + } + } + private void pushImage(ImageReference reference) throws IOException { Consumer progressConsumer = this.log.pushingImage(reference); TotalProgressPushListener listener = new TotalProgressPushListener(progressConsumer); @@ -160,19 +173,6 @@ public class Builder { this.log.pushedImage(reference); } - private void createTags(ImageReference sourceReference, List tags) throws IOException { - for (ImageReference tag : tags) { - this.docker.image().tag(sourceReference, tag); - this.log.createdTag(tag); - } - } - - private void pushTags(List tags) throws IOException { - for (ImageReference tag : tags) { - pushImage(tag); - } - } - private String getBuilderAuthHeader() { return (this.dockerConfiguration != null && this.dockerConfiguration.getBuilderRegistryAuthentication() != null) ? this.dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader() : null; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java index 24d83d70c3..0889a42f38 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java @@ -284,7 +284,7 @@ public class DockerApi { Assert.notNull(reference, "Reference must not be null"); Collection params = force ? FORCE_PARAMS : Collections.emptySet(); URI uri = buildUrl("/images/" + reference, params); - http().delete(uri); + http().delete(uri).close(); } /** @@ -305,7 +305,7 @@ public class DockerApi { Assert.notNull(sourceReference, "SourceReference must not be null"); Assert.notNull(targetReference, "TargetReference must not be null"); URI uri = buildUrl("/images/" + sourceReference + "/tag", "repo", targetReference.toString()); - http().post(uri); + http().post(uri).close(); } } @@ -356,7 +356,7 @@ public class DockerApi { public void start(ContainerReference reference) throws IOException { Assert.notNull(reference, "Reference must not be null"); URI uri = buildUrl("/containers/" + reference + "/start"); - http().post(uri); + http().post(uri).close(); } /** @@ -404,7 +404,7 @@ public class DockerApi { Assert.notNull(reference, "Reference must not be null"); Collection params = force ? FORCE_PARAMS : Collections.emptySet(); URI uri = buildUrl("/containers/" + reference, params); - http().delete(uri); + http().delete(uri).close(); } } @@ -427,7 +427,7 @@ public class DockerApi { Assert.notNull(name, "Name must not be null"); Collection params = force ? FORCE_PARAMS : Collections.emptySet(); URI uri = buildUrl("/volumes/" + name, params); - http().delete(uri); + http().delete(uri).close(); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PrintStreamBuildLogTests.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PrintStreamBuildLogTests.java index a20e94b88e..74cefced82 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PrintStreamBuildLogTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PrintStreamBuildLogTests.java @@ -76,7 +76,7 @@ class PrintStreamBuildLogTests { phase2Consumer.accept(mockLogEvent("spring")); phase2Consumer.accept(mockLogEvent("boot")); log.executedLifecycle(request); - log.createdTag(tag); + log.taggedImage(tag); String expected = FileCopyUtils.copyToString(new InputStreamReader( getClass().getResourceAsStream("print-stream-build-log.txt"), StandardCharsets.UTF_8)); assertThat(out.toString()).isEqualToIgnoringNewLines(expected); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc index b15fd7e157..66b6bfa876 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc @@ -178,7 +178,7 @@ The value supplied will be passed unvalidated to Docker when creating the builde | `tags` | -| Multiple {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[tag names] to be created for the generated image. +| A list of one or more additional tags to apply to the generated image. | |=== diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-failsWithInvalidTagName.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-failsWithInvalidTag.gradle similarity index 100% rename from spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-failsWithInvalidTagName.gradle rename to spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests-failsWithInvalidTag.gradle diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc index 46ae88ebdd..612cda0134 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc @@ -184,7 +184,7 @@ The value supplied will be passed unvalidated to Docker when creating the builde | `false` | `tags` -| Multiple {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[tag names] to be created for the generated image. +| One or more additional tags to apply to the generated image. | |===