You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2018/09/18 15:44:42 UTC

[GitHub] nicolaferraro closed pull request #87: kamel install with sample

nicolaferraro closed pull request #87: kamel install with sample
URL: https://github.com/apache/camel-k/pull/87
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 189d4ef..188d392 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 15a4de0..1667f6a 100644
--- a/pkg/client/cmd/install.go
+++ b/pkg/client/cmd/install.go
@@ -40,6 +40,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
@@ -48,6 +49,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 {
@@ -74,6 +76,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 {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services