Skip to content

Commit e70edce

Browse files
committed
Merge branch '3.5.x'
Closes gh-47020
2 parents 7f7d5b1 + f50e779 commit e70edce

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/service/connection/ConnectionNamePredicate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* {@link Predicate} that matches against connection name.
3030
*
3131
* @author Phillip Webb
32+
* @author Yanming Zhou
3233
*/
3334
class ConnectionNamePredicate implements Predicate<DockerComposeConnectionSource> {
3435

@@ -47,7 +48,7 @@ public boolean test(DockerComposeConnectionSource source) {
4748

4849
private String getActual(RunningService service) {
4950
String label = service.labels().get("org.springframework.boot.service-connection");
50-
return (label != null) ? asCanonicalName(label) : service.image().getName();
51+
return asCanonicalName((label != null) ? label : service.image().getName());
5152
}
5253

5354
private String asCanonicalName(String name) {

core/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/ConnectionNamePredicateTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* Tests for {@link ConnectionNamePredicate}.
3333
*
3434
* @author Phillip Webb
35+
* @author Yanming Zhou
3536
*/
3637
class ConnectionNamePredicateTests {
3738

@@ -60,11 +61,16 @@ void organization() {
6061

6162
@Test
6263
void customDomain() {
64+
assertThat(predicateOf("redis")).accepts(sourceOf("internalhost:8080/redis"));
6365
assertThat(predicateOf("redis")).accepts(sourceOf("internalhost:8080/library/redis"));
66+
assertThat(predicateOf("redis")).accepts(sourceOf("myhost.com/redis"));
6467
assertThat(predicateOf("redis")).accepts(sourceOf("myhost.com/library/redis"));
6568
assertThat(predicateOf("redis")).accepts(sourceOf("myhost.com:8080/library/redis"));
66-
assertThat(predicateOf("redis")).rejects(sourceOf("internalhost:8080/redis"));
6769
assertThat(predicateOf("redis")).accepts(sourceOf("docker.my-company.com/library/redis:latest"));
70+
assertThat(predicateOf("openzipkin/zipkin")).rejects(sourceOf("myhost.com:8080/zipkin"));
71+
assertThat(predicateOf("openzipkin/zipkin")).rejects(sourceOf("myhost.com:8080/library/zipkin"));
72+
assertThat(predicateOf("openzipkin/zipkin")).accepts(sourceOf("myhost.com:8080/openzipkin/zipkin"));
73+
assertThat(predicateOf("postgres")).accepts(sourceOf("docker.my-company.com/postgres:latest"));
6874
}
6975

7076
@Test

0 commit comments

Comments
 (0)