You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Roberto Camelk <be...@gmail.com> on 2021/12/17 14:50:59 UTC

CLI vs API: modeline strange behaviors

The YAML below is a snippet of my Integration resource in k8s, got by:
kubectl get integration <my-integration-name> -o yaml

apiVersion: camel.apache.org/v1
kind: Integration
metadata:
  creationTimestamp: "2021-12-15T11:22:48Z"
  generation: 1
  name: micro-profile-metrics2
  namespace: default
  resourceVersion: "85599"
  uid: 40f85faf-d9c6-472c-b10c-2d794e35e015
spec:
  dependencies:
  - camel:cron
  - camel:microprofile-metrics
  sources:
  - content: "//camel-k: dependency=camel-cron\n//camel-k:
dependency=camel-quarkus-microprofile-metrics\n\nimport
      org.apache.camel.builder.RouteBuilder;\n\npublic class
MicroProfileMetrics2
      extends RouteBuilder {\n\n    @Override\n    public void
configure() throws
      Exception
{\n\tfrom(\"cron:tab?schedule=0/15+*+*+*+*+?\")\n\t\t.routeId(\"MicroProfileMetrics2-route-1\")\n\t\t.log(\"Starting
      MicroProfile
Metrics\")\n\t\t.delay(simple(\"${random(1000,5000)}\"))\n\t\t.choice()\n\t\t\t.when().simple(\"${random(1,10)}
      < 2\")\n\t\t\t\t.throwException(new
RuntimeException(\"Perdeu\"))\n\t\t\t.otherwise()\n\t\t\t\t.log(\"MicroProfile
      Metrics sample done!\");\n    }\n\n}\n"
    name: MicroProfileMetrics2.java



Note for example the modeline in "source":  //camel-k:
dependency=camel-quarkus-microprofile-metrics

And note the value in the "dependencies":
- camel:microprofile-metrics

This is strange... why the dependency isn't
"camel-quarkus-microprofile-metrics" (containing "quarkus" word) ?
Is Modeline a specific feature of the CLI? If I submit an Integration
resource via k8s API without that dependencies field but via modeline,
will the operator parse the dependencies from source too?

Re: CLI vs API: modeline strange behaviors

Posted by Pasquale Congiusti <pa...@gmail.com>.
Yeah, the dependencies are converted in the plain related camel catalog
ones. Then, the runtime will take care to transform them into the ones of
the related runtime, Camel Quarkus in this case. If you have a look at the
deployed application, you can see that the pom has the camel-quarkus
related dependencies.

I think the idea here is to have more than one runtime having its own
catalog of specific dependencies, so the Integration must be agnostic and
have a generic definition of the dependencies to use.

Pasquale.

On Fri, Dec 17, 2021 at 6:04 PM Roberto Camelk <be...@gmail.com>
wrote:

> Ok, but about the modeline
>
> //camel-k: dependency=camel-quarkus-microprofile-metrics
>
> Why it is transformed to the dependency:
> - camel:microprofile-metrics
>
> ?
>
> On Fri, Dec 17, 2021 at 12:24 PM Pasquale Congiusti
> <pa...@gmail.com> wrote:
> >
> > Hi Roberto,
> > I think the modeline is meant for CLI only as a way to parse most of the
> > kamel run options and provide them for you. As stated in the example doc
> > [1];
> >
> > $ kamel run Hello.java
> > Modeline options have been loaded from source files
> > Full command: kamel run Hello.java --dependency
> mvn:org.my:application:1.0
> >
> > It expands the parameters provided in the Integration into a full
> command.
> >
> > Regards,
> >
> > Pasquale.
> >
> >
> > [1] https://camel.apache.org/camel-k/1.7.x/cli/modeline.html
> >
> >
> > On Fri, Dec 17, 2021 at 3:52 PM Roberto Camelk <
> betonetotbo.camelk@gmail.com>
> > wrote:
> >
> > > The YAML below is a snippet of my Integration resource in k8s, got by:
> > > kubectl get integration <my-integration-name> -o yaml
> > >
> > > apiVersion: camel.apache.org/v1
> > > kind: Integration
> > > metadata:
> > >   creationTimestamp: "2021-12-15T11:22:48Z"
> > >   generation: 1
> > >   name: micro-profile-metrics2
> > >   namespace: default
> > >   resourceVersion: "85599"
> > >   uid: 40f85faf-d9c6-472c-b10c-2d794e35e015
> > > spec:
> > >   dependencies:
> > >   - camel:cron
> > >   - camel:microprofile-metrics
> > >   sources:
> > >   - content: "//camel-k: dependency=camel-cron\n//camel-k:
> > > dependency=camel-quarkus-microprofile-metrics\n\nimport
> > >       org.apache.camel.builder.RouteBuilder;\n\npublic class
> > > MicroProfileMetrics2
> > >       extends RouteBuilder {\n\n    @Override\n    public void
> > > configure() throws
> > >       Exception
> > >
> > >
> {\n\tfrom(\"cron:tab?schedule=0/15+*+*+*+*+?\")\n\t\t.routeId(\"MicroProfileMetrics2-route-1\")\n\t\t.log(\"Starting
> > >       MicroProfile
> > >
> > >
> Metrics\")\n\t\t.delay(simple(\"${random(1000,5000)}\"))\n\t\t.choice()\n\t\t\t.when().simple(\"${random(1,10)}
> > >       < 2\")\n\t\t\t\t.throwException(new
> > >
> > >
> RuntimeException(\"Perdeu\"))\n\t\t\t.otherwise()\n\t\t\t\t.log(\"MicroProfile
> > >       Metrics sample done!\");\n    }\n\n}\n"
> > >     name: MicroProfileMetrics2.java
> > >
> > >
> > >
> > > Note for example the modeline in "source":  //camel-k:
> > > dependency=camel-quarkus-microprofile-metrics
> > >
> > > And note the value in the "dependencies":
> > > - camel:microprofile-metrics
> > >
> > > This is strange... why the dependency isn't
> > > "camel-quarkus-microprofile-metrics" (containing "quarkus" word) ?
> > > Is Modeline a specific feature of the CLI? If I submit an Integration
> > > resource via k8s API without that dependencies field but via modeline,
> > > will the operator parse the dependencies from source too?
> > >
>

Re: CLI vs API: modeline strange behaviors

Posted by Roberto Camelk <be...@gmail.com>.
Ok, but about the modeline

//camel-k: dependency=camel-quarkus-microprofile-metrics

Why it is transformed to the dependency:
- camel:microprofile-metrics

?

On Fri, Dec 17, 2021 at 12:24 PM Pasquale Congiusti
<pa...@gmail.com> wrote:
>
> Hi Roberto,
> I think the modeline is meant for CLI only as a way to parse most of the
> kamel run options and provide them for you. As stated in the example doc
> [1];
>
> $ kamel run Hello.java
> Modeline options have been loaded from source files
> Full command: kamel run Hello.java --dependency mvn:org.my:application:1.0
>
> It expands the parameters provided in the Integration into a full command.
>
> Regards,
>
> Pasquale.
>
>
> [1] https://camel.apache.org/camel-k/1.7.x/cli/modeline.html
>
>
> On Fri, Dec 17, 2021 at 3:52 PM Roberto Camelk <be...@gmail.com>
> wrote:
>
> > The YAML below is a snippet of my Integration resource in k8s, got by:
> > kubectl get integration <my-integration-name> -o yaml
> >
> > apiVersion: camel.apache.org/v1
> > kind: Integration
> > metadata:
> >   creationTimestamp: "2021-12-15T11:22:48Z"
> >   generation: 1
> >   name: micro-profile-metrics2
> >   namespace: default
> >   resourceVersion: "85599"
> >   uid: 40f85faf-d9c6-472c-b10c-2d794e35e015
> > spec:
> >   dependencies:
> >   - camel:cron
> >   - camel:microprofile-metrics
> >   sources:
> >   - content: "//camel-k: dependency=camel-cron\n//camel-k:
> > dependency=camel-quarkus-microprofile-metrics\n\nimport
> >       org.apache.camel.builder.RouteBuilder;\n\npublic class
> > MicroProfileMetrics2
> >       extends RouteBuilder {\n\n    @Override\n    public void
> > configure() throws
> >       Exception
> >
> > {\n\tfrom(\"cron:tab?schedule=0/15+*+*+*+*+?\")\n\t\t.routeId(\"MicroProfileMetrics2-route-1\")\n\t\t.log(\"Starting
> >       MicroProfile
> >
> > Metrics\")\n\t\t.delay(simple(\"${random(1000,5000)}\"))\n\t\t.choice()\n\t\t\t.when().simple(\"${random(1,10)}
> >       < 2\")\n\t\t\t\t.throwException(new
> >
> > RuntimeException(\"Perdeu\"))\n\t\t\t.otherwise()\n\t\t\t\t.log(\"MicroProfile
> >       Metrics sample done!\");\n    }\n\n}\n"
> >     name: MicroProfileMetrics2.java
> >
> >
> >
> > Note for example the modeline in "source":  //camel-k:
> > dependency=camel-quarkus-microprofile-metrics
> >
> > And note the value in the "dependencies":
> > - camel:microprofile-metrics
> >
> > This is strange... why the dependency isn't
> > "camel-quarkus-microprofile-metrics" (containing "quarkus" word) ?
> > Is Modeline a specific feature of the CLI? If I submit an Integration
> > resource via k8s API without that dependencies field but via modeline,
> > will the operator parse the dependencies from source too?
> >

Re: CLI vs API: modeline strange behaviors

Posted by Pasquale Congiusti <pa...@gmail.com>.
Hi Roberto,
I think the modeline is meant for CLI only as a way to parse most of the
kamel run options and provide them for you. As stated in the example doc
[1];

$ kamel run Hello.java
Modeline options have been loaded from source files
Full command: kamel run Hello.java --dependency mvn:org.my:application:1.0

It expands the parameters provided in the Integration into a full command.

Regards,

Pasquale.


[1] https://camel.apache.org/camel-k/1.7.x/cli/modeline.html


On Fri, Dec 17, 2021 at 3:52 PM Roberto Camelk <be...@gmail.com>
wrote:

> The YAML below is a snippet of my Integration resource in k8s, got by:
> kubectl get integration <my-integration-name> -o yaml
>
> apiVersion: camel.apache.org/v1
> kind: Integration
> metadata:
>   creationTimestamp: "2021-12-15T11:22:48Z"
>   generation: 1
>   name: micro-profile-metrics2
>   namespace: default
>   resourceVersion: "85599"
>   uid: 40f85faf-d9c6-472c-b10c-2d794e35e015
> spec:
>   dependencies:
>   - camel:cron
>   - camel:microprofile-metrics
>   sources:
>   - content: "//camel-k: dependency=camel-cron\n//camel-k:
> dependency=camel-quarkus-microprofile-metrics\n\nimport
>       org.apache.camel.builder.RouteBuilder;\n\npublic class
> MicroProfileMetrics2
>       extends RouteBuilder {\n\n    @Override\n    public void
> configure() throws
>       Exception
>
> {\n\tfrom(\"cron:tab?schedule=0/15+*+*+*+*+?\")\n\t\t.routeId(\"MicroProfileMetrics2-route-1\")\n\t\t.log(\"Starting
>       MicroProfile
>
> Metrics\")\n\t\t.delay(simple(\"${random(1000,5000)}\"))\n\t\t.choice()\n\t\t\t.when().simple(\"${random(1,10)}
>       < 2\")\n\t\t\t\t.throwException(new
>
> RuntimeException(\"Perdeu\"))\n\t\t\t.otherwise()\n\t\t\t\t.log(\"MicroProfile
>       Metrics sample done!\");\n    }\n\n}\n"
>     name: MicroProfileMetrics2.java
>
>
>
> Note for example the modeline in "source":  //camel-k:
> dependency=camel-quarkus-microprofile-metrics
>
> And note the value in the "dependencies":
> - camel:microprofile-metrics
>
> This is strange... why the dependency isn't
> "camel-quarkus-microprofile-metrics" (containing "quarkus" word) ?
> Is Modeline a specific feature of the CLI? If I submit an Integration
> resource via k8s API without that dependencies field but via modeline,
> will the operator parse the dependencies from source too?
>