This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/master by this push:
     new ec2f4bb  kamel install with example
ec2f4bb is described below

commit ec2f4bb8f739720a3eead7f0c68b68e0ab05c470
Author: Dmitry Volodin <dmvo...@gmail.com>
AuthorDate: Mon Sep 17 16:23:13 2018 +0300

    kamel install with example
---
 deploy/cr-example.yaml    | 22 ++++++++++++++++++++++
 deploy/cr.yaml            | 22 ----------------------
 deploy/resources.go       | 35 +++++++++++++++++------------------
 pkg/client/cmd/install.go |  9 +++++++++
 pkg/install/operator.go   |  7 +++++++
 5 files changed, 55 insertions(+), 40 deletions(-)

diff --git a/deploy/cr-example.yaml b/deploy/cr-example.yaml
new file mode 100644
index 0000000..c2851c7
--- /dev/null
+++ b/deploy/cr-example.yaml
@@ -0,0 +1,22 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Integration
+metadata:
+  name: example
+spec:
+  dependencies:
+    - camel:groovy
+  source:
+    content: |-
+      // This is Camel K Groovy example route
+
+      rnd = new Random()
+
+      from('timer:groovy?period=1s')
+          .routeId('groovy')
+          .setBody()
+              .constant('Hello Camel K!')
+          .process {
+              it.in.headers['RandomValue'] = rnd.nextInt()
+          }
+          .to('log:info?showHeaders=true')
+    name: routes.groovy
\ No newline at end of file
diff --git a/deploy/cr.yaml b/deploy/cr.yaml
deleted file mode 100644
index ae0ee37..0000000
--- a/deploy/cr.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-apiVersion: "camel.apache.org/v1alpha1"
-kind: "Integration"
-metadata:
-  name: "example"
-spec:
-  replicas: 1
-  source:
-    code: |-
-      package kamel;
-
-      import org.apache.camel.builder.RouteBuilder;
-
-      public class Routes extends RouteBuilder {
-
-          @Override
-          public void configure() throws Exception {
-              from("timer:tick")
-                .setBody(constant("Hello World!!!"))
-                .to("log:info");
-          }
-
-      }
diff --git a/deploy/resources.go b/deploy/resources.go
index ed871fd..b3492c7 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -66,31 +66,30 @@ spec:
   version: v1alpha1
 
 `
-       Resources["cr.yaml"] =
+       Resources["cr-example.yaml"] =
                `
-apiVersion: "camel.apache.org/v1alpha1"
-kind: "Integration"
+apiVersion: camel.apache.org/v1alpha1
+kind: Integration
 metadata:
-  name: "example"
+  name: example
 spec:
-  replicas: 1
+  dependencies:
+    - camel:groovy
   source:
-    code: |-
-      package kamel;
+    content: |-
+      // This is Camel K Groovy example route
 
-      import org.apache.camel.builder.RouteBuilder;
+      rnd = new Random()
 
-      public class Routes extends RouteBuilder {
-
-          @Override
-          public void configure() throws Exception {
-              from("timer:tick")
-                .setBody(constant("Hello World!!!"))
-                .to("log:info");
+      from('timer:groovy?period=1s')
+          .routeId('groovy')
+          .setBody()
+              .constant('Hello Camel K!')
+          .process {
+              it.in.headers['RandomValue'] = rnd.nextInt()
           }
-
-      }
-
+          .to('log:info?showHeaders=true')
+    name: routes.groovy
 `
        Resources["operator-deployment.yaml"] =
                `
diff --git a/pkg/client/cmd/install.go b/pkg/client/cmd/install.go
index d71c3c5..cd84fbd 100644
--- a/pkg/client/cmd/install.go
+++ b/pkg/client/cmd/install.go
@@ -41,6 +41,7 @@ func NewCmdInstall(rootCmdOptions *RootCmdOptions) 
*cobra.Command {
        }
 
        cmd.Flags().BoolVar(&options.clusterSetupOnly, "cluster-setup", false, 
"Execute cluster-wide operations only (may require admin rights)")
+       cmd.Flags().BoolVar(&options.exampleSetup, "example", false, "Install 
example integration")
        cmd.ParseFlags(os.Args)
 
        return &cmd
@@ -49,6 +50,7 @@ func NewCmdInstall(rootCmdOptions *RootCmdOptions) 
*cobra.Command {
 type installCmdOptions struct {
        *RootCmdOptions
        clusterSetupOnly bool
+       exampleSetup     bool
 }
 
 func (o *installCmdOptions) install(cmd *cobra.Command, args []string) error {
@@ -73,6 +75,13 @@ func (o *installCmdOptions) install(cmd *cobra.Command, args 
[]string) error {
                        return err
                }
 
+               if o.exampleSetup {
+                       err = install.Example(namespace)
+                       if err != nil {
+                               return err
+                       }
+               }
+
                fmt.Println("Camel K installed in namespace", namespace)
        }
 
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index 528424a..58aed65 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -45,6 +45,13 @@ func PlatformContexts(namespace string) error {
        )
 }
 
+// Example --
+func Example(namespace string) error {
+       return installResources(namespace,
+               "cr-example.yaml",
+       )
+}
+
 func installResources(namespace string, names ...string) error {
        for _, name := range names {
                if err := installResource(namespace, name); err != nil {

Reply via email to