From e724d7fd9e87779874f14b9801b2546b03fb98fd Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Thu, 12 May 2022 13:14:41 +0200 Subject: [PATCH] Move Docker/Podman endpoint to application.properties Signed-off-by: Georg Pfuetzenreuter --- .../net/libertacasa/pubsh/web/Docker.java | 4 ++-- .../pubsh/web/DockerProperties.java | 20 +++++++++++++++++++ ...itional-spring-configuration-metadata.json | 17 +++++++++++----- src/main/resources/application.properties | 3 ++- 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 src/main/java/net/libertacasa/pubsh/web/DockerProperties.java diff --git a/src/main/java/net/libertacasa/pubsh/web/Docker.java b/src/main/java/net/libertacasa/pubsh/web/Docker.java index 2d7bfbe..60d6caa 100644 --- a/src/main/java/net/libertacasa/pubsh/web/Docker.java +++ b/src/main/java/net/libertacasa/pubsh/web/Docker.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; + import com.github.dockerjava.api.DockerClient; import com.github.dockerjava.api.command.BuildImageResultCallback; import com.github.dockerjava.api.command.CreateContainerResponse; @@ -24,8 +25,7 @@ import com.github.dockerjava.transport.DockerHttpClient; public class Docker { static DockerClientConfig DockerConfig = DefaultDockerClientConfig.createDefaultConfigBuilder() - .withDockerHost("tcp://sweetsuse:2375") - //.withDockerHost("tcp://sweetsuse:8085") + .withDockerHost(DockerProperties.getEndpoint()) .withDockerTlsVerify(false) .build(); diff --git a/src/main/java/net/libertacasa/pubsh/web/DockerProperties.java b/src/main/java/net/libertacasa/pubsh/web/DockerProperties.java new file mode 100644 index 0000000..c23cc25 --- /dev/null +++ b/src/main/java/net/libertacasa/pubsh/web/DockerProperties.java @@ -0,0 +1,20 @@ +package net.libertacasa.pubsh.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties("lysergic.docker") +public class DockerProperties { + + private static String endpoint; + + public void setEndpoint(String endpoint) { + DockerProperties.endpoint = endpoint; + } + + public static String getEndpoint() { + return endpoint; + } + +} diff --git a/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 3d1bce2..ebde200 100644 --- a/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1,5 +1,12 @@ -{"properties": [{ - "name": "spring.datasource.jdbc-url", - "type": "java.lang.String", - "description": "New Hikari JDBC connection URI specifier" -}]} +{"properties": [ + { + "name": "spring.datasource.jdbc-url", + "type": "java.lang.String", + "description": "New Hikari JDBC connection URI specifier" + }, + { + "name": "lysergic.docker.endpoint", + "type": "java.lang.String", + "description": "Custom variable to specify Docker/Podman API endpoint" + } +]} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fee4153..dae748b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -10,4 +10,5 @@ spring.datasource.driverClassName=org.mariadb.jdbc.Driver spring.datasource.jdbc-url=jdbc:mariadb://${DB_HOST}/${DB} spring.datasource.username=${DB_USER} spring.datasource.password=${DB_SECRET} -db-scheduler.enabled=true \ No newline at end of file +db-scheduler.enabled=true +lysergic.docker.endpoint=${CONTAINER_API} \ No newline at end of file