diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeConfig.java index ed5c47c786952..4474a28da851e 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeConfig.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeConfig.java @@ -255,6 +255,12 @@ public class KnativeConfig implements PlatformConfiguration { @ConfigItem(defaultValue = "false") boolean idempotent; + /** + * VCS URI annotation configuration. + */ + @ConfigItem + VCSUriConfig vcsUri; + public Optional getPartOf() { return partOf; } @@ -542,6 +548,11 @@ public boolean isIdempotent() { return idempotent; } + @Override + public VCSUriConfig getVCSUri() { + return vcsUri; + } + @Override public RbacConfig getRbacConfig() { return rbac; 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 7a4c4405ff3ff..b3411046f40d5 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 @@ -973,7 +973,7 @@ private static List createAnnotationDecorators(Optional { ScmInfo scm = p.getScmInfo(); - String vcsUrl = scm != null ? scm.getRemote().get("origin") : null; + String vcsUri = parseVCSUri(config.getVCSUri(), scm); String commitId = scm != null ? scm.getCommit() : null; // Dekorate uses its own annotations. Let's replace them with the quarkus ones. @@ -987,10 +987,10 @@ private static List createAnnotationDecorators(Optional toPolicyRulesList(Map .build()) .collect(Collectors.toList()); } + + private static String parseVCSUri(VCSUriConfig config, ScmInfo scm) { + if (config.enabled) { + return config.override.orElseGet(() -> scm != null ? Git.sanitizeRemoteUrl(scm.getRemote().get("origin")) : null); + } + return null; + } } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java index ebab056064d48..f5aa8bf024442 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesConfig.java @@ -381,6 +381,12 @@ public class KubernetesConfig implements PlatformConfiguration { @ConfigItem(defaultValue = "false") boolean idempotent; + /** + * VCS URI annotation configuration. + */ + @ConfigItem + VCSUriConfig vcsUri; + /** * Optionally set directory generated kubernetes resources will be written to. Default is `target/kubernetes`. */ @@ -600,6 +606,11 @@ public boolean isIdempotent() { return idempotent; } + @Override + public VCSUriConfig getVCSUri() { + return vcsUri; + } + public DeployStrategy getDeployStrategy() { return deployStrategy; } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftConfig.java index afdd1b33e9a3d..89c6fb56ddc1f 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftConfig.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/OpenshiftConfig.java @@ -587,6 +587,12 @@ public EnvVarsConfig getEnv() { @ConfigItem(defaultValue = "false") boolean idempotent; + /** + * VCS URI annotation configuration. + */ + @ConfigItem + VCSUriConfig vcsUri; + public Optional getAppSecret() { return this.appSecret; } @@ -605,6 +611,11 @@ public boolean isIdempotent() { return idempotent; } + @Override + public VCSUriConfig getVCSUri() { + return vcsUri; + } + public DeployStrategy getDeployStrategy() { return deployStrategy; } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/PlatformConfiguration.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/PlatformConfiguration.java index 2710ef71d8675..adea6a48e2512 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/PlatformConfiguration.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/PlatformConfiguration.java @@ -95,4 +95,6 @@ default String getConfigName() { SecurityContextConfig getSecurityContext(); boolean isIdempotent(); + + VCSUriConfig getVCSUri(); } diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VCSUriConfig.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VCSUriConfig.java new file mode 100644 index 0000000000000..3afdcbe912f1c --- /dev/null +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/VCSUriConfig.java @@ -0,0 +1,22 @@ +package io.quarkus.kubernetes.deployment; + +import java.util.Optional; + +import io.quarkus.runtime.annotations.ConfigGroup; +import io.quarkus.runtime.annotations.ConfigItem; + +@ConfigGroup +public class VCSUriConfig { + + /** + * Whether the vcs-uri annotation should be added to the generated configuration. + */ + @ConfigItem(defaultValue = "true") + boolean enabled; + + /** + * Optional override of the vcs-uri annotation. + */ + @ConfigItem + Optional override; +}