Skip to content

Commit

Permalink
Merge pull request #684 from starlingbank/master
Browse files Browse the repository at this point in the history
Fix handling of Run Commands from properties.
  • Loading branch information
rhuss committed Feb 14, 2017
2 parents 9e10f1b + 837a79d commit ee60a7e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ public Builder ports(List<String> ports) {
}

public Builder runCmds(List<String> theCmds) {
if (config.runCmds == null) {
if (theCmds == null) {
config.runCmds = new ArrayList<>();
} else {
config.runCmds = theCmds;
}
else
config.runCmds = theCmds;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ private List<String> extractPortValues(String prefix, Properties properties) {


private List<String> extractRunCommands(String prefix, Properties properties) {
List<String> ret = new ArrayList<>();
List<String> cmds = listWithPrefix(prefix, RUN, properties);
if (cmds == null) {
return null;
}
return ret;
return listWithPrefix(prefix, RUN, properties);
}

private RestartPolicy extractRestartPolicy(String prefix, Properties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ public void testPorts() throws Exception {
assertArrayEquals(new String[]{"8080", "9090", "80"}, ports);
}

@Test
public void testRunCommands() {
List<ImageConfiguration> configs = resolveImage(
imageConfiguration,props(
"docker.name","demo",
"docker.run.1", "foo",
"docker.run.2", "bar",
"docker.run.3", "wibble")
);

assertEquals(1, configs.size());

BuildImageConfiguration buildConfig = configs.get(0).getBuildConfiguration();
String[] runCommands = new ArrayList<>(buildConfig.getRunCmds()).toArray(new String[buildConfig.getRunCmds().size()]);
assertArrayEquals(new String[]{"foo", "bar", "wibble"}, runCommands);
}

@Test
public void testEnvAndLabels() throws Exception {
List<ImageConfiguration> configs = resolveImage(
Expand Down

0 comments on commit ee60a7e

Please sign in to comment.