use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.
the class BuildImageMojo method buildImage.
private void buildImage() throws MojoExecutionException {
Libraries libraries = getLibraries(Collections.emptySet());
try {
DockerConfiguration dockerConfiguration = (this.docker != null) ? this.docker.asDockerConfiguration() : null;
BuildRequest request = getBuildRequest(libraries);
Builder builder = new Builder(new MojoBuildLog(this::getLog), dockerConfiguration);
builder.build(request);
} catch (IOException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.
the class Docker method asDockerConfiguration.
/**
* Returns this configuration as a {@link DockerConfiguration} instance. This method
* should only be called when the configuration is complete and will no longer be
* changed.
* @return the Docker configuration
*/
DockerConfiguration asDockerConfiguration() {
DockerConfiguration dockerConfiguration = new DockerConfiguration();
dockerConfiguration = customizeHost(dockerConfiguration);
dockerConfiguration = customizeBuilderAuthentication(dockerConfiguration);
dockerConfiguration = customizePublishAuthentication(dockerConfiguration);
return dockerConfiguration;
}
use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.
the class DockerSpecTests method asDockerConfigurationWithTokenAuth.
@Test
void asDockerConfigurationWithTokenAuth() {
DockerSpec dockerSpec = new DockerSpec(new DockerSpec.DockerRegistrySpec("token1"), new DockerSpec.DockerRegistrySpec("token2"));
DockerConfiguration dockerConfiguration = dockerSpec.asDockerConfiguration();
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())).contains("\"identitytoken\" : \"token1\"");
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader())).contains("\"identitytoken\" : \"token2\"");
}
use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.
the class DockerSpecTests method asDockerConfigurationWithUserAuth.
@Test
void asDockerConfigurationWithUserAuth() {
DockerSpec dockerSpec = new DockerSpec(new DockerSpec.DockerRegistrySpec("user1", "secret1", "https://docker1.example.com", "docker1@example.com"), new DockerSpec.DockerRegistrySpec("user2", "secret2", "https://docker2.example.com", "docker2@example.com"));
DockerConfiguration dockerConfiguration = dockerSpec.asDockerConfiguration();
assertThat(decoded(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())).contains("\"username\" : \"user1\"").contains("\"password\" : \"secret1\"").contains("\"email\" : \"docker1@example.com\"").contains("\"serveraddress\" : \"https://docker1.example.com\"");
assertThat(decoded(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader())).contains("\"username\" : \"user2\"").contains("\"password\" : \"secret2\"").contains("\"email\" : \"docker2@example.com\"").contains("\"serveraddress\" : \"https://docker2.example.com\"");
assertThat(dockerSpec.asDockerConfiguration().getHost()).isNull();
}
use of org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration in project spring-boot by spring-projects.
the class DockerSpecTests method asDockerConfigurationWithHostConfiguration.
@Test
void asDockerConfigurationWithHostConfiguration() {
DockerSpec dockerSpec = new DockerSpec();
dockerSpec.setHost("docker.example.com");
dockerSpec.setTlsVerify(true);
dockerSpec.setCertPath("/tmp/ca-cert");
DockerConfiguration dockerConfiguration = dockerSpec.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(dockerSpec.asDockerConfiguration().getBuilderRegistryAuthentication()).isNull();
assertThat(dockerSpec.asDockerConfiguration().getPublishRegistryAuthentication()).isNull();
}
Aggregations