本文整理汇总了Java中com.spotify.docker.client.exceptions.DockerCertificateException类的典型用法代码示例。如果您正苦于以下问题:Java DockerCertificateException类的具体用法?Java DockerCertificateException怎么用?Java DockerCertificateException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DockerCertificateException类属于com.spotify.docker.client.exceptions包,在下文中一共展示了DockerCertificateException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupCerts
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的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);
}
}
示例2: createClient
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的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;
}
示例3: countRunningContainers
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
private int countRunningContainers(String imageName) throws DockerException, InterruptedException, DockerCertificateException {
// The could be a performance hog in huge Docker environments. Replacing with
// docker labels/metadata is the plan.
DockerClient dockerClient = null;
try {
dockerClient = buildDockerClient();
List<ListContainersParam> params = new ArrayList<ListContainersParam>(2);
params.add(ListContainersParam.withLabel(DockerLabelsBuilder.CLOUD_NAME, DockerLabelsBuilder.sanitize(getName())));
if (imageName != null) {
params.add(ListContainersParam.withLabel(DockerLabelsBuilder.IMAGE_NAME, DockerLabelsBuilder.sanitize(imageName)));
}
return dockerClient.listContainers(params.toArray(new ListContainersParam[params.size()])).size();
} finally {
if (dockerClient != null) {
dockerClient.close();
}
}
}
示例4: createDockerClient
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
static DockerClient createDockerClient() {
try {
return DefaultDockerClient.fromEnv().build();
} catch (DockerCertificateException e) {
throw Throwables.propagate(e);
}
}
示例5: LocalEngine
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
public LocalEngine(LocalEngineConfig config) {
this.config = config;
try {
dockerClient = DefaultDockerClient.fromEnv().build();
} catch (DockerCertificateException e) {
log.error("initialize dockers client failed: " + e.getMessage(), e);
throw new RuntimeException("dockers client initialization failed.", e);
}
}
示例6: connect
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的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
);
}
}
示例7: createDockerClient
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
protected DockerClient createDockerClient() {
try {
return DefaultDockerClient.fromEnv().build();
} catch (DockerCertificateException e) {
throw new IllegalStateException("Could not create docker client from environement", e);
}
}
示例8: openDockerClient
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
@Nonnull
private DockerClient openDockerClient() throws MojoExecutionException {
final RegistryAuthSupplier authSupplier = createRegistryAuthSupplier();
try {
return DefaultDockerClient.fromEnv()
.readTimeoutMillis(readTimeoutMillis)
.connectTimeoutMillis(connectTimeoutMillis)
.registryAuthSupplier(authSupplier)
.build();
} catch (DockerCertificateException e) {
throw new MojoExecutionException("Could not load Docker certificates", e);
}
}
示例9: startPostgresIfNecessary
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
private void startPostgresIfNecessary() {
try {
if (container == null) {
DockerClient docker = DefaultDockerClient.fromEnv().build();
container = new PostgresContainer(docker, host);
}
} catch (DockerCertificateException | InterruptedException | DockerException | IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
示例10: getDockerClient
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的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);
}
}
示例11: startPostgresIfNecessary
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
private void startPostgresIfNecessary() {
try {
if (container == null) {
DockerClient docker = DefaultDockerClient.fromEnv().build();
container = new PostgresContainer(docker, host);
}
} catch (InterruptedException | DockerCertificateException | DockerException | IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
示例12: ContainerFactoryImpl
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
@Inject
ContainerFactoryImpl(final UniqueIdService uniqueIdService, final SimpleExecutorService simpleExecutorService)
throws DockerCertificateException {
this.uniqueIdService = uniqueIdService;
this.simpleExecutorService = simpleExecutorService;
docker = DefaultDockerClient.fromEnv()
.build();
}
示例13: countAllRunningContainers
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
private int countAllRunningContainers() throws DockerException, InterruptedException, DockerCertificateException {
return countRunningContainers(null);
}
示例14: update
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
@Update
public void update() throws InterruptedException, DockerException, DockerCertificateException, IOException {
this.stop();
this.start();
}
示例15: LocalEngineTest
import com.spotify.docker.client.exceptions.DockerCertificateException; //导入依赖的package包/类
public LocalEngineTest() throws DockerCertificateException {}