diff --git a/Gopkg.lock b/Gopkg.lock index 0975b149a8..4c8e50fabe 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -492,14 +492,6 @@ revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" 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" @@ -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 37d06bb4a6..ca4e52f459 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 59783658e7..4dcf7285fb 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 8c69f69790..33c37877e8 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 0000000000..c2a2631ac9 --- /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 +}