use of io.fabric8.maven.docker.access.DockerConnectionDetector in project docker-maven-plugin by fabric8io.
the class DockerAccessFactory method createDockerAccess.
public DockerAccess createDockerAccess(DockerAccessContext dockerAccessContext) throws MojoExecutionException, MojoFailureException {
try {
DockerConnectionDetector dockerConnectionDetector = createDockerConnectionDetector(dockerAccessContext, dockerAccessContext.getLog());
DockerConnectionDetector.ConnectionParameter connectionParam = dockerConnectionDetector.detectConnectionParameter(dockerAccessContext.getDockerHost(), dockerAccessContext.getCertPath());
String version = dockerAccessContext.getMinimalApiVersion() != null ? dockerAccessContext.getMinimalApiVersion() : API_VERSION;
DockerAccess access = new DockerAccessWithHcClient("v" + version, connectionParam.getUrl(), connectionParam.getCertPath(), dockerAccessContext.getMaxConnections(), dockerAccessContext.getLog());
access.start();
setDockerHostAddressProperty(dockerAccessContext, connectionParam.getUrl());
String serverVersion = access.getServerApiVersion();
if (!EnvUtil.greaterOrEqualsVersion(serverVersion, version)) {
throw new MojoExecutionException(String.format("Server API version %s is smaller than required API version %s", serverVersion, version));
}
return access;
} catch (IOException e) {
throw new MojoExecutionException("Cannot create docker access object ", e);
}
}
Aggregations