camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nferr...@apache.org
Subject [camel-k] 01/02: Regression for groovy routes #118
Date Mon, 24 Sep 2018 20:45:38 GMT
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

commit 39a7dd2aa38666e51f7c8e47a7c610c534c4dbca
Author: lburgazzoli <lburgazzoli@gmail.com>
AuthorDate: Mon Sep 24 22:14:54 2018 +0200

    Regression for groovy routes #118
---
 Gopkg.lock                           |  9 --------
 pkg/client/cmd/run.go                | 11 ++++++++++
 pkg/stub/action/integration/build.go |  4 +++-
 pkg/stub/action/integration/util.go  | 26 +++--------------------
 pkg/util/util.go                     | 40 ++++++++++++++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/Gopkg.lock b/Gopkg.lock
index 0975b14..4c8e50f 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -493,14 +493,6 @@
   version = "v0.9.1"
 
 [[projects]]
-  branch = "v1"
-  digest = "1:52ffb9db0286de37253a5098607cfbcfcdc94e51e8c226da120513df82adab0c"
-  name = "gopkg.in/yaml.v1"
-  packages = ["."]
-  pruneopts = "NUT"
-  revision = "9f9df34309c04878acc86042b16630b0f696e1de"
-
-[[projects]]
   digest = "1:7c95b35057a0ff2e19f707173cc1a947fa43a6eb5c4d300d196ece0334046082"
   name = "gopkg.in/yaml.v2"
   packages = ["."]
@@ -741,7 +733,6 @@
     "github.com/spf13/cobra",
     "github.com/stoewer/go-strcase",
     "github.com/stretchr/testify/assert",
-    "gopkg.in/yaml.v1",
     "gopkg.in/yaml.v2",
     "k8s.io/api/apps/v1",
     "k8s.io/api/core/v1",
diff --git a/pkg/client/cmd/run.go b/pkg/client/cmd/run.go
index 37d06bb..ca4e52f 100644
--- a/pkg/client/cmd/run.go
+++ b/pkg/client/cmd/run.go
@@ -25,6 +25,8 @@ import (
 	"strconv"
 	"strings"
 
+	"github.com/apache/camel-k/pkg/util"
+
 	"github.com/apache/camel-k/pkg/util/sync"
 	"github.com/sirupsen/logrus"
 
@@ -267,6 +269,15 @@ func (o *runCmdOptions) updateIntegrationCode(filename string) (*v1alpha1.Integr
 		}
 	}
 
+	// special handling for groovy
+	// TODO: we should define handlers for languages and/or file extensions
+	if o.Language == "groovy" && !util.StringSliceExists(o.Dependencies, "camel:groovy")
{
+		integration.Spec.Dependencies = append(integration.Spec.Dependencies, "camel:groovy")
+	}
+	if o.Language == "" && strings.HasSuffix(filename, ".groovy") {
+		integration.Spec.Dependencies = append(integration.Spec.Dependencies, "camel:groovy")
+	}
+
 	for _, item := range o.Properties {
 		integration.Spec.Configuration = append(integration.Spec.Configuration, v1alpha1.ConfigurationSpec{
 			Type:  "property",
diff --git a/pkg/stub/action/integration/build.go b/pkg/stub/action/integration/build.go
index 5978365..4dcf728 100644
--- a/pkg/stub/action/integration/build.go
+++ b/pkg/stub/action/integration/build.go
@@ -19,6 +19,8 @@ package action
 
 import (
 	"fmt"
+
+	"github.com/apache/camel-k/pkg/util"
 	"github.com/apache/camel-k/pkg/util/digest"
 
 	"github.com/rs/xid"
@@ -60,7 +62,7 @@ func (action *buildAction) Handle(integration *v1alpha1.Integration) error
{
 			// amended to add/remove dependencies
 
 			//TODO: this is a very simple check, we may need to provide a deps comparison strategy
-			if !StringSliceContains(ctx.Spec.Dependencies, integration.Spec.Dependencies) {
+			if !util.StringSliceContains(ctx.Spec.Dependencies, integration.Spec.Dependencies) {
 				// We need to re-generate a context or search for a new one that
 				// satisfies integrations needs so let's remove the association
 				// with a context
diff --git a/pkg/stub/action/integration/util.go b/pkg/stub/action/integration/util.go
index 8c69f69..33c3787 100644
--- a/pkg/stub/action/integration/util.go
+++ b/pkg/stub/action/integration/util.go
@@ -4,6 +4,8 @@ import (
 	"fmt"
 	"strings"
 
+	"github.com/apache/camel-k/pkg/util"
+
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/operator-framework/operator-sdk/pkg/sdk"
 	"k8s.io/api/core/v1"
@@ -38,7 +40,7 @@ func LookupContextForIntegration(integration *v1alpha1.Integration) (*v1alpha1.I
 				continue
 			}
 
-			if StringSliceContains(ctx.Spec.Dependencies, integration.Spec.Dependencies) {
+			if util.StringSliceContains(ctx.Spec.Dependencies, integration.Spec.Dependencies) {
 				return &ctx, nil
 			}
 		}
@@ -47,28 +49,6 @@ func LookupContextForIntegration(integration *v1alpha1.Integration) (*v1alpha1.I
 	return nil, nil
 }
 
-// StringSliceContains --
-func StringSliceContains(slice []string, items []string) bool {
-	for i := 0; i < len(items); i++ {
-		if !StringSliceExists(slice, items[i]) {
-			return false
-		}
-	}
-
-	return true
-}
-
-// StringSliceExists --
-func StringSliceExists(slice []string, item string) bool {
-	for i := 0; i < len(slice); i++ {
-		if slice[i] == item {
-			return true
-		}
-	}
-
-	return false
-}
-
 // PropertiesString --
 func PropertiesString(m map[string]string) string {
 	properties := ""
diff --git a/pkg/util/util.go b/pkg/util/util.go
new file mode 100644
index 0000000..c2a2631
--- /dev/null
+++ b/pkg/util/util.go
@@ -0,0 +1,40 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package util
+
+// StringSliceContains --
+func StringSliceContains(slice []string, items []string) bool {
+	for i := 0; i < len(items); i++ {
+		if !StringSliceExists(slice, items[i]) {
+			return false
+		}
+	}
+
+	return true
+}
+
+// StringSliceExists --
+func StringSliceExists(slice []string, item string) bool {
+	for i := 0; i < len(slice); i++ {
+		if slice[i] == item {
+			return true
+		}
+	}
+
+	return false
+}


Mime
View raw message