Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable both public and private repository for pulling image during bootBuildImage #24549

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ private Image getImage(BuildRequest request, ImageType imageType) throws IOExcep
private Image pullImage(ImageReference reference, ImageType imageType) throws IOException {
Consumer<TotalProgressEvent> progressConsumer = this.log.pullingImage(reference, imageType);
TotalProgressPullListener listener = new TotalProgressPullListener(progressConsumer);
Image image = this.docker.image().pull(reference, listener, getBuilderAuthHeader());
String registryUrl = this.dockerConfiguration.getRegistryUrl();
String authHeader = null;
if (registryUrl != null && registryUrl.contains(reference.getDomain())) {
authHeader = getBuilderAuthHeader();
}
Image image = this.docker.image().pull(reference, listener, authHeader);
this.log.pulledImage(image, imageType);
return image;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,33 @@ public final class DockerConfiguration {

private final DockerRegistryAuthentication publishAuthentication;

private final String registryUrl;

public DockerConfiguration() {
this(null, null, null);
}

private DockerConfiguration(DockerHost host, DockerRegistryAuthentication builderAuthentication,
DockerRegistryAuthentication publishAuthentication) {
this(host, builderAuthentication, publishAuthentication, null);
}

private DockerConfiguration(DockerHost host, DockerRegistryAuthentication builderAuthentication,
DockerRegistryAuthentication publishAuthentication, String registryUrl) {
this.host = host;
this.builderAuthentication = builderAuthentication;
this.publishAuthentication = publishAuthentication;
this.registryUrl = registryUrl;
}

public DockerHost getHost() {
return this.host;
}

public String getRegistryUrl() {
return this.registryUrl;
}

public DockerRegistryAuthentication getBuilderRegistryAuthentication() {
return this.builderAuthentication;
}
Expand All @@ -73,7 +85,7 @@ public DockerConfiguration withBuilderRegistryUserAuthentication(String username
Assert.notNull(username, "Username must not be null");
Assert.notNull(password, "Password must not be null");
return new DockerConfiguration(this.host, new DockerRegistryUserAuthentication(username, password, url, email),
this.publishAuthentication);
this.publishAuthentication, url);
}

public DockerConfiguration withPublishRegistryTokenAuthentication(String token) {
Expand Down