mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Create service connections for image with registry host and without project
See gh-46974 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
committed by
Moritz Halbritter
parent
fafd0bbd20
commit
c8d29fd3fe
+2
-1
@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
|
||||
* {@link Predicate} that matches against connection name.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
class ConnectionNamePredicate implements Predicate<DockerComposeConnectionSource> {
|
||||
|
||||
@@ -47,7 +48,7 @@ class ConnectionNamePredicate implements Predicate<DockerComposeConnectionSource
|
||||
|
||||
private String getActual(RunningService service) {
|
||||
String label = service.labels().get("org.springframework.boot.service-connection");
|
||||
return (label != null) ? asCanonicalName(label) : service.image().getName();
|
||||
return asCanonicalName((label != null) ? label : service.image().getName());
|
||||
}
|
||||
|
||||
private String asCanonicalName(String name) {
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock;
|
||||
* Tests for {@link ConnectionNamePredicate}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
class ConnectionNamePredicateTests {
|
||||
|
||||
@@ -63,7 +64,7 @@ class ConnectionNamePredicateTests {
|
||||
assertThat(predicateOf("redis")).accepts(sourceOf("internalhost:8080/library/redis"));
|
||||
assertThat(predicateOf("redis")).accepts(sourceOf("myhost.com/library/redis"));
|
||||
assertThat(predicateOf("redis")).accepts(sourceOf("myhost.com:8080/library/redis"));
|
||||
assertThat(predicateOf("redis")).rejects(sourceOf("internalhost:8080/redis"));
|
||||
assertThat(predicateOf("redis")).accepts(sourceOf("internalhost:8080/redis"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user