本文整理汇总了Java中com.spotify.docker.client.auth.RegistryAuthSupplier类的典型用法代码示例。如果您正苦于以下问题:Java RegistryAuthSupplier类的具体用法?Java RegistryAuthSupplier怎么用?Java RegistryAuthSupplier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryAuthSupplier类属于com.spotify.docker.client.auth包,在下文中一共展示了RegistryAuthSupplier类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openDockerClient
import com.spotify.docker.client.auth.RegistryAuthSupplier; //导入依赖的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);
}
}
示例2: createRegistryAuthSupplier
import com.spotify.docker.client.auth.RegistryAuthSupplier; //导入依赖的package包/类
@Nonnull
private RegistryAuthSupplier createRegistryAuthSupplier() {
final List<RegistryAuthSupplier> suppliers = new ArrayList<>();
if (useMavenSettingsForAuth) {
suppliers.add(new MavenRegistryAuthSupplier(session.getSettings()));
}
if (dockerConfigFile == null || "".equals(dockerConfigFile.getName())) {
suppliers.add(new ConfigFileRegistryAuthSupplier());
} else {
suppliers.add(
new ConfigFileRegistryAuthSupplier(
new DockerConfigReader(),
dockerConfigFile.toPath()
)
);
}
if (googleContainerRegistryEnabled) {
try {
final RegistryAuthSupplier googleSupplier = googleContainerRegistryAuthSupplier();
if (googleSupplier != null) {
suppliers.add(0, googleSupplier);
}
} catch (IOException ex) {
getLog().info("Ignoring exception while loading Google credentials", ex);
}
} else {
getLog().info("Google Container Registry support is disabled");
}
MavenPomAuthSupplier pomSupplier = new MavenPomAuthSupplier(this.username, this.password);
if (pomSupplier.hasUserName()) {
suppliers.add(pomSupplier);
}
return new MultiRegistryAuthSupplier(suppliers);
}
示例3: googleContainerRegistryAuthSupplier
import com.spotify.docker.client.auth.RegistryAuthSupplier; //导入依赖的package包/类
/**
* Attempt to load a GCR compatible RegistryAuthSupplier based on a few conditions:
* <ol>
* <li>First check to see if the environemnt variable DOCKER_GOOGLE_CREDENTIALS is set and points
* to a readable file</li>
* <li>Otherwise check if the Google Application Default Credentials can be loaded</li>
* </ol>
* Note that we use a special environment variable of our own in addition to any environment
* variable that the ADC loading uses (GOOGLE_APPLICATION_CREDENTIALS) in case there is a need for
* the user to use the latter env var for some other purpose in their build.
*
* @return a GCR RegistryAuthSupplier, or null
* @throws IOException if an IOException occurs while loading the credentials
*/
@Nullable
private RegistryAuthSupplier googleContainerRegistryAuthSupplier() throws IOException {
GoogleCredentials credentials = null;
final String googleCredentialsPath = System.getenv("DOCKER_GOOGLE_CREDENTIALS");
if (googleCredentialsPath != null) {
final File file = new File(googleCredentialsPath);
if (file.exists()) {
try (FileInputStream inputStream = new FileInputStream(file)) {
credentials = GoogleCredentials.fromStream(inputStream);
getLog().info("Using Google credentials from file: " + file.getAbsolutePath());
}
}
}
// use the ADC last
if (credentials == null) {
try {
credentials = GoogleCredentials.getApplicationDefault();
getLog().info("Using Google application default credentials");
} catch (IOException ex) {
// No GCP default credentials available
getLog().debug("Failed to load Google application default credentials", ex);
}
}
if (credentials == null) {
return null;
}
return ContainerRegistryAuthSupplier.forCredentials(credentials).build();
}