Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

WIP: adds support for pushing to GCR via mvn deploy. Has failing in… #13

Merged
merged 1 commit into from
Jun 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@
<name>Dockerfile Maven Plugin</name>
<description>Adds support for building Dockerfiles in Maven</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.spotify</groupId>
<artifactId>docker-client</artifactId>
<classifier>shaded</classifier>
<version>4.0.8</version>
<version>8.6.2</version>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.exceptions.DockerCertificateException;

import com.spotify.docker.client.gcr.ContainerRegistryAuthSupplier;
import com.spotify.docker.client.messages.RegistryAuthSupplier;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Objects;

import java.util.concurrent.ExecutorService;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -378,10 +381,21 @@ protected static String formatImageName(@Nonnull String repository, @Nonnull Str

@Nonnull
protected DockerClient openDockerClient() throws MojoExecutionException {
ContainerRegistryAuthSupplier authSupplier = null;
try {
authSupplier = ContainerRegistryAuthSupplier.forApplicationDefaultCredentials()
.build();
getLog().info("Using Google application credentials");
} catch (IOException ex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to catch DockerException as well, which maybe shouldn't be an unchecked exception to begin with? (I realize that would be a breaking change)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// No GCP default credentials available
getLog().debug("Failed to create Google default credentials", ex);
}

try {
return DefaultDockerClient.fromEnv()
.readTimeoutMillis(readTimeoutMillis)
.connectTimeoutMillis(connectTimeoutMillis)
.registryAuthSupplier(authSupplier)
.build();
} catch (DockerCertificateException e) {
throw new MojoExecutionException("Could not load Docker certificates", e);
Expand Down