This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 135a8807d636 chore(CLI): Show clusterType values (#20378)
135a8807d636 is described below
commit 135a8807d636d9f11c7be48fc2c40c878be9d25a
Author: Ricardo M. <[email protected]>
AuthorDate: Fri Dec 12 11:04:56 2025 +0100
chore(CLI): Show clusterType values (#20378)
Currently, there's no information about the valid cluster types the
kubernetes plugin could use.
This commit reads the ClusterType enum and use it to show it to the
`--help` argument.
Example:
```
$ camel kubernetes run --help
...
--cluster-type=<clusterType>
The target cluster type (kubernetes, openshift,
kind, k3s, minikube). Special configurations
may
be applied to different cluster types such as
Kind or Minikube.
...
```
---
.../ClusterTypeCompletionCandidates.java | 35 ++++++++++++++++++++++
.../commands/kubernetes/ClusterTypeConverter.java | 29 ++++++++++++++++++
.../core/commands/kubernetes/KubernetesExport.java | 4 ++-
.../core/commands/kubernetes/KubernetesRun.java | 4 ++-
4 files changed, 70 insertions(+), 2 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/ClusterTypeCompletionCandidates.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/ClusterTypeCompletionCandidates.java
new file mode 100644
index 000000000000..6e1365594c8b
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/ClusterTypeCompletionCandidates.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.kubernetes;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class ClusterTypeCompletionCandidates implements Iterable<String> {
+
+ public ClusterTypeCompletionCandidates() {
+ }
+
+ @Override
+ public Iterator<String> iterator() {
+ return Arrays.stream(ClusterType.values())
+ .map(ClusterType::name)
+ .map(String::toLowerCase)
+ .iterator();
+ }
+
+}
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/ClusterTypeConverter.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/ClusterTypeConverter.java
new file mode 100644
index 000000000000..1f50891ea10e
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/ClusterTypeConverter.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.kubernetes;
+
+import picocli.CommandLine;
+
+public class ClusterTypeConverter implements
CommandLine.ITypeConverter<String> {
+
+ public String convert(String value) throws Exception {
+ // Validate that the value is a valid cluster type
+ ClusterType.fromName(value);
+ // Return the original value to maintain String type in KubernetesRun
+ return value;
+ }
+}
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 16ba483093cf..197b8743a6a0 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
@@ -126,7 +126,9 @@ public class KubernetesExport extends Export {
protected String registryMirror;
@CommandLine.Option(names = { "--cluster-type" },
- description = "The target cluster type. Special
configurations may be applied to different cluster types such as Kind or
Minikube or Openshift.")
+ completionCandidates =
ClusterTypeCompletionCandidates.class,
+ converter = ClusterTypeConverter.class,
+ description = "The target cluster type
(${COMPLETION-CANDIDATES}). Special configurations may be applied to different
cluster types such as Kind or Minikube.")
protected String clusterType;
private static final String SRC_MAIN_RESOURCES = "/src/main/resources/";
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 58a4521755f9..3e46ad9dac38 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
@@ -158,7 +158,9 @@ public class KubernetesRun extends KubernetesBaseCommand {
String imageBuilder = "jib";
@CommandLine.Option(names = { "--cluster-type" },
- description = "The target cluster type. Special
configurations may be applied to different cluster types such as Kind or
Minikube.")
+ completionCandidates =
ClusterTypeCompletionCandidates.class,
+ converter = ClusterTypeConverter.class,
+ description = "The target cluster type
(${COMPLETION-CANDIDATES}). Special configurations may be applied to different
cluster types such as Kind or Minikube.")
String clusterType = "Kubernetes";
@CommandLine.Option(names = { "--image-build" }, defaultValue = "true",