Skip to content

Commit

Permalink
Allow establishing docker container startup dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo authored and losipiuk committed Sep 30, 2020
1 parent 58f6742 commit 6e9014a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,15 @@ public String getEnvironmentName()
return name;
}

public Builder containerDependsOn(String container, String dependencyContainer)
{
checkState(containers.containsKey(container), "Container with name %s is not registered", name);
checkState(containers.containsKey(dependencyContainer), "Dependency container with name %s is not registered", dependencyContainer);
containers.get(container).dependsOn(containers.get(dependencyContainer));

return this;
}

public Builder addContainers(DockerContainer... containers)
{
Arrays.stream(containers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public Kafka(PortBinder portBinder)
@Override
public void extendEnvironment(Environment.Builder builder)
{
builder.addContainers(createZookeeper(), createKafka());
builder.addContainers(createZookeeper(), createKafka())
.containerDependsOn("kafka", "zookeeper");
}

@SuppressWarnings("resource")
Expand Down

0 comments on commit 6e9014a

Please sign in to comment.