use of org.springframework.boot.buildpack.platform.docker.type.ContainerReference in project spring-boot by spring-projects.
the class BuilderTests method mockDockerApi.
private DockerApi mockDockerApi() throws IOException {
ContainerApi containerApi = mock(ContainerApi.class);
ContainerReference reference = ContainerReference.of("container-ref");
given(containerApi.create(any(), any())).willReturn(reference);
given(containerApi.wait(eq(reference))).willReturn(ContainerStatus.of(0, null));
ImageApi imageApi = mock(ImageApi.class);
VolumeApi volumeApi = mock(VolumeApi.class);
DockerApi docker = mock(DockerApi.class);
given(docker.image()).willReturn(imageApi);
given(docker.container()).willReturn(containerApi);
given(docker.volume()).willReturn(volumeApi);
return docker;
}
use of org.springframework.boot.buildpack.platform.docker.type.ContainerReference in project spring-boot by spring-projects.
the class BuilderTests method mockDockerApiLifecycleError.
private DockerApi mockDockerApiLifecycleError() throws IOException {
ContainerApi containerApi = mock(ContainerApi.class);
ContainerReference reference = ContainerReference.of("container-ref");
given(containerApi.create(any(), any())).willReturn(reference);
given(containerApi.wait(eq(reference))).willReturn(ContainerStatus.of(9, null));
ImageApi imageApi = mock(ImageApi.class);
VolumeApi volumeApi = mock(VolumeApi.class);
DockerApi docker = mock(DockerApi.class);
given(docker.image()).willReturn(imageApi);
given(docker.container()).willReturn(containerApi);
given(docker.volume()).willReturn(volumeApi);
return docker;
}
use of org.springframework.boot.buildpack.platform.docker.type.ContainerReference in project spring-boot by spring-projects.
the class LifecycleTests method assertPhaseWasRun.
private void assertPhaseWasRun(String name, IOConsumer<ContainerConfig> configConsumer) throws IOException {
ContainerReference containerReference = ContainerReference.of("cnb-lifecycle-" + name);
then(this.docker.container()).should().start(containerReference);
then(this.docker.container()).should().logs(eq(containerReference), any());
then(this.docker.container()).should().remove(containerReference, true);
configConsumer.accept(this.configs.get(containerReference.toString()));
}
use of org.springframework.boot.buildpack.platform.docker.type.ContainerReference in project spring-boot by spring-projects.
the class Lifecycle method run.
private void run(Phase phase) throws IOException {
Consumer<LogUpdateEvent> logConsumer = this.log.runningPhase(this.request, phase.getName());
ContainerConfig containerConfig = ContainerConfig.of(this.builder.getName(), phase::apply);
ContainerReference reference = createContainer(containerConfig);
try {
this.docker.container().start(reference);
this.docker.container().logs(reference, logConsumer::accept);
ContainerStatus status = this.docker.container().wait(reference);
if (status.getStatusCode() != 0) {
throw new BuilderException(phase.getName(), status.getStatusCode());
}
} finally {
this.docker.container().remove(reference, true);
}
}
Aggregations