From 2fd7dbc91e8f208b9ba536ad81875a2b988c3699 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Thu, 5 Sep 2024 16:43:21 +0530 Subject: [PATCH] fix(openshift): build fails with imageStream for buildRecreate value No need to convert value to lowercase when parsing string value to enum Signed-off-by: Rohan Kumar --- CHANGELOG.md | 1 + .../jkube/kit/common/BuildRecreateMode.java | 2 +- .../kit/common/BuildRecreateModeTest.java | 42 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/BuildRecreateModeTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bfa85efa0..bbc7f2b3a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Usage: ### 1.18-SNAPSHOT * Fix #1125: Support WebFlux SpringBoot projects when it comes to generate probes for actuators * Fix #2844: `oc:build` on openshift use `pods/log` to retrieve logs from build +* Fix #3354: Build fails with `imageStream` for `buildRecreate` value ### 1.17.0 (2024-08-13) * Fix #494: Support for Micronaut Framework Native Images diff --git a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/BuildRecreateMode.java b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/BuildRecreateMode.java index e6ed68a0f2..2b0982597a 100644 --- a/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/BuildRecreateMode.java +++ b/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/BuildRecreateMode.java @@ -57,7 +57,7 @@ public static BuildRecreateMode fromParameter(String param) { } else if (param.equalsIgnoreCase("true")) { return all; } - return valueOf(param.toLowerCase()); + return valueOf(param); } BuildRecreateMode(boolean bc, boolean is) { diff --git a/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/BuildRecreateModeTest.java b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/BuildRecreateModeTest.java new file mode 100644 index 0000000000..7a208301f9 --- /dev/null +++ b/jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/BuildRecreateModeTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Red Hat, Inc. + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at: + * + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.jkube.kit.common; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +class BuildRecreateModeTest { + static Stream fromParameterSource() { + return Stream.of( + arguments("buildConfig", BuildRecreateMode.buildConfig), + arguments("bc", BuildRecreateMode.bc), + arguments("imageStream", BuildRecreateMode.imageStream), + arguments("is", BuildRecreateMode.is), + arguments("all", BuildRecreateMode.all), + arguments("none", BuildRecreateMode.none) + ); + } + + @ParameterizedTest(name = "fromParameter({0}) should return {1}") + @MethodSource("fromParameterSource") + void fromParameter_shouldParseEnumCorrectly(String param, BuildRecreateMode expectedValue) { + assertThat(BuildRecreateMode.fromParameter(param)).isEqualTo(expectedValue); + } +}