Merge branch '2.7.x'
This commit is contained in:
@@ -57,6 +57,9 @@ The following table summarizes the available parameters:
|
||||
|
||||
| `certPath`
|
||||
| Path to certificate and key files for HTTPS (required if `tlsVerify` is `true`, ignored otherwise)
|
||||
|
||||
| `bindHostToBuilder`
|
||||
| When `true`, the value of the `host` property will be provided to the container that is created for the CNB builder (optional)
|
||||
|===
|
||||
|
||||
For more details, see also <<build-image.examples.docker,examples>>.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,8 @@ public class Docker {
|
||||
|
||||
private String certPath;
|
||||
|
||||
private boolean bindHostToBuilder;
|
||||
|
||||
private DockerRegistry builderRegistry;
|
||||
|
||||
private DockerRegistry publishRegistry;
|
||||
@@ -74,6 +76,18 @@ public class Docker {
|
||||
this.certPath = certPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to use the configured Docker host in the builder container.
|
||||
* @return {@code true} to use the configured Docker host in the builder container
|
||||
*/
|
||||
public boolean isBindHostToBuilder() {
|
||||
return this.bindHostToBuilder;
|
||||
}
|
||||
|
||||
void setBindHostToBuilder(boolean bindHostToBuilder) {
|
||||
this.bindHostToBuilder = bindHostToBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration of the Docker registry where builder and run images are stored.
|
||||
* @return the registry configuration
|
||||
@@ -117,6 +131,7 @@ public class Docker {
|
||||
DockerConfiguration asDockerConfiguration() {
|
||||
DockerConfiguration dockerConfiguration = new DockerConfiguration();
|
||||
dockerConfiguration = customizeHost(dockerConfiguration);
|
||||
dockerConfiguration = dockerConfiguration.withBindHostToBuilder(this.bindHostToBuilder);
|
||||
dockerConfiguration = customizeBuilderAuthentication(dockerConfiguration);
|
||||
dockerConfiguration = customizePublishAuthentication(dockerConfiguration);
|
||||
return dockerConfiguration;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,6 +52,24 @@ class DockerTests {
|
||||
assertThat(host.getAddress()).isEqualTo("docker.example.com");
|
||||
assertThat(host.isSecure()).isEqualTo(true);
|
||||
assertThat(host.getCertificatePath()).isEqualTo("/tmp/ca-cert");
|
||||
assertThat(dockerConfiguration.isBindHostToBuilder()).isFalse();
|
||||
assertThat(docker.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
|
||||
assertThat(docker.asDockerConfiguration().getPublishRegistryAuthentication()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void asDockerConfigurationWithBindHostToBuilder() {
|
||||
Docker docker = new Docker();
|
||||
docker.setHost("docker.example.com");
|
||||
docker.setTlsVerify(true);
|
||||
docker.setCertPath("/tmp/ca-cert");
|
||||
docker.setBindHostToBuilder(true);
|
||||
DockerConfiguration dockerConfiguration = docker.asDockerConfiguration();
|
||||
DockerHost host = dockerConfiguration.getHost();
|
||||
assertThat(host.getAddress()).isEqualTo("docker.example.com");
|
||||
assertThat(host.isSecure()).isEqualTo(true);
|
||||
assertThat(host.getCertificatePath()).isEqualTo("/tmp/ca-cert");
|
||||
assertThat(dockerConfiguration.isBindHostToBuilder()).isTrue();
|
||||
assertThat(docker.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
|
||||
assertThat(docker.asDockerConfiguration().getPublishRegistryAuthentication()).isNull();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user