Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow comma separated list of container names in dependsOn elements #810

Merged
merged 2 commits into from
Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion samples/custom-net/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<alias>box2</alias>
</network>
<dependsOn>
<dependsOn>box1</dependsOn>
<container>box1</container>
</dependsOn>
<namingStrategy>none</namingStrategy>
<cmd>
Expand Down
1 change: 1 addition & 0 deletions src/main/asciidoc/inc/start/_depends-on.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Your containers should preferably be able to deal with temporarily unresolvable

The `<dependsOn>` configuration can be used to expresses custom network dependencies between your containers. `docker:start` will ensure that all dependencies a container depends on are completely started (fulfilling all `<wait>` conditions) before the depending container is started.

Additionally, each `<container>` element can specify a comma separated set of containers. Comma (and whitespace) can be used to separate containers since valid docker container names contain only characters, digits, underscores, periods and dashes.

.Example
[source,xml]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void addVolumes(RunImageConfiguration runConfig, List<String> ret) {

private void addLinks(RunImageConfiguration runConfig, List<String> ret) {
// Custom networks can have circular links, no need to be considered for the starting order.
if (runConfig.getLinks() != null && !runConfig.getNetworkingConfig().isCustomNetwork()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that getLinks() is never null ?

Copy link
Contributor Author

@chonton chonton Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added @Nonnull annotations to show the deduction chain. EnvUtil.splitAtCommasAndTrim(Iterable<String> input) never returns null.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm settled then ;-)

if (!runConfig.getNetworkingConfig().isCustomNetwork()) {
for (String[] link : EnvUtil.splitOnLastColon(runConfig.getLinks())) {
ret.add(link[0]);
}
Expand All @@ -114,7 +114,7 @@ private void addContainerNetwork(RunImageConfiguration runConfig, List<String> r

private void addDependsOn(RunImageConfiguration runConfig, List<String> ret) {
// Only used in custom networks.
if (runConfig.getDependsOn() != null && runConfig.getNetworkingConfig().isCustomNetwork()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't getDependsOn() be null ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise.

if (runConfig.getNetworkingConfig().isCustomNetwork()) {
for (String link : runConfig.getDependsOn()) {
ret.add(link);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public String getDomainname() {
}

public List<String> getDependsOn() {
return dependsOn;
return EnvUtil.splitAtCommasAndTrim(dependsOn);
}

public String getUser() {
Expand Down