Search in sources :

Example 1 with DockerAccess

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccess in project jkube by eclipse.

the class DockerAccessFactory method createDockerAccess.

public DockerAccess createDockerAccess(DockerAccessContext dockerAccessContext) {
    try {
        DockerConnectionDetector dockerConnectionDetector = createDockerConnectionDetector(dockerAccessContext, dockerAccessContext.getLog());
        DockerConnectionDetector.ConnectionParameter connectionParam = dockerConnectionDetector.detectConnectionParameter(dockerAccessContext.getDockerHost(), dockerAccessContext.getCertPath());
        DockerAccess access = new DockerAccessWithHcClient(connectionParam.getUrl(), connectionParam.getCertPath(), dockerAccessContext.getMaxConnections(), dockerAccessContext.getLog());
        access.start();
        setDockerHostAddressProperty(dockerAccessContext, connectionParam.getUrl());
        return access;
    } catch (IOException e) {
        throw new IllegalStateException("Cannot create docker access object ", e);
    }
}
Also used : DockerAccess(org.eclipse.jkube.kit.build.service.docker.access.DockerAccess) DockerAccessWithHcClient(org.eclipse.jkube.kit.build.service.docker.access.hc.DockerAccessWithHcClient) DockerConnectionDetector(org.eclipse.jkube.kit.build.service.docker.access.DockerConnectionDetector) IOException(java.io.IOException)

Example 2 with DockerAccess

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccess in project jkube by eclipse.

the class AbstractDockerMojo method doExecute.

protected void doExecute() throws MojoExecutionException {
    final boolean ansiRestore = Ansi.isEnabled();
    try {
        DockerAccess dockerAccess = null;
        try {
            javaProject = MavenUtil.convertMavenProjectToJKubeProject(project, session);
            resources = updateResourceConfigNamespace(namespace, resources);
            // The 'real' images configuration to use (configured images + externally resolved images)
            if (isDockerAccessRequired()) {
                DockerAccessFactory.DockerAccessContext dockerAccessContext = getDockerAccessContext();
                dockerAccess = dockerAccessFactory.createDockerAccess(dockerAccessContext);
            }
            jkubeServiceHub = JKubeServiceHub.builder().log(log).configuration(initJKubeConfiguration()).clusterAccess(clusterAccess).platformMode(getConfiguredRuntimeMode()).dockerServiceHub(DockerServiceHub.newInstance(log, dockerAccess, logOutputSpecFactory)).buildServiceConfig(buildServiceConfigBuilder().build()).offline(offline).build();
            resolvedImages = ConfigHelper.initImageConfiguration(apiVersion, getBuildTimestamp(getPluginContext(), CONTEXT_KEY_BUILD_TIMESTAMP, project.getBuild().getDirectory(), DOCKER_BUILD_TIMESTAMP), images, imageConfigResolver, log, filter, this, jkubeServiceHub.getConfiguration());
            executeInternal();
        } catch (IOException | DependencyResolutionRequiredException exp) {
            logException(exp);
            throw new MojoExecutionException(exp.getMessage());
        } catch (MojoExecutionException exp) {
            logException(exp);
            throw exp;
        } finally {
            Optional.ofNullable(jkubeServiceHub).ifPresent(JKubeServiceHub::close);
        }
    } finally {
        Ansi.setEnabled(ansiRestore);
    }
}
Also used : DockerAccess(org.eclipse.jkube.kit.build.service.docker.access.DockerAccess) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) DockerAccessFactory(org.eclipse.jkube.kit.build.service.docker.DockerAccessFactory) JKubeServiceHub(org.eclipse.jkube.kit.config.service.JKubeServiceHub)

Aggregations

IOException (java.io.IOException)2 DockerAccess (org.eclipse.jkube.kit.build.service.docker.access.DockerAccess)2 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 DockerAccessFactory (org.eclipse.jkube.kit.build.service.docker.DockerAccessFactory)1 DockerConnectionDetector (org.eclipse.jkube.kit.build.service.docker.access.DockerConnectionDetector)1 DockerAccessWithHcClient (org.eclipse.jkube.kit.build.service.docker.access.hc.DockerAccessWithHcClient)1 JKubeServiceHub (org.eclipse.jkube.kit.config.service.JKubeServiceHub)1