Skip to content

Commit

Permalink
fixed logic to determine location of dockerfile if dockerFile and doc…
Browse files Browse the repository at this point in the history
…kerFileDir also set

Signed-off-by: Laszlo Meszaros <lacienator@gmail.com>
  • Loading branch information
lmesz committed Dec 21, 2016
1 parent 67fa15b commit 5de287a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,14 @@ public String initAndValidate(Logger log) throws IllegalArgumentException {

// Initialize the dockerfile location and the build mode
private void initDockerFileFile(Logger log) {
if (dockerFile != null) {
if (dockerFile != null && dockerFileDir != null) {
dockerFileFile = new File(dockerFile);
if (dockerFileFile.isAbsolute()) {
throw new IllegalArgumentException("<dockerFile> can not be absolute path if <dockerFileDir> also set.");
}
dockerFileFile = new File(dockerFileDir, dockerFile);
dockerFileMode = true;
} else if (dockerFile != null) {
dockerFileFile = new File(dockerFile);
dockerFileMode = true;
} else if (dockerFileDir != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ public void simpleDockerfileDir() {
assertEquals(config.getDockerFile(),new File("src/docker/Dockerfile"));
}

@Test
public void simpleDockerfileDirAndDockerfile() {
BuildImageConfiguration config =
new BuildImageConfiguration.Builder().
dockerFileDir("/tmp/").
dockerFile("Dockerfile").build();
config.initAndValidate(logger);
assertTrue(config.isDockerFileMode());
assertEquals(config.getDockerFile(),new File("/tmp/Dockerfile"));
}

@Test
public void deprecatedDockerfileDir() {
AssemblyConfiguration assemblyConfig = new AssemblyConfiguration.Builder().dockerFileDir("src/docker").build();
Expand Down

0 comments on commit 5de287a

Please sign in to comment.