mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 14:30:28 -05:00
fix: normalize bare host:port Docker host values to prevent URI parse failure (#665)
Co-authored-by: Dixit R Jain <dixitrjain@Dixits-MacBook-Pro.local>
This commit is contained in:
1 parent
f30bd79d67
commit
2dd748ee07
2 files changed
+147
-1
No files matched your search
+24
-1
@@ -27,10 +27,33 @@ public class DockerClientProducer {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a Docker host value by prepending {@code tcp://} when no recognized
|
||||
* URI scheme ({@code tcp://}, {@code unix://}, {@code npipe://}) is present.
|
||||
*
|
||||
* @param dockerHost the raw Docker host configuration value
|
||||
* @return the normalized Docker host value, or the original value if it already has a scheme
|
||||
*/
|
||||
static String normalizeDockerHost(String dockerHost) {
|
||||
if (dockerHost == null) {
|
||||
return null;
|
||||
}
|
||||
if (dockerHost.isEmpty()) {
|
||||
return dockerHost;
|
||||
}
|
||||
String lower = dockerHost.toLowerCase();
|
||||
if (lower.startsWith("tcp://") || lower.startsWith("unix://") || lower.startsWith("npipe://")) {
|
||||
return dockerHost;
|
||||
}
|
||||
String normalized = "tcp://" + dockerHost;
|
||||
LOG.infov("Docker host value ''{0}'' has no URI scheme; normalizing to ''{1}''", dockerHost, normalized);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@Produces
|
||||
@ApplicationScoped
|
||||
public DockerClient dockerClient() {
|
||||
String dockerHost = config.docker().dockerHost();
|
||||
String dockerHost = normalizeDockerHost(config.docker().dockerHost());
|
||||
LOG.infov("Creating DockerClient for host: {0}", dockerHost);
|
||||
|
||||
DefaultDockerClientConfig.Builder builder = DefaultDockerClientConfig.createDefaultConfigBuilder()
|
||||
|
||||
Reference in new issue
Block a user