From 4538e2b81ff74af7a76760bfb31a54c6ceb3e831 Mon Sep 17 00:00:00 2001 From: Bhargav Kodali Date: Fri, 27 Sep 2024 20:05:30 -0700 Subject: [PATCH] docker -fix --- .../main/java/org/openmrs/maven/plugins/CreateMySql.java | 6 +++++- .../src/main/java/org/openmrs/maven/plugins/Setup.java | 4 ++-- .../org/openmrs/maven/plugins/utility/DockerHelper.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docker-maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateMySql.java b/docker-maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateMySql.java index d56e2fd7..b80286b5 100644 --- a/docker-maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateMySql.java +++ b/docker-maven-plugin/src/main/java/org/openmrs/maven/plugins/CreateMySql.java @@ -11,12 +11,14 @@ import com.github.dockerjava.api.model.PullResponseItem; import com.github.dockerjava.api.model.Volume; import org.apache.commons.lang.StringUtils; +import com.github.dockerjava.api.command.ListImagesCmd; import org.apache.maven.plugin.MojoExecutionException; import java.io.Closeable; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Arrays; import java.util.concurrent.CountDownLatch; /** @@ -62,7 +64,9 @@ public void executeTask() throws MojoExecutionException { } private boolean noMySqlImage(DockerClient docker) { - List mysql = docker.listImagesCmd().withImageNameFilter(MYSQL_8_4_1).exec(); + ListImagesCmd listImagesCmd = docker.listImagesCmd(); + listImagesCmd.getFilters().put("reference", Arrays.asList(MYSQL_8_4_1)); + List mysql = listImagesCmd.exec(); return mysql.size() == 0; } diff --git a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java index b71f17fa..1543174c 100644 --- a/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java +++ b/maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java @@ -627,8 +627,8 @@ public String determineDbName(String uri, String serverId) throws MojoExecutionE } dbName = dbName.substring(1); - - if (!dbName.substring(1).matches("^[A-Za-z0-9_\\-]+$")) { + + if (!dbName.substring(1).matches("^[A-Za-z0-9_\\-]+$")) { throw new MojoExecutionException( "The database name is not in the correct format (it should only have alphanumeric, dash and underscore signs): " + diff --git a/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DockerHelper.java b/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DockerHelper.java index e51b5cb3..8edece3d 100644 --- a/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DockerHelper.java +++ b/sdk-commons/src/main/java/org/openmrs/maven/plugins/utility/DockerHelper.java @@ -32,7 +32,7 @@ public class DockerHelper { public static final String DOCKER_MYSQL_PASSWORD = "Admin123"; private static final String DOCKER_HOST_KEY = "dockerHost"; public static final String DEFAULT_DOCKER_HOST_UNIX_SOCKET = "unix:///var/run/docker.sock"; - public static final String DEFAULT_HOST_DOCKER_FOR_WINDOWS = "http://127.0.0.1:2375/"; + public static final String DEFAULT_HOST_DOCKER_FOR_WINDOWS = "tcp://127.0.0.1:2375/"; private static final String DOCKER_HOST_MSG_WINDOWS = "To use dockerized MySQL, You have to pass Docker Host URL to SDK. " + "You should run SDK from docker-machine command line, so SDK can connect to your Docker. Your individual docker host URL can be obtained by calling command" +