本文整理匯總了Java中com.spotify.docker.client.DefaultDockerClient.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java DefaultDockerClient.Builder方法的具體用法?Java DefaultDockerClient.Builder怎麽用?Java DefaultDockerClient.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.spotify.docker.client.DefaultDockerClient
的用法示例。
在下文中一共展示了DefaultDockerClient.Builder方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createClient
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
private static DefaultDockerClient createClient(PluginSettings pluginSettings) throws Exception {
DefaultDockerClient.Builder builder = DefaultDockerClient.builder();
builder.uri(pluginSettings.getDockerURI());
if (pluginSettings.getDockerURI().startsWith("https://")) {
setupCerts(pluginSettings, builder);
}
if (pluginSettings.useDockerAuthInfo()) {
RegistryAuth auth = RegistryAuth.builder()
.password(pluginSettings.getPrivateRegistryPassword())
.serverAddress(pluginSettings.getPrivateRegistryServer())
.username(pluginSettings.getPrivateRegistryUsername())
.build();
builder.registryAuth(auth);
}
DefaultDockerClient docker = builder.build();
String ping = docker.ping();
if (!"OK".equals(ping)) {
throw new RuntimeException("Could not ping the docker server, the server said '" + ping + "' instead of 'OK'.");
}
return docker;
}
示例2: setupCerts
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的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);
}
}
示例3: createClient
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
private static DefaultDockerClient createClient(PluginSettings pluginSettings) throws Exception {
DefaultDockerClient.Builder builder = DefaultDockerClient.builder();
builder.uri(pluginSettings.getDockerURI());
if (pluginSettings.getDockerURI().startsWith("https://")) {
setupCerts(pluginSettings, builder);
}
if (pluginSettings.useDockerAuthInfo()) {
final RegistryAuth registryAuth = pluginSettings.registryAuth();
LOG.info(format("Using private docker registry server `{0}`.", registryAuth.serverAddress()));
builder.registryAuth(registryAuth);
}
DefaultDockerClient docker = builder.build();
String ping = docker.ping();
if (!"OK".equals(ping)) {
throw new RuntimeException("Could not ping the docker server, the server said '" + ping + "' instead of 'OK'.");
}
return docker;
}
示例4: createClient
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的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;
}
示例5: DockerClientSpotify
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的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();
}
示例6: build
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
@Override
public DefaultDockerClient.Builder build(HttpRestApiHost host) {
return DefaultDockerClient
.builder()
.uri(host.getUri())
;
}
示例7: SpotifyRxDocker
import com.spotify.docker.client.DefaultDockerClient; //導入方法依賴的package包/類
public SpotifyRxDocker(DefaultDockerClient.Builder builder, Scheduler scheduler) {
this.clientBuilder = builder;
this.scheduler = scheduler;
this.clients = Collections.synchronizedMap(new HashMap<>());
}