Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* {@link Predicate} that matches against connection name.
*
* @author Phillip Webb
* @author Yanming Zhou
*/
class ConnectionNamePredicate implements Predicate<DockerComposeConnectionSource> {

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

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Tests for {@link ConnectionNamePredicate}.
*
* @author Phillip Webb
* @author Yanming Zhou
*/
class ConnectionNamePredicateTests {

Expand Down Expand Up @@ -63,7 +64,7 @@ void customDomain() {
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
Expand Down