Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ParsedDockerComposeFile {
SafeConstructor constructor = new SafeConstructor(options) {
@Override
protected Object constructObject(Node node) {
if (node.getTag().equals(new Tag("!reset"))) {
if (node.getTag().equals(new Tag("!reset")) || node.getTag().equals(new Tag("!override"))) {
return null;
}
return super.constructObject(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,35 @@ void resetEnvironment() {
assertThat(container.getConfig().getEnv()).doesNotContain("foo=bar");
}
}

@Test
void readLabel() {
try (
ComposeContainer compose = new ComposeContainer(DockerImageName.parse("docker:25.0.5"), BASE)
.withExposedService("redis", 6379)
) {
compose.start();
InspectContainerResponse container = compose
.getContainerByServiceName("redis-1")
.map(ContainerState::getContainerInfo)
.get();
assertThat(container.getConfig().getLabels()).containsKey("label1");
}
}

@Test
void readOverriddenLabel() {
try (
ComposeContainer compose = new ComposeContainer(DockerImageName.parse("docker:25.0.5"), BASE, OVERRIDE)
.withExposedService("redis", 6379)
) {
compose.start();
InspectContainerResponse container = compose
.getContainerByServiceName("redis-1")
.map(ContainerState::getContainerInfo)
.get();
assertThat(container.getConfig().getLabels()).doesNotContainKey("label1");
assertThat(container.getConfig().getLabels()).containsKey("label2");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ services:
- 6379
environment:
foo: !reset null
labels: !override
label2: value2
2 changes: 2 additions & 0 deletions core/src/test/resources/compose-override/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ services:
- 6379
environment:
foo: bar
labels:
label1: value1