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

Maven release v0.9.13 #1153

Merged
merged 5 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -133,8 +133,8 @@ private static String mapToDockerfileString(Map<String, String> map, String comm
@Nullable private String baseImage;
@Nullable private List<String> entrypoint;
@Nullable private List<String> programArguments;
@Nullable private Map<String, String> environment;
@Nullable private String user;
private Map<String, String> environment = Collections.emptyMap();
private List<String> exposedPorts = Collections.emptyList();
private Map<String, String> labels = Collections.emptyMap();

Expand Down Expand Up @@ -219,7 +219,7 @@ public JavaDockerContextGenerator setProgramArguments(@Nullable List<String> pro
* @param environment map from the environment variable name to value
* @return this
*/
public JavaDockerContextGenerator setEnvironment(Map<String, String> environment) {
public JavaDockerContextGenerator setEnvironment(@Nullable Map<String, String> environment) {
this.environment = environment;
return this;
}
Expand Down Expand Up @@ -336,7 +336,9 @@ String makeDockerfile() throws JsonProcessingException {
dockerfile.append("\nEXPOSE ").append(port);
}

dockerfile.append(mapToDockerfileString(environment, "ENV"));
if (environment != null) {
dockerfile.append(mapToDockerfileString(environment, "ENV"));
TadCordle marked this conversation as resolved.
Show resolved Hide resolved
}
dockerfile.append(mapToDockerfileString(labels, "LABEL"));
if (entrypoint != null) {
dockerfile.append("\nENTRYPOINT ").append(objectMapper.writeValueAsString(entrypoint));
Expand Down
6 changes: 6 additions & 0 deletions jib-maven-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ All notable changes to this project will be documented in this file.

### Fixed

## 0.9.13

### Fixed

- Adds environment variable configuration to Docker context generator ([#890 (comment)](https://github.com/GoogleContainerTools/jib/issues/890#issuecomment-430227555))

## 0.9.11

### Added
Expand Down
2 changes: 1 addition & 1 deletion jib-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>0.9.12-SNAPSHOT</version>
<version>0.9.14-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Jib</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void execute() throws MojoExecutionException {
.setEntrypoint(entrypoint)
.setProgramArguments(getArgs())
.setExposedPorts(getExposedPorts())
.setEnvironment(getEnvironment())
.setLabels(getLabels())
.setUser(getUser())
.generate(Paths.get(targetDir));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package com.google.cloud.tools.jib.maven;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.apache.maven.model.Build;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -119,6 +121,11 @@ public void testGenerateDockerContext_errorOnWindowsAppRootWithDriveLetter() {
}

@Test
public void testGeneratedDockerContext_env() throws MojoExecutionException, IOException {
mojo.execute();
Assert.assertEquals("ENV envKey=\"envVal\"", getDockerfileLine("ENV"));
}

public void testBaseImage_nonWarPackaging() throws MojoExecutionException, IOException {
mojo.execute();

Expand Down Expand Up @@ -234,6 +241,11 @@ String getMainClass() {
String getAppRoot() {
return appRoot;
}

@Override
Map<String, String> getEnvironment() {
return ImmutableMap.of("envKey", "envVal");
}
}

@Nullable
Expand Down