Skip to content

Commit

Permalink
Merge pull request spotify#473 from elifarley/master
Browse files Browse the repository at this point in the history
Fix docker-lab/helios#462 (Authentication against private registry.hub.docker.com repositories)
  • Loading branch information
mattnworb authored Aug 18, 2016
2 parents a84a946 + 65bf453 commit 3c985eb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/com/spotify/docker/client/DefaultDockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,7 @@ public static class Builder {
private long readTimeoutMillis = DEFAULT_READ_TIMEOUT_MILLIS;
private int connectionPoolSize = DEFAULT_CONNECTION_POOL_SIZE;
private DockerCertificates dockerCertificates;
private boolean dockerAuth;
private AuthConfig authConfig;
private Map<String, Object> headers = new HashMap<>();

Expand Down Expand Up @@ -1989,6 +1990,21 @@ public Builder connectionPoolSize(final int connectionPoolSize) {
return this;
}

public boolean dockerAuth() {
return dockerAuth;
}

/**
* Allows reusing Docker auth info
*
* @param dockerAuth tells if Docker auth info should be used
* @return Builder
*/
public Builder dockerAuth(final boolean dockerAuth) {
this.dockerAuth = dockerAuth;
return this;
}

public AuthConfig authConfig() {
return authConfig;
}
Expand All @@ -2005,6 +2021,13 @@ public Builder authConfig(final AuthConfig authConfig) {
}

public DefaultDockerClient build() {
if (dockerAuth) {
try {
this.authConfig = AuthConfig.fromDockerConfig().build();
} catch (IOException e) {
log.warn("Unable to use Docker auth info", e);
}
}
return new DefaultDockerClient(this);
}

Expand Down

0 comments on commit 3c985eb

Please sign in to comment.