当前位置: 首页>>代码示例>>Java>>正文


Java DockerCertificates类代码示例

本文整理汇总了Java中com.spotify.docker.client.DockerCertificates的典型用法代码示例。如果您正苦于以下问题:Java DockerCertificates类的具体用法?Java DockerCertificates怎么用?Java DockerCertificates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DockerCertificates类属于com.spotify.docker.client包,在下文中一共展示了DockerCertificates类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupCerts

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
private static void setupCerts(PluginSettings pluginSettings, DefaultDockerClient.Builder builder) throws IOException, DockerCertificateException {
    if (isBlank(pluginSettings.getDockerCACert()) || isBlank(pluginSettings.getDockerClientCert()) || isBlank(pluginSettings.getDockerClientKey())) {
        LOG.warn("Missing docker certificates, will attempt to connect without certificates");
        return;
    }

    Path certificateDir = Files.createTempDirectory(UUID.randomUUID().toString());
    File tempDirectory = certificateDir.toFile();

    try {
        FileUtils.writeStringToFile(new File(tempDirectory, DockerCertificates.DEFAULT_CA_CERT_NAME), pluginSettings.getDockerCACert(), StandardCharsets.UTF_8);
        FileUtils.writeStringToFile(new File(tempDirectory, DockerCertificates.DEFAULT_CLIENT_CERT_NAME), pluginSettings.getDockerClientCert(), StandardCharsets.UTF_8);
        FileUtils.writeStringToFile(new File(tempDirectory, DockerCertificates.DEFAULT_CLIENT_KEY_NAME), pluginSettings.getDockerClientKey(), StandardCharsets.UTF_8);
        builder.dockerCertificates(new DockerCertificates(certificateDir));
    } finally {
        FileUtils.deleteDirectory(tempDirectory);
    }
}
 
开发者ID:gocd-contrib,项目名称:docker-elastic-agents,代码行数:19,代码来源:DockerClientFactory.java

示例2: DockerWrapper

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
/**
 * Constructor.
 * @param dockerHost String. The docker host ex: https://something:2376
 * @param certPath String. The certificate path
 * @param feedBackLevel String. The logging level: q = ERROR, v = DEBUG, i = info (default)
 * @throws DockerCertificateException
 */
public DockerWrapper(String dockerHost, String certPath, String feedBackLevel) throws DockerCertificateException {
	this.dockerHost = dockerHost;
	this.certPath = certPath;
	this.docker = DefaultDockerClient.builder()
		    .uri(URI.create(this.dockerHost))
		    .dockerCertificates(new DockerCertificates(Paths.get(this.certPath)))
		    .build();
	if (feedBackLevel.equalsIgnoreCase("q")) {
		Logger.getRootLogger().setLevel(Level.ERROR);
		logger.setLevel(Level.ERROR);
	}
	else if (feedBackLevel.equalsIgnoreCase("v")) {
			Logger.getRootLogger().setLevel(Level.DEBUG);
			logger.setLevel(Level.DEBUG);
	}
}
 
开发者ID:cleuton,项目名称:servkeeper,代码行数:24,代码来源:DockerWrapper.java

示例3: createClient

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
private DefaultDockerClient createClient() {
    DefaultDockerClient dockerClient;
    Optional<DockerCertificates> certs = Optional.absent();
    if (mccySettings.getDockerCertPath() != null) {
        try {
            certs = DockerCertificates.builder()
                    .dockerCertPath(Paths.get(mccySettings.getDockerCertPath())).build();
        } catch (DockerCertificateException e) {
            throw new IllegalArgumentException("Unable to initialize Docker certificates with given configuration");
        }
    }

    final DefaultDockerClient.Builder clientBuilder = DefaultDockerClient.builder();

    if (certs.isPresent()) {
        clientBuilder
                .dockerCertificates(certs.get());
    }

    dockerClient = clientBuilder
            .uri(mccySettings.getDockerHostUri())
            .build();
    return dockerClient;
}
 
开发者ID:moorkop,项目名称:mccy-engine,代码行数:25,代码来源:DockerClientProxyImpl.java

示例4: getDockerClient

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
public DockerClient getDockerClient() throws DockerCertificateException {
	DockerClient client = null;
	if (this.isUseDefault()) {
		client = DefaultDockerClient.builder()
				.uri(DefaultDockerClient.DEFAULT_UNIX_ENDPOINT).build();
	} else {
		if (this.isUseUnixSocket()) {
			client = DefaultDockerClient.builder().uri(getSocketPath())
					.build();
		} else if (isUseHTTPS()) {
			if (isEnableAuth()) {
				client = DefaultDockerClient
						.builder()
						.dockerCertificates(
								new DockerCertificates(Paths
										.get(getAuthPath())))
						.uri(getHost()).build();
			} else {
				client = DefaultDockerClient.builder().uri(getHost())
						.build();
			}
		}
	}
	return client;
}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:26,代码来源:DockerConnectionElement.java

示例5: DockerClientSpotify

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
public DockerClientSpotify() {
    messageConsole = new DockerClientMessageConsole(Constants.CONSOLE_NAME);
    dockerConfig = new DockerConfig();

    final String endpoint = dockerConfig.getUri();
    final String dockerCertPath = dockerConfig.getDockerCertPath();

    final DefaultDockerClient.Builder builder = new DefaultDockerClient.Builder();
    builder.uri(endpoint);
    builder.readTimeoutMillis(DefaultDockerClient.NO_TIMEOUT);

    if (dockerCertPath != null && !dockerCertPath.isEmpty()) {
        try {
            builder.dockerCertificates(new DockerCertificates(Paths
                    .get(dockerCertPath)));
        } catch (DockerCertificateException e) {
            messageConsole.getDockerConsoleOut().println(
                    "[ERROR] " + e.toString());
        }
    }

    dockerClient = builder.build();
}
 
开发者ID:domeide,项目名称:doclipser,代码行数:24,代码来源:DockerClientSpotify.java

示例6: connect

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
@Override
public DockerHost connect() throws IOException {
    try {
        final DockerHost connected;
        if(this.dockerHost.isEmpty() || this.certPath.isEmpty()) {
            connected = new RtDockerHost(
                DefaultDockerClient.fromEnv().build(),
                this.dockerHost, this.certPath
            );
        } else {
            connected = new RtDockerHost(
                DefaultDockerClient
                    .builder()
                    .uri(this.dockerHost)
                    .dockerCertificates(
                        new DockerCertificates(Paths.get(this.certPath))
                    ).build(),
                this.dockerHost, this.certPath
            );
        }
        return connected;
    } catch (final DockerCertificateException ex) {
        throw new IOException(
            "DockerCertificateException when trying to connect", ex
        );
    }
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:28,代码来源:RtDockerHost.java

示例7: createSettings

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
protected PluginSettings createSettings() throws IOException {
    PluginSettings settings = new PluginSettings();
    settings.setMaxDockerContainers(1);
    settings.setDockerURI(builder.uri().toString());
    if (settings.getDockerURI().startsWith("https://")) {
        settings.setDockerCACert(FileUtils.readFileToString(Paths.get(getenv("DOCKER_CERT_PATH"), DockerCertificates.DEFAULT_CA_CERT_NAME).toFile(), StandardCharsets.UTF_8));
        settings.setDockerClientCert(FileUtils.readFileToString(Paths.get(getenv("DOCKER_CERT_PATH"), DockerCertificates.DEFAULT_CLIENT_CERT_NAME).toFile(), StandardCharsets.UTF_8));
        settings.setDockerClientKey(FileUtils.readFileToString(Paths.get(getenv("DOCKER_CERT_PATH"), DockerCertificates.DEFAULT_CLIENT_KEY_NAME).toFile(), StandardCharsets.UTF_8));
    }

    return settings;
}
 
开发者ID:gocd-contrib,项目名称:docker-elastic-agents,代码行数:13,代码来源:BaseTest.java

示例8: getDockerClient

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
@Bean
public DockerClient getDockerClient() {
	try {
		return DefaultDockerClient.builder()
			.dockerCertificates(DockerCertificates.builder().dockerCertPath(Paths.get(environment.getProperty("shiny.proxy.docker.cert-path", ""))).build().orNull())
			.uri(environment.getProperty("shiny.proxy.docker.url"))
			.build();
	} catch (DockerCertificateException e) {
		throw new ShinyProxyException("Failed to initialize docker client", e);
	}
}
 
开发者ID:openanalytics,项目名称:shinyproxy,代码行数:12,代码来源:DockerService.java

示例9: build

import com.spotify.docker.client.DockerCertificates; //导入依赖的package包/类
@Override
public DefaultDockerClient.Builder build(HttpsRestApiHost host) {
	DefaultDockerClient.Builder builder = DefaultDockerClient.builder();
		
	builder.uri(host.getUri());
	try {
		builder.dockerCertificates(new DockerCertificates(Paths.get(host.getCertPath())));			
	} catch(DockerCertificateException ex) {
		throw new IllegalArgumentException("Certificates could not be resolved", ex);
	}
	return builder;
}
 
开发者ID:petercipov,项目名称:mobi,代码行数:13,代码来源:SpotifyClientBuilder.java


注:本文中的com.spotify.docker.client.DockerCertificates类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。