From 0f743bc5adba939e71953f6d7eae40cdc476b8f6 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Tue, 29 Aug 2023 16:49:42 +0200 Subject: [PATCH] chore(camel-k): Allow to set camel-kamelets version for Camel JBang --- .../yaks/camelk/jbang/CamelJBang.java | 5 +++++ .../yaks/camelk/jbang/CamelJBangSettings.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBang.java b/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBang.java index a7b2ab34..f4b540c2 100644 --- a/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBang.java +++ b/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBang.java @@ -303,6 +303,11 @@ private static void addTrust() { private static List camel(String... args) { List jBangArgs = new ArrayList<>(); jBangArgs.add(String.format("-Dcamel.jbang.version=%s", CamelJBangSettings.getCamelVersion())); + + if (!CamelJBangSettings.getKameletsVersion().isBlank()) { + jBangArgs.add(String.format("-Dcamel-kamelets.version=%s", CamelJBangSettings.getKameletsVersion())); + } + jBangArgs.add(CamelJBangSettings.getCamelApp()); jBangArgs.addAll(List.of(args)); diff --git a/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBangSettings.java b/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBangSettings.java index d2f8489d..18cc35f6 100644 --- a/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBangSettings.java +++ b/java/steps/yaks-camel-k/src/main/java/org/citrusframework/yaks/camelk/jbang/CamelJBangSettings.java @@ -37,6 +37,10 @@ public final class CamelJBangSettings { private static final String CAMEL_VERSION_ENV = JBANG_ENV_PREFIX + "CAMEL_VERSION"; private static final String CAMEL_VERSION_DEFAULT = "3.20.4"; + private static final String KAMELETS_VERSION_PROPERTY = JBANG_PROPERTY_PREFIX + "kamelets.version"; + private static final String KAMELETS_VERSION_ENV = JBANG_ENV_PREFIX + "KAMELETS_VERSION"; + private static final String KAMELETS_VERSION_DEFAULT = ""; + private static final String KAMELETS_LOCAL_DIR_PROPERTY = JBANG_PROPERTY_PREFIX + "kamelets.local.dir"; private static final String KAMELETS_LOCAL_DIR_ENV = JBANG_ENV_PREFIX + "KAMELETS_LOCAL_DIR"; @@ -148,4 +152,13 @@ public static String getCamelVersion() { System.getenv(CAMEL_VERSION_ENV) != null ? System.getenv(CAMEL_VERSION_ENV) : CAMEL_VERSION_DEFAULT); } + /** + * Kamelets version used by the JBang runtime. + * @return + */ + public static String getKameletsVersion() { + return System.getProperty(KAMELETS_VERSION_PROPERTY, + System.getenv(KAMELETS_VERSION_ENV) != null ? System.getenv(KAMELETS_VERSION_ENV) : KAMELETS_VERSION_DEFAULT); + } + }