apache / camel-k

Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers
https://camel.apache.org/camel-k
Apache License 2.0
869 stars 349 forks source link

Do not fail if sources are exclusively passed via configuration file. #5933

Closed fsrv-xyz closed 1 week ago

fsrv-xyz commented 2 weeks ago

What happened?

While trying to convert my integration project to Integration resources via the kamel run -o yaml executable, I noticed that it is not possible to define the sources of the integration exclusively via the configuration file. That means that I need to pass at least one of the sources file as command line argument.

As a result of specifying a source file in command line arguments as well as in configuration file, the source block is duplicated in the resulting integration resource (which is expected, I guess).

Steps to reproduce

  1. Create a basic integration source file with camel init hello.java
  2. Create a kamel-config.yaml including a minimal set of configuration:
    kamel:
    run:
    integration:
      hello:
        sources:
          - ./hello.java
  3. Run kamel run -o yaml --name hello The command fails as no source files are specified in command line args.

Relevant log output

/private/tmp/test > camel init hello.java
/private/tmp/test > cat ./kamel-config.yaml
kamel:
  run:
    integration:
      hello:
        sources:
          - ./hello.java
/private/tmp/test > kamel run -o yaml --name hello
Error: run command expects either an Integration source or the container image (via --image argument)
/private/tmp/test > kamel run -o yaml --name hello ./hello.java
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  annotations:
    camel.apache.org/operator.id: camel-k
  creationTimestamp: null
  name: hello
spec:
  sources:
  - content: |
      import org.apache.camel.builder.RouteBuilder;

      public class hello extends RouteBuilder {

          @Override
          public void configure() throws Exception {
              from("timer:java?period=1000")
                  .setBody()
                      .simple("Hello Camel from ${routeId}")
                  .log("${body}");
          }
      }
    name: hello.java
  - content: |
      import org.apache.camel.builder.RouteBuilder;

      public class hello extends RouteBuilder {

          @Override
          public void configure() throws Exception {
              from("timer:java?period=1000")
                  .setBody()
                      .simple("Hello Camel from ${routeId}")
                  .log("${body}");
          }
      }
    name: hello.java
  traits: {}
status: {}

Camel K version

v2.5.0

squakez commented 2 weeks ago

Thanks for reporting. I'll have a look at the PR asap.