This is an automated email from the ASF dual-hosted git repository.
cdeppisch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c56dca33bd4 CAMEL-21088: Support all export options on Kubernetes run
command
c56dca33bd4 is described below
commit c56dca33bd46a710c22721ea80911a9f009b3456
Author: Christoph Deppisch <[email protected]>
AuthorDate: Wed Sep 4 11:31:54 2024 +0200
CAMEL-21088: Support all export options on Kubernetes run command
- Kubernetes run command should support all export command options that
make sense
- Run command delegates the options to the nested export command
---
.../dsl/jbang/core/commands/ExportBaseCommand.java | 10 +-
.../core/commands/kubernetes/KubernetesExport.java | 59 ++++++-
.../core/commands/kubernetes/KubernetesRun.java | 170 ++++++++++++++++-----
3 files changed, 190 insertions(+), 49 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index 43592362b30..e02ea425360 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -105,24 +105,24 @@ public abstract class ExportBaseCommand extends
CamelCommand {
protected String gav;
@CommandLine.Option(names = { "--exclude" }, description = "Exclude files
by name or pattern")
- List<String> excludes = new ArrayList<>();
+ protected List<String> excludes = new ArrayList<>();
@CommandLine.Option(names = { "--maven-settings" },
description = "Optional location of Maven settings.xml
file to configure servers, repositories, mirrors and proxies."
+ " If set to \"false\", not even the
default ~/.m2/settings.xml will be used.")
- String mavenSettings;
+ protected String mavenSettings;
@CommandLine.Option(names = { "--maven-settings-security" },
description = "Optional location of Maven
settings-security.xml file to decrypt settings.xml")
- String mavenSettingsSecurity;
+ protected String mavenSettingsSecurity;
@CommandLine.Option(names = { "--maven-central-enabled" },
description = "Whether downloading JARs from Maven
Central repository is enabled")
- boolean mavenCentralEnabled = true;
+ protected boolean mavenCentralEnabled = true;
@CommandLine.Option(names = { "--maven-apache-snapshot-enabled" },
description = "Whether downloading JARs from ASF Maven
Snapshot repository is enabled")
- boolean mavenApacheSnapshotEnabled = true;
+ protected boolean mavenApacheSnapshotEnabled = true;
@CommandLine.Option(names = { "--main-classname" },
description = "The class name of the Camel Main
application class",
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
index b53c1f3190f..564d9152507 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
@@ -134,13 +134,35 @@ public class KubernetesExport extends Export {
runtime = configurer.runtime;
quarkusVersion = configurer.quarkusVersion;
- symbolicLink = configurer.symbolicLink;
- mavenWrapper = configurer.mavenWrapper;
- gradleWrapper = configurer.gradleWrapper;
- exportDir = configurer.exportDir;
+
files = configurer.files;
gav = configurer.gav;
+ repositories = configurer.repositories;
+ dependencies = configurer.dependencies;
+ excludes = configurer.excludes;
+ mavenSettings = configurer.mavenSettings;
+ mavenSettingsSecurity = configurer.mavenSettingsSecurity;
+ mavenCentralEnabled = configurer.mavenCentralEnabled;
+ mavenApacheSnapshotEnabled = configurer.mavenApacheSnapshotEnabled;
+ javaVersion = configurer.javaVersion;
+ camelVersion = configurer.camelVersion;
+ kameletsVersion = configurer.kameletsVersion;
+ profile = configurer.profile;
+ localKameletDir = configurer.localKameletDir;
+ springBootVersion = configurer.springBootVersion;
+ camelSpringBootVersion = configurer.camelSpringBootVersion;
+ quarkusGroupId = configurer.quarkusGroupId;
+ quarkusArtifactId = configurer.quarkusArtifactId;
+ buildTool = configurer.buildTool;
openapi = configurer.openapi;
+ exportDir = configurer.exportDir;
+ packageName = configurer.packageName;
+ buildProperties = configurer.buildProperties;
+ symbolicLink = configurer.symbolicLink;
+ javaLiveReload = configurer.javaLiveReload;
+ ignoreLoadingError = configurer.ignoreLoadingError;
+ mavenWrapper = configurer.mavenWrapper;
+ gradleWrapper = configurer.gradleWrapper;
fresh = configurer.fresh;
download = configurer.download;
quiet = configurer.quiet;
@@ -492,13 +514,34 @@ public class KubernetesExport extends Export {
*/
public record ExportConfigurer(RuntimeType runtime,
String quarkusVersion,
- boolean symbolicLink,
- boolean mavenWrapper,
- boolean gradleWrapper,
- String exportDir,
List<String> files,
String gav,
+ List<String> repositories,
+ List<String> dependencies,
+ List<String> excludes,
+ String mavenSettings,
+ String mavenSettingsSecurity,
+ boolean mavenCentralEnabled,
+ boolean mavenApacheSnapshotEnabled,
+ String javaVersion,
+ String camelVersion,
+ String kameletsVersion,
+ String profile,
+ String localKameletDir,
+ String springBootVersion,
+ String camelSpringBootVersion,
+ String quarkusGroupId,
+ String quarkusArtifactId,
+ String buildTool,
String openapi,
+ String exportDir,
+ String packageName,
+ List<String> buildProperties,
+ boolean symbolicLink,
+ boolean javaLiveReload,
+ boolean ignoreLoadingError,
+ boolean mavenWrapper,
+ boolean gradleWrapper,
boolean fresh,
boolean download,
boolean quiet,
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
index 7f5d3d31c76..df7eff9e149 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
@@ -152,8 +152,14 @@ public class KubernetesRun extends KubernetesBaseCommand {
description = "List of target platforms. Each platform
is defined using the pattern.")
String imagePlatforms;
- @CommandLine.Option(names = { "--gav" }, description = "The Maven
group:artifact:version")
- String gav;
+ // Export base options
+
+ @CommandLine.Option(names = { "--repository" }, description = "Additional
maven repositories")
+ List<String> repositories = new ArrayList<>();
+
+ @CommandLine.Option(names = { "--dep", "--dependency" }, description =
"Add additional dependencies",
+ split = ",")
+ List<String> dependencies = new ArrayList<>();
@CommandLine.Option(names = { "--runtime" },
completionCandidates =
RuntimeCompletionCandidates.class,
@@ -162,10 +168,76 @@ public class KubernetesRun extends KubernetesBaseCommand {
description = "Runtime (${COMPLETION-CANDIDATES})")
RuntimeType runtime = RuntimeType.quarkus;
+ @CommandLine.Option(names = { "--gav" }, description = "The Maven
group:artifact:version")
+ String gav;
+
+ @CommandLine.Option(names = { "--exclude" }, description = "Exclude files
by name or pattern")
+ List<String> excludes = new ArrayList<>();
+
+ @CommandLine.Option(names = { "--maven-settings" },
+ description = "Optional location of Maven settings.xml
file to configure servers, repositories, mirrors and proxies."
+ + " If set to \"false\", not even the
default ~/.m2/settings.xml will be used.")
+ String mavenSettings;
+
+ @CommandLine.Option(names = { "--maven-settings-security" },
+ description = "Optional location of Maven
settings-security.xml file to decrypt settings.xml")
+ String mavenSettingsSecurity;
+
+ @CommandLine.Option(names = { "--maven-central-enabled" },
+ description = "Whether downloading JARs from Maven
Central repository is enabled")
+ boolean mavenCentralEnabled = true;
+
+ @CommandLine.Option(names = { "--maven-apache-snapshot-enabled" },
+ description = "Whether downloading JARs from ASF Maven
Snapshot repository is enabled")
+ boolean mavenApacheSnapshotEnabled = true;
+
+ @CommandLine.Option(names = { "--java-version" }, description = "Java
version", defaultValue = "17")
+ String javaVersion = "17";
+
+ @CommandLine.Option(names = { "--camel-version" },
+ description = "To export using a different Camel
version than the default version.")
+ String camelVersion;
+
+ @CommandLine.Option(names = {
+ "--kamelets-version" }, description = "Apache Camel Kamelets
version")
+ String kameletsVersion;
+
+ @CommandLine.Option(names = { "--profile" }, scope =
CommandLine.ScopeType.INHERIT,
+ description = "Profile to export (dev, test, or
prod).")
+ String profile;
+
+ @CommandLine.Option(names = { "--local-kamelet-dir" },
+ description = "Local directory for loading Kamelets
(takes precedence)")
+ String localKameletDir;
+
+ @CommandLine.Option(names = { "--spring-boot-version" }, description =
"Spring Boot version",
+ defaultValue = RuntimeType.SPRING_BOOT_VERSION)
+ String springBootVersion = RuntimeType.SPRING_BOOT_VERSION;
+
+ @CommandLine.Option(names = { "--camel-spring-boot-version" }, description
= "Camel version to use with Spring Boot")
+ String camelSpringBootVersion;
+
+ @CommandLine.Option(names = { "--quarkus-group-id" }, description =
"Quarkus Platform Maven groupId",
+ defaultValue = "io.quarkus.platform")
+ String quarkusGroupId = "io.quarkus.platform";
+
+ @CommandLine.Option(names = { "--quarkus-artifact-id" }, description =
"Quarkus Platform Maven artifactId",
+ defaultValue = "quarkus-bom")
+ String quarkusArtifactId = "quarkus-bom";
+
@CommandLine.Option(names = { "--quarkus-version" }, description =
"Quarkus Platform version",
defaultValue = RuntimeType.QUARKUS_VERSION)
String quarkusVersion = RuntimeType.QUARKUS_VERSION;
+ @CommandLine.Option(names = { "--package-name" },
+ description = "For Java source files should they have
the given package name. By default the package name is computed from the Maven
GAV. "
+ + "Use false to turn off and not include
package name in the Java source files.")
+ String packageName;
+
+ @CommandLine.Option(names = { "--build-property" },
+ description = "Maven/Gradle build properties, ex.
--build-property=prop1=foo")
+ List<String> buildProperties = new ArrayList<>();
+
public KubernetesRun(CamelJBangMain main) {
super(main);
}
@@ -182,40 +254,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
StringPrinter exportPrinter = new StringPrinter();
getMain().withPrinter(exportPrinter);
- KubernetesExport export = new KubernetesExport(
- getMain(), new KubernetesExport.ExportConfigurer(
- runtime,
- quarkusVersion,
- true,
- true,
- false,
- workingDir,
- List.of(filePaths),
- gav,
- openApi,
- true,
- true,
- false,
- false,
- "off"));
-
- export.image = image;
- export.imageRegistry = imageRegistry;
- export.imageGroup = imageGroup;
- export.imageBuilder = imageBuilder;
- export.clusterType = clusterType;
- export.traitProfile = traitProfile;
- export.serviceAccount = serviceAccount;
- export.properties = properties;
- export.configs = configs;
- export.resources = resources;
- export.envVars = envVars;
- export.volumes = volumes;
- export.connects = connects;
- export.annotations = annotations;
- export.labels = labels;
- export.traits = traits;
-
+ KubernetesExport export = configureExport(workingDir);
int exit = export.export();
// Revert printer to this run command's printer
@@ -293,6 +332,65 @@ public class KubernetesRun extends KubernetesBaseCommand {
return 0;
}
+ private KubernetesExport configureExport(String workingDir) {
+ KubernetesExport.ExportConfigurer configurer = new
KubernetesExport.ExportConfigurer(
+ runtime,
+ quarkusVersion,
+ List.of(filePaths),
+ gav,
+ repositories,
+ dependencies,
+ excludes,
+ mavenSettings,
+ mavenSettingsSecurity,
+ mavenCentralEnabled,
+ mavenApacheSnapshotEnabled,
+ javaVersion,
+ camelVersion,
+ kameletsVersion,
+ profile,
+ localKameletDir,
+ springBootVersion,
+ camelSpringBootVersion,
+ quarkusGroupId,
+ quarkusArtifactId,
+ "maven",
+ openApi,
+ workingDir,
+ packageName,
+ buildProperties,
+ true,
+ false,
+ false,
+ true,
+ false,
+ true,
+ true,
+ false,
+ false,
+ "off");
+ KubernetesExport export = new KubernetesExport(getMain(), configurer);
+
+ export.image = image;
+ export.imageRegistry = imageRegistry;
+ export.imageGroup = imageGroup;
+ export.imageBuilder = imageBuilder;
+ export.clusterType = clusterType;
+ export.traitProfile = traitProfile;
+ export.serviceAccount = serviceAccount;
+ export.properties = properties;
+ export.configs = configs;
+ export.resources = resources;
+ export.envVars = envVars;
+ export.volumes = volumes;
+ export.connects = connects;
+ export.annotations = annotations;
+ export.labels = labels;
+ export.traits = traits;
+
+ return export;
+ }
+
private void installShutdownInterceptor(String projectName, String
workingDir) {
KubernetesDelete deleteCommand = new KubernetesDelete(getMain());
deleteCommand.name = projectName;