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

Make Jib env var handling consistent with Kubernetes env vars handling #17948

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Changes from all 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 @@ -405,7 +405,7 @@ private JibContainerBuilder createContainerBuilderFromFastJar(JibConfig jibConfi
.addLayer(Collections.singletonList(componentsPath.resolve(JarResultBuildStep.QUARKUS)), workDirInContainer)
.setWorkingDirectory(workDirInContainer)
.setEntrypoint(entrypoint)
.setEnvironment(jibConfig.environmentVariables)
.setEnvironment(getEnvironmentVariables(jibConfig))
.setLabels(allLabels(jibConfig, containerImageLabels))
.setCreationTime(Instant.now());
for (int port : jibConfig.ports) {
Expand Down Expand Up @@ -480,7 +480,7 @@ private JibContainerBuilder createContainerBuilderFromLegacyJar(JibConfig jibCon
}

JibContainerBuilder jibContainerBuilder = javaContainerBuilder.toContainerBuilder()
.setEnvironment(jibConfig.environmentVariables)
.setEnvironment(getEnvironmentVariables(jibConfig))
.setLabels(allLabels(jibConfig, containerImageLabels))
.setCreationTime(Instant.now());

Expand Down Expand Up @@ -519,7 +519,7 @@ private JibContainerBuilder createContainerBuilderFromNative(ContainerImageConfi
.build())
.setWorkingDirectory(workDirInContainer)
.setEntrypoint(entrypoint)
.setEnvironment(jibConfig.environmentVariables)
.setEnvironment(getEnvironmentVariables(jibConfig))
.setLabels(allLabels(jibConfig, containerImageLabels))
.setCreationTime(Instant.now());
for (int port : jibConfig.ports) {
Expand All @@ -531,6 +531,18 @@ private JibContainerBuilder createContainerBuilderFromNative(ContainerImageConfi
}
}

private Map<String, String> getEnvironmentVariables(JibConfig jibConfig) {
Map<String, String> original = jibConfig.environmentVariables;
if (original.isEmpty()) {
return original;
}
Map<String, String> converted = new HashMap<>();
for (Map.Entry<String, String> entry : original.entrySet()) {
converted.put(entry.getKey().toUpperCase().replace('-', '_').replace('.', '_').replace('/', '_'), entry.getValue());
}
return converted;
}

/**
* Allow users to have custom files in {@code src/main/jib} that will be copied into the built container's file system
* in same manner as the Jib Maven and Gradle plugins do.
Expand Down