From a80a37e698aa5b8b5a88c238ed888ba287d64a7b Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 13 May 2024 16:28:43 +0200 Subject: [PATCH] Make parseVCSUri less brittle Fixes #40369 --- .../deployment/KubernetesCommonHelper.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java index f2075c21cd51e..f83be2afcc74f 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java @@ -1194,9 +1194,19 @@ private static List toPolicyRulesList(Map } private static String parseVCSUri(VCSUriConfig config, ScmInfo scm) { - if (config.enabled) { - return config.override.orElseGet(() -> scm != null ? Git.sanitizeRemoteUrl(scm.getRemote().get("origin")) : null); + if (!config.enabled) { + return null; } - return null; + if (config.override.isPresent()) { + return config.override.get(); + } + if (scm == null) { + return null; + } + String originRemote = scm.getRemote().get("origin"); + if (originRemote == null || originRemote.isBlank()) { + return null; + } + return Git.sanitizeRemoteUrl(originRemote); } }