Skip to content

Commit 64c4900

Browse files
Polish "Add option to create tags for a built image"
See gh-27613
1 parent 66f44b0 commit 64c4900

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/AbstractBuildLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void executedLifecycle(BuildRequest request) {
9191
}
9292

9393
@Override
94-
public void createdTag(ImageReference tag) {
94+
public void taggedImage(ImageReference tag) {
9595
log("Successfully created image tag '" + tag + "'");
9696
log();
9797
}

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public interface BuildLog {
104104
* Log that a tag has been created.
105105
* @param tag the tag reference
106106
*/
107-
void createdTag(ImageReference tag);
107+
void taggedImage(ImageReference tag);
108108

109109
/**
110110
* Factory method that returns a {@link BuildLog} the outputs to {@link System#out}.

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ public void build(BuildRequest request) throws DockerEngineException, IOExceptio
111111
this.docker.image().load(ephemeralBuilder.getArchive(), UpdateListener.none());
112112
try {
113113
executeLifecycle(request, ephemeralBuilder);
114-
createTags(request.getName(), request.getTags());
114+
tagImage(request.getName(), request.getTags());
115115
if (request.isPublish()) {
116-
pushImage(request.getName());
117-
pushTags(request.getTags());
116+
pushImages(request.getName(), request.getTags());
118117
}
119118
}
120119
finally {
@@ -153,26 +152,27 @@ private void executeLifecycle(BuildRequest request, EphemeralBuilder builder) th
153152
}
154153
}
155154

156-
private void pushImage(ImageReference reference) throws IOException {
157-
Consumer<TotalProgressEvent> progressConsumer = this.log.pushingImage(reference);
158-
TotalProgressPushListener listener = new TotalProgressPushListener(progressConsumer);
159-
this.docker.image().push(reference, listener, getPublishAuthHeader());
160-
this.log.pushedImage(reference);
161-
}
162-
163-
private void createTags(ImageReference sourceReference, List<ImageReference> tags) throws IOException {
155+
private void tagImage(ImageReference sourceReference, List<ImageReference> tags) throws IOException {
164156
for (ImageReference tag : tags) {
165157
this.docker.image().tag(sourceReference, tag);
166-
this.log.createdTag(tag);
158+
this.log.taggedImage(tag);
167159
}
168160
}
169161

170-
private void pushTags(List<ImageReference> tags) throws IOException {
162+
private void pushImages(ImageReference name, List<ImageReference> tags) throws IOException {
163+
pushImage(name);
171164
for (ImageReference tag : tags) {
172165
pushImage(tag);
173166
}
174167
}
175168

169+
private void pushImage(ImageReference reference) throws IOException {
170+
Consumer<TotalProgressEvent> progressConsumer = this.log.pushingImage(reference);
171+
TotalProgressPushListener listener = new TotalProgressPushListener(progressConsumer);
172+
this.docker.image().push(reference, listener, getPublishAuthHeader());
173+
this.log.pushedImage(reference);
174+
}
175+
176176
private String getBuilderAuthHeader() {
177177
return (this.dockerConfiguration != null && this.dockerConfiguration.getBuilderRegistryAuthentication() != null)
178178
? this.dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader() : null;

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public void remove(ImageReference reference, boolean force) throws IOException {
284284
Assert.notNull(reference, "Reference must not be null");
285285
Collection<String> params = force ? FORCE_PARAMS : Collections.emptySet();
286286
URI uri = buildUrl("/images/" + reference, params);
287-
http().delete(uri);
287+
http().delete(uri).close();
288288
}
289289

290290
/**
@@ -305,7 +305,7 @@ public void tag(ImageReference sourceReference, ImageReference targetReference)
305305
Assert.notNull(sourceReference, "SourceReference must not be null");
306306
Assert.notNull(targetReference, "TargetReference must not be null");
307307
URI uri = buildUrl("/images/" + sourceReference + "/tag", "repo", targetReference.toString());
308-
http().post(uri);
308+
http().post(uri).close();
309309
}
310310

311311
}
@@ -356,7 +356,7 @@ private void uploadContainerContent(ContainerReference reference, ContainerConte
356356
public void start(ContainerReference reference) throws IOException {
357357
Assert.notNull(reference, "Reference must not be null");
358358
URI uri = buildUrl("/containers/" + reference + "/start");
359-
http().post(uri);
359+
http().post(uri).close();
360360
}
361361

362362
/**
@@ -404,7 +404,7 @@ public void remove(ContainerReference reference, boolean force) throws IOExcepti
404404
Assert.notNull(reference, "Reference must not be null");
405405
Collection<String> params = force ? FORCE_PARAMS : Collections.emptySet();
406406
URI uri = buildUrl("/containers/" + reference, params);
407-
http().delete(uri);
407+
http().delete(uri).close();
408408
}
409409

410410
}
@@ -427,7 +427,7 @@ public void delete(VolumeName name, boolean force) throws IOException {
427427
Assert.notNull(name, "Name must not be null");
428428
Collection<String> params = force ? FORCE_PARAMS : Collections.emptySet();
429429
URI uri = buildUrl("/volumes/" + name, params);
430-
http().delete(uri);
430+
http().delete(uri).close();
431431
}
432432

433433
}

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/build/PrintStreamBuildLogTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void printsExpectedOutput() throws Exception {
7676
phase2Consumer.accept(mockLogEvent("spring"));
7777
phase2Consumer.accept(mockLogEvent("boot"));
7878
log.executedLifecycle(request);
79-
log.createdTag(tag);
79+
log.taggedImage(tag);
8080
String expected = FileCopyUtils.copyToString(new InputStreamReader(
8181
getClass().getResourceAsStream("print-stream-build-log.txt"), StandardCharsets.UTF_8));
8282
assertThat(out.toString()).isEqualToIgnoringNewLines(expected);

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/docs/asciidoc/packaging-oci-image.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ The value supplied will be passed unvalidated to Docker when creating the builde
178178

179179
| `tags`
180180
|
181-
| Multiple {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[tag names] to be created for the generated image.
181+
| A list of one or more additional tags to apply to the generated image.
182182
|
183183

184184
|===

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ The value supplied will be passed unvalidated to Docker when creating the builde
184184
| `false`
185185

186186
| `tags`
187-
| Multiple {spring-boot-api}/buildpack/platform/docker/type/ImageReference.html#of-java.lang.String-[tag names] to be created for the generated image.
187+
| One or more additional tags to apply to the generated image.
188188
|
189189

190190
|===

0 commit comments

Comments
 (0)