public Optional<DockerCertificatesStore> build() throws DockerCertificateException { if (this.caCertPath == null || this.clientKeyPath == null || this.clientCertPath == null) { log.debug("caCertPath, clientKeyPath or clientCertPath not specified, not using SSL"); return Optional.absent(); } else if (Files.exists(this.caCertPath) && Files.exists(this.clientKeyPath) && Files.exists(this.clientCertPath)) { return Optional.of((DockerCertificatesStore) new DockerCertificates(this)); } else { log.debug("{}, {} or {} does not exist, not using SSL", this.caCertPath, this.clientKeyPath, this.clientCertPath); return Optional.absent(); } } }
protected DockerClient getNewDockerClient() throws Exception { if (isNullOrEmpty(DOCKER_HOST.dockerCertPath())) { return new DefaultDockerClient(DOCKER_HOST.uri()); } else { final Path dockerCertPath = java.nio.file.Paths.get(DOCKER_HOST.dockerCertPath()); return new DefaultDockerClient(DOCKER_HOST.uri(), new DockerCertificates(dockerCertPath)); } }
private DockerClient createDockerClient(final AgentConfig config) throws IOException { final DefaultDockerClient.Builder builder = DefaultDockerClient.builder() .uri(config.getDockerHost().uri()); if (config.getConnectionPoolSize() != -1) { builder.connectionPoolSize(config.getConnectionPoolSize()); } if (!isNullOrEmpty(config.getDockerHost().dockerCertPath())) { final Path dockerCertPath = java.nio.file.Paths.get(config.getDockerHost().dockerCertPath()); final DockerCertificates dockerCertificates; try { dockerCertificates = new DockerCertificates(dockerCertPath); } catch (DockerCertificateException e) { throw new RuntimeException(e); } builder.dockerCertificates(dockerCertificates); } if (config.getGoogleCredentials() != null) { builder.registryAuthSupplier( ContainerRegistryAuthSupplier .forCredentials(config.getGoogleCredentials()) .build() ); } return new PollingDockerClient(builder); }
public Optional<DockerCertificatesStore> build() throws DockerCertificateException { if (this.caCertPath == null || this.clientKeyPath == null || this.clientCertPath == null) { log.debug("caCertPath, clientKeyPath or clientCertPath not specified, not using SSL"); return Optional.absent(); } else if (Files.exists(this.caCertPath) && Files.exists(this.clientKeyPath) && Files.exists(this.clientCertPath)) { return Optional.of((DockerCertificatesStore) new DockerCertificates(this)); } else { log.debug("{}, {} or {} does not exist, not using SSL", this.caCertPath, this.clientKeyPath, this.clientCertPath); return Optional.absent(); } } }
public static DockerClient buildClient(URI dockerHost, Path certificatesPath) { try { if (dockerHost == null) { logger.info("Configuring docker host from environment"); return DefaultDockerClient.fromEnv().build(); } else { logger.info("Configuring docker host from configuration"); DefaultDockerClient.Builder builder = DefaultDockerClient.builder().uri(dockerHost); if (certificatesPath != null) { builder.dockerCertificates(new DockerCertificates(certificatesPath)); } return builder.build(); } } catch (DockerCertificateException e) { logger.error("Could not read certificates", e); throw new IllegalArgumentException("Could not read certificates: " + e.getMessage()); } }
final DockerCertificates dockerCertificates; try { dockerCertificates = new DockerCertificates(dockerCertPath); } catch (DockerCertificateException e) { throw Throwables.propagate(e);