You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/11 13:49:23 UTC

[camel-k] branch master updated (c8e89bd -> 465444d)

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

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


    from c8e89bd  fix(OLM): fix 'replaces' field from 1.0.0-M2 CSV
     new d5b0048  fix #1005: allow to customize loader and add default dependencies for knative-source loader
     new 465444d  fix #1005: fix findings

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pkg/apis/camel/v1alpha1/integration_types.go |  3 ++
 pkg/trait/dependencies.go                    |  6 ++++
 pkg/trait/dependencies_test.go               | 45 +++++++++++++++++++++++++++-
 pkg/trait/trait_types.go                     |  4 +++
 4 files changed, 57 insertions(+), 1 deletion(-)


[camel-k] 02/02: fix #1005: fix findings

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 465444d0234bd72ce9cd8a06e1571a5d236bd594
Author: nferraro <ni...@gmail.com>
AuthorDate: Fri Oct 11 15:10:17 2019 +0200

    fix #1005: fix findings
---
 pkg/apis/camel/v1alpha1/integration_types.go | 2 +-
 pkg/trait/dependencies_test.go               | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/integration_types.go b/pkg/apis/camel/v1alpha1/integration_types.go
index 3d8d488..3f3d775 100644
--- a/pkg/apis/camel/v1alpha1/integration_types.go
+++ b/pkg/apis/camel/v1alpha1/integration_types.go
@@ -109,7 +109,7 @@ type SourceSpec struct {
 	Language Language `json:"language,omitempty"`
 	// Loader is an optional id of the org.apache.camel.k.RoutesLoader that will
 	// interpret this source at runtime
-	Loader   string   `json:"loader,omitempty"`
+	Loader string `json:"loader,omitempty"`
 }
 
 // Language --
diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go
index d92866a..fed00c9 100644
--- a/pkg/trait/dependencies_test.go
+++ b/pkg/trait/dependencies_test.go
@@ -22,7 +22,6 @@ import (
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/util/test"
-
 	"github.com/stretchr/testify/assert"
 )
 
@@ -204,7 +203,7 @@ func TestIntegrationCustomLoader(t *testing.T) {
 							Content: "- from:\n    uri: direct:foo\n    steps:\n    - to: log:bar",
 						},
 						Language: v1alpha1.LanguageYaml,
-						Loader: "knative-source-yaml",
+						Loader:   "knative-source-yaml",
 					},
 				},
 			},


[camel-k] 01/02: fix #1005: allow to customize loader and add default dependencies for knative-source loader

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d5b004821ad0ac37f3dc0ddaee86447feae16dea
Author: nferraro <ni...@gmail.com>
AuthorDate: Fri Oct 11 13:28:55 2019 +0200

    fix #1005: allow to customize loader and add default dependencies for knative-source loader
---
 pkg/apis/camel/v1alpha1/integration_types.go |  3 ++
 pkg/trait/dependencies.go                    |  6 ++++
 pkg/trait/dependencies_test.go               | 44 ++++++++++++++++++++++++++++
 pkg/trait/trait_types.go                     |  4 +++
 4 files changed, 57 insertions(+)

diff --git a/pkg/apis/camel/v1alpha1/integration_types.go b/pkg/apis/camel/v1alpha1/integration_types.go
index 2b0ba8e..3d8d488 100644
--- a/pkg/apis/camel/v1alpha1/integration_types.go
+++ b/pkg/apis/camel/v1alpha1/integration_types.go
@@ -107,6 +107,9 @@ const (
 type SourceSpec struct {
 	DataSpec
 	Language Language `json:"language,omitempty"`
+	// Loader is an optional id of the org.apache.camel.k.RoutesLoader that will
+	// interpret this source at runtime
+	Loader   string   `json:"loader,omitempty"`
 }
 
 // Language --
diff --git a/pkg/trait/dependencies.go b/pkg/trait/dependencies.go
index 7a2b94b..9659577 100644
--- a/pkg/trait/dependencies.go
+++ b/pkg/trait/dependencies.go
@@ -19,6 +19,7 @@ package trait
 
 import (
 	"sort"
+	"strings"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/metadata"
@@ -70,6 +71,11 @@ func (t *dependenciesTrait) Apply(e *Environment) error {
 			util.StringSliceUniqueAdd(&dependencies, "mvn:org.apache.camel.k/camel-k-loader-java")
 		}
 
+		if strings.HasPrefix(s.Loader, "knative-source") {
+			util.StringSliceUniqueAdd(&dependencies, "mvn:org.apache.camel.k/camel-k-loader-knative")
+			util.StringSliceUniqueAdd(&dependencies, "mvn:org.apache.camel.k/camel-k-runtime-knative")
+		}
+
 		// main required by default
 		util.StringSliceUniqueAdd(&dependencies, "mvn:org.apache.camel.k/camel-k-runtime-main")
 
diff --git a/pkg/trait/dependencies_test.go b/pkg/trait/dependencies_test.go
index fd9ae24..d92866a 100644
--- a/pkg/trait/dependencies_test.go
+++ b/pkg/trait/dependencies_test.go
@@ -188,3 +188,47 @@ func TestIntegrationAutoGeneratedDeps(t *testing.T) {
 		e.Integration.Status.Dependencies,
 	)
 }
+
+func TestIntegrationCustomLoader(t *testing.T) {
+	catalog, err := test.DefaultCatalog()
+	assert.Nil(t, err)
+
+	e := &Environment{
+		CamelCatalog: catalog,
+		Integration: &v1alpha1.Integration{
+			Spec: v1alpha1.IntegrationSpec{
+				Sources: []v1alpha1.SourceSpec{
+					{
+						DataSpec: v1alpha1.DataSpec{
+							Name:    "flow.yaml",
+							Content: "- from:\n    uri: direct:foo\n    steps:\n    - to: log:bar",
+						},
+						Language: v1alpha1.LanguageYaml,
+						Loader: "knative-source-yaml",
+					},
+				},
+			},
+			Status: v1alpha1.IntegrationStatus{
+				Phase: v1alpha1.IntegrationPhaseInitialization,
+			},
+		},
+	}
+
+	trait := newDependenciesTrait()
+	enabled, err := trait.Configure(e)
+	assert.Nil(t, err)
+	assert.True(t, enabled)
+
+	err = trait.Apply(e)
+	assert.Nil(t, err)
+	assert.ElementsMatch(t,
+		[]string{
+			"camel:direct",
+			"camel:log",
+			"mvn:org.apache.camel.k/camel-k-loader-knative",
+			"mvn:org.apache.camel.k/camel-k-loader-yaml",
+			"mvn:org.apache.camel.k/camel-k-runtime-knative",
+			"mvn:org.apache.camel.k/camel-k-runtime-main"},
+		e.Integration.Status.Dependencies,
+	)
+}
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index fabf049..f1cb187 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -325,6 +325,7 @@ func (e *Environment) ComputeConfigMaps() []runtime.Object {
 				},
 				Annotations: map[string]string{
 					"camel.apache.org/source.language":    string(s.InferLanguage()),
+					"camel.apache.org/source.loader":      s.Loader,
 					"camel.apache.org/source.name":        s.Name,
 					"camel.apache.org/source.compression": strconv.FormatBool(s.Compression),
 				},
@@ -394,6 +395,9 @@ func (e *Environment) ComputeSourcesURI() []string {
 		if s.InferLanguage() != "" {
 			params = append(params, "language="+string(s.InferLanguage()))
 		}
+		if s.Loader != "" {
+			params = append(params, "loader="+s.Loader)
+		}
 		if s.Compression {
 			params = append(params, "compression=true")
 		}