Skip to content

Commit

Permalink
fix (quarkusio#24885) Do not infer command/args based on s2i image used
Browse files Browse the repository at this point in the history
  • Loading branch information
iocanel committed Sep 12, 2022
1 parent 147dd58 commit 2642001
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public void openshiftRequirementsJvm(OpenshiftConfig openshiftConfig,
String baseJvmImage = config.baseJvmImage
.orElse(OpenshiftConfig.getDefaultJvmImage(compiledJavaVersion.getJavaVersion()));

boolean hasCustomJarPath = config.jarFileName.isPresent() || config.jarDirectory.isPresent();
boolean hasCustomJvmArguments = config.jvmArguments.isPresent();

builderImageProducer.produce(new BaseImageInfoBuildItem(baseJvmImage));
Optional<OpenshiftBaseJavaImage> baseImage = OpenshiftBaseJavaImage.findMatching(baseJvmImage);

Expand All @@ -150,8 +153,9 @@ public void openshiftRequirementsJvm(OpenshiftConfig openshiftConfig,
envProducer.produce(KubernetesEnvBuildItem.createSimpleVar(b.getJvmOptionsEnvVar(),
String.join(" ", config.getEffectiveJvmArguments()), null));
});

//In all other cases its the responsibility of the image to set those up correctly.
if (!baseImage.isPresent()) {
if (hasCustomJarPath || hasCustomJvmArguments) {
List<String> cmd = new ArrayList<>();
cmd.add("java");
cmd.addAll(config.getEffectiveJvmArguments());
Expand Down Expand Up @@ -180,6 +184,9 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig,

String nativeBinaryFileName = null;

boolean hasCustomNativePath = config.nativeBinaryFileName.isPresent() || config.nativeBinaryDirectory.isPresent();
boolean hasCustomNativeArguments = config.nativeArguments.isPresent();

//The default openshift builder for native builds, renames the native binary.
//To make things easier for the user, we need to handle it.
if (usingDefaultBuilder && !config.nativeBinaryFileName.isPresent()) {
Expand All @@ -195,6 +202,7 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig,
// 1. explicitly specified by the user.
// 2. detected via OpenshiftBaseNativeImage
// 3. fallback value

String nativeBinaryDirectory = config.nativeBinaryDirectory
.orElse(baseImage.map(i -> i.getNativeBinaryDirectory()).orElse(config.FALLBACK_NATIVE_BINARY_DIRECTORY));
String pathToNativeBinary = concatUnixPaths(nativeBinaryDirectory, nativeBinaryFileName);
Expand All @@ -209,7 +217,7 @@ public void openshiftRequirementsNative(OpenshiftConfig openshiftConfig,

});

if (!baseImage.isPresent() && config.nativeArguments.isPresent()) {
if (hasCustomNativePath || hasCustomNativeArguments) {
commandProducer
.produce(KubernetesCommandBuildItem.commandWithArgs(pathToNativeBinary, config.nativeArguments.get()));
}
Expand Down

0 comments on commit 2642001

Please sign in to comment.