Skip to content

Commit 4ef051e

Browse files
authored
fix: make sure that version checking cannot block the extension (#598)
1 parent 4e0e3c6 commit 4ef051e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

core/deployment/src/main/java/io/quarkiverse/operatorsdk/deployment/OperatorSDKProcessor.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,14 @@ void updateControllerConfigurations(
136136
}
137137

138138
private void checkVersionCompatibility(String found, String expected, String name) {
139-
final var foundVersion = Semver.coerce(found);
140-
final var expectedVersion = Semver.coerce(expected);
139+
final var foundVersionOpt = getSemverFrom(found);
140+
final var expectedVersionOpt = getSemverFrom(expected);
141+
if (foundVersionOpt.isEmpty() || expectedVersionOpt.isEmpty()) {
142+
// abort version check if we couldn't parse the version for some reason as a version check should not prevent the rest of the processing to proceed
143+
return;
144+
}
145+
final var foundVersion = foundVersionOpt.get();
146+
final var expectedVersion = expectedVersionOpt.get();
141147
if (!expectedVersion.equals(foundVersion)) {
142148
String message = "Mismatched " + name + " version found: \"" + found + "\", expected: \"" + expected + "\"";
143149
if (buildTimeConfiguration.failOnVersionCheck) {
@@ -154,6 +160,15 @@ private void checkVersionCompatibility(String found, String expected, String nam
154160
}
155161
}
156162

163+
private static Optional<Semver> getSemverFrom(String version) {
164+
try {
165+
return Optional.of(Semver.coerce(version));
166+
} catch (Exception e) {
167+
log.warn("Couldn't convert version " + version);
168+
}
169+
return Optional.empty();
170+
}
171+
157172
@BuildStep
158173
ConfigurationServiceBuildItem createConfigurationServiceAndOperator(
159174
OutputTargetBuildItem outputTarget,

0 commit comments

Comments
 (0)