Add property to specify Docker Compose flags
See gh-42571
This commit is contained in:
committed by
Moritz Halbritter
parent
31fada6d3e
commit
2bee29c2fd
@@ -106,6 +106,7 @@ class DefaultDockerComposeTests {
|
||||
HostConfig hostConfig = null;
|
||||
DockerCliInspectResponse inspectResponse = new DockerCliInspectResponse(id, config, networkSettings,
|
||||
hostConfig);
|
||||
willReturn(mock(DockerCompose.Options.class)).given(this.cli).getDockerComposeOptions();
|
||||
willReturn(List.of(psResponse)).given(this.cli).run(new DockerCliCommand.ComposePs());
|
||||
willReturn(List.of(inspectResponse)).given(this.cli).run(new DockerCliCommand.Inspect(List.of(id)));
|
||||
DefaultDockerCompose compose = new DefaultDockerCompose(this.cli, HOST);
|
||||
@@ -132,6 +133,7 @@ class DefaultDockerComposeTests {
|
||||
hostConfig);
|
||||
willReturn(List.of(new DockerCliContextResponse("test", true, "https://192.168.1.1"))).given(this.cli)
|
||||
.run(new DockerCliCommand.Context());
|
||||
willReturn(mock(DockerCompose.Options.class)).given(this.cli).getDockerComposeOptions();
|
||||
willReturn(List.of(psResponse)).given(this.cli).run(new DockerCliCommand.ComposePs());
|
||||
willReturn(List.of(inspectResponse)).given(this.cli).run(new DockerCliCommand.Inspect(List.of(id)));
|
||||
DefaultDockerCompose compose = new DefaultDockerCompose(this.cli, null);
|
||||
@@ -148,6 +150,7 @@ class DefaultDockerComposeTests {
|
||||
DockerCliComposePsResponse psResponse = new DockerCliComposePsResponse(shortId, "name", "redis", "running");
|
||||
Config config = new Config("redis", Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList());
|
||||
DockerCliInspectResponse inspectResponse = new DockerCliInspectResponse(longId, config, null, null);
|
||||
willReturn(mock(DockerCompose.Options.class)).given(this.cli).getDockerComposeOptions();
|
||||
willReturn(List.of(new DockerCliContextResponse("test", true, "https://192.168.1.1"))).given(this.cli)
|
||||
.run(new DockerCliCommand.Context());
|
||||
willReturn(List.of(psResponse)).given(this.cli).run(new DockerCliCommand.ComposePs());
|
||||
|
||||
@@ -75,6 +75,8 @@ class DockerComposeLifecycleManagerTests {
|
||||
|
||||
private Set<String> activeProfiles;
|
||||
|
||||
private List<String> arguments;
|
||||
|
||||
private GenericApplicationContext applicationContext;
|
||||
|
||||
private TestSpringApplicationShutdownHandlers shutdownHandlers;
|
||||
@@ -358,6 +360,14 @@ class DockerComposeLifecycleManagerTests {
|
||||
assertThat(this.activeProfiles).containsExactly("my-profile");
|
||||
}
|
||||
|
||||
@Test
|
||||
void startGetsDockerComposeWithArguments() {
|
||||
this.properties.getArguments().add("--project-name=test");
|
||||
setUpRunningServices();
|
||||
this.lifecycleManager.start();
|
||||
assertThat(this.arguments).containsExactly("--project-name=test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void startPublishesEvent() {
|
||||
EventCapturingListener listener = new EventCapturingListener();
|
||||
@@ -519,8 +529,10 @@ class DockerComposeLifecycleManagerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DockerCompose getDockerCompose(DockerComposeFile composeFile, Set<String> activeProfiles) {
|
||||
protected DockerCompose getDockerCompose(DockerComposeFile composeFile, Set<String> activeProfiles,
|
||||
List<String> arguments) {
|
||||
DockerComposeLifecycleManagerTests.this.activeProfiles = activeProfiles;
|
||||
DockerComposeLifecycleManagerTests.this.arguments = arguments;
|
||||
return DockerComposeLifecycleManagerTests.this.dockerCompose;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class DockerComposePropertiesTests {
|
||||
@Test
|
||||
void getWhenPropertiesReturnsBound() {
|
||||
Map<String, String> source = new LinkedHashMap<>();
|
||||
source.put("spring.docker.compose.arguments", "--project-name=test,--progress=auto");
|
||||
source.put("spring.docker.compose.file", "my-compose.yml");
|
||||
source.put("spring.docker.compose.lifecycle-management", "start-only");
|
||||
source.put("spring.docker.compose.host", "myhost");
|
||||
@@ -76,6 +77,7 @@ class DockerComposePropertiesTests {
|
||||
source.put("spring.docker.compose.readiness.tcp.read-timeout", "500ms");
|
||||
Binder binder = new Binder(new MapConfigurationPropertySource(source));
|
||||
DockerComposeProperties properties = DockerComposeProperties.get(binder);
|
||||
assertThat(properties.getArguments()).containsExactly("--project-name=test", "--progress=auto");
|
||||
assertThat(properties.getFile()).containsExactly(new File("my-compose.yml"));
|
||||
assertThat(properties.getLifecycleManagement()).isEqualTo(LifecycleManagement.START_ONLY);
|
||||
assertThat(properties.getHost()).isEqualTo("myhost");
|
||||
|
||||
Reference in New Issue
Block a user