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 0ca851532df CAMEL-17967: camel-jbang - Init command like camel-k
0ca851532df is described below
commit 0ca851532df305fcc3e084efdbb49b842e692054
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Apr 15 13:26:38 2022 +0200
CAMEL-17967: camel-jbang - Init command like camel-k
---
.../org/apache/camel/dsl/jbang/core/commands/Init.java | 8 ++++++++
.../src/main/resources/templates/integration.yaml.tmpl | 14 ++++++++++++++
2 files changed, 22 insertions(+)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
index 01d1859ec9c..1d5913333fb 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Init.java
@@ -32,6 +32,10 @@ class Init implements Callable<Integer> {
@CommandLine.Parameters(description = "Name of integration file", arity =
"1")
private String file;
+ @Option(names = { "--integration" },
+ description = "When creating a yaml file should it be created as a
Camel K Integration CRD")
+ private boolean integration;
+
//CHECKSTYLE:OFF
@Option(names = { "-h", "--help" }, usageHelp = true, description =
"Display the help and sub-commands")
private boolean helpRequested = false;
@@ -40,6 +44,10 @@ class Init implements Callable<Integer> {
@Override
public Integer call() throws Exception {
String ext = FileUtil.onlyExt(file, false);
+ if ("yaml".equals(ext) && integration) {
+ ext = "integration.yaml";
+ }
+
String name = FileUtil.onlyName(file, false);
InputStream is =
Init.class.getClassLoader().getResourceAsStream("templates/" + ext + ".tmpl");
if (is == null) {
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/integration.yaml.tmpl
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/integration.yaml.tmpl
new file mode 100644
index 00000000000..71a6b9d3d5a
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/integration.yaml.tmpl
@@ -0,0 +1,14 @@
+apiVersion: camel.apache.org/v1
+kind: Integration
+metadata:
+ name: {{ .Name }}
+spec:
+ flows:
+ - from:
+ uri: "timer:yaml"
+ parameters:
+ period: "1000"
+ steps:
+ - setBody:
+ constant: "Hello Camel from yaml"
+ - log: "${body}"