You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2020/10/06 08:03:11 UTC
[camel-k] branch master updated (7935569 -> 7de8fb2)
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.
from 7935569 Updated CHANGELOG.md
new 19b66cf chore(binding): refactor binding mechanism and add many more tests
new 39318e8 chore(e2e): fix
new 7fea5bf chore(e2e): refactor tests to run all them
new 9c07fc6 chore(e2e): add reserved kamelet names
new 7d3d9d3 chore(e2e): fix missing namespace values in knative references
new f15f1ee chore(e2e): clarification on kamelet syntax
new 69bb64a chore(e2e): fix deepcopy and regen
new 7de8fb2 chore(e2e): fix test chore(e2e): fix http cloudevent test
The 8 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:
.github/workflows/knative.yml | 3 +-
deploy/crd-kamelet-binding.yaml | 80 ++++----
...el-k.v1.2.0-snapshot.clusterserviceversion.yaml | 2 +-
.../kameletbindings.camel.apache.org.crd.yaml | 80 ++++----
deploy/resources.go | 61 +-----
docs/modules/ROOT/pages/kamelets/kamelets.adoc | 12 +-
.../kamelet-binding/display.groovy} | 8 +-
e2e/yaks/common/kamelet-binding/kamelet.feature | 10 +
.../kamelet-binding/logger-sink-binding.yaml | 14 +-
.../kamelet-binding/logger-sink.kamelet.yaml} | 15 +-
.../kamelet-binding}/messages-channel.yaml | 0
.../timer-source-binding-display.yaml | 9 +-
.../kamelet-binding}/timer-source-binding.yaml | 0
.../kamelet-binding}/timer-source.kamelet.yaml | 2 +-
.../kamelet-binding}/yaks-config.yaml | 10 +-
.../kamelet}/echo-sink.kamelet.yaml | 2 +-
e2e/yaks/common/kamelet/kamelet.feature | 5 +
.../kamelet}/source-sink.groovy | 3 +-
.../kamelet}/timer-source.kamelet.yaml | 2 +-
.../{kamelets => common/kamelet}/yaks-config.yaml | 6 -
.../knative-sinkbinding}/messages-channel.yaml | 0
.../knative-sinkbinding/receiver.groovy | 0
.../knative-sinkbinding/sinkbinding.feature | 0
.../{ => common}/knative-sinkbinding/source.yaml | 0
.../knative-sinkbinding/yaks-config.yaml | 0
e2e/yaks/{ => common}/knative/receiver.groovy | 0
e2e/yaks/{ => common}/knative/source.yaml | 0
e2e/yaks/{ => common}/knative/sources.feature | 0
e2e/yaks/{ => common}/knative/yaks-config.yaml | 0
e2e/yaks/{ => common}/yaks-config.yaml | 0
e2e/yaks/kamelets/kamelet.feature | 9 -
e2e/yaks/kamelets/logger.groovy | 21 --
e2e/yaks/{ => openshift}/monitoring/Metrics.java | 0
e2e/yaks/{ => openshift}/monitoring/app/pom.xml | 0
.../java/org/apache/camel/integration/Service.java | 0
.../{ => openshift}/monitoring/metrics.feature | 0
e2e/yaks/{ => openshift}/monitoring/obtainToken.sh | 0
.../{ => openshift}/monitoring/yaks-config.yaml | 0
e2e/yaks/{ => openshift}/yaks-config.yaml | 0
examples/kamelets/timer-source.kamelet.yaml | 2 +-
go.mod | 1 +
helm/camel-k/crds/crd-kamelet-binding.yaml | 80 ++++----
pkg/apis/camel/v1alpha1/kamelet_binding_types.go | 15 +-
.../v1alpha1/kamelet_binding_types_support.go | 21 ++
pkg/apis/camel/v1alpha1/kamelet_types.go | 11 +
pkg/apis/camel/v1alpha1/kamelet_types_support.go | 4 +
pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go | 6 +-
pkg/client/camel/go.mod | 1 +
pkg/controller/kamelet/common.go | 30 ++-
pkg/controller/kameletbinding/initialize.go | 85 +-------
pkg/trait/kamelets.go | 2 +-
pkg/trait/knative.go | 6 +
pkg/util/bindings/api.go | 48 +++++
pkg/util/bindings/bindings_test.go | 222 +++++++++++++++++++++
pkg/util/bindings/camel_uri.go | 58 ++++++
pkg/util/bindings/catalog.go | 61 ++++++
pkg/util/bindings/kamelet.go | 68 +++++++
pkg/util/bindings/knative_ref.go | 116 +++++++++++
pkg/util/bindings/knative_uri.go | 102 ++++++++++
pkg/util/knative/apis.go | 30 +++
60 files changed, 987 insertions(+), 336 deletions(-)
copy e2e/yaks/{kamelets/source-sink.groovy => common/kamelet-binding/display.groovy} (87%)
mode change 100755 => 100644
create mode 100644 e2e/yaks/common/kamelet-binding/kamelet.feature
copy examples/kamelets/kamelet-binding-example.yaml => e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml (74%)
copy e2e/yaks/{kamelets/echo-sink.kamelet.yaml => common/kamelet-binding/logger-sink.kamelet.yaml} (52%)
rename e2e/yaks/{knative-sinkbinding => common/kamelet-binding}/messages-channel.yaml (100%)
copy examples/kamelets/kamelet-binding-example.yaml => e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml (56%)
rename e2e/yaks/{kamelets => common/kamelet-binding}/timer-source-binding.yaml (100%)
copy e2e/yaks/{kamelets => common/kamelet-binding}/timer-source.kamelet.yaml (95%)
copy e2e/yaks/{kamelets => common/kamelet-binding}/yaks-config.yaml (71%)
rename e2e/yaks/{kamelets => common/kamelet}/echo-sink.kamelet.yaml (94%)
create mode 100644 e2e/yaks/common/kamelet/kamelet.feature
rename e2e/yaks/{kamelets => common/kamelet}/source-sink.groovy (94%)
rename e2e/yaks/{kamelets => common/kamelet}/timer-source.kamelet.yaml (95%)
rename e2e/yaks/{kamelets => common/kamelet}/yaks-config.yaml (81%)
rename e2e/yaks/{kamelets => common/knative-sinkbinding}/messages-channel.yaml (100%)
rename e2e/yaks/{ => common}/knative-sinkbinding/receiver.groovy (100%)
rename e2e/yaks/{ => common}/knative-sinkbinding/sinkbinding.feature (100%)
rename e2e/yaks/{ => common}/knative-sinkbinding/source.yaml (100%)
rename e2e/yaks/{ => common}/knative-sinkbinding/yaks-config.yaml (100%)
rename e2e/yaks/{ => common}/knative/receiver.groovy (100%)
rename e2e/yaks/{ => common}/knative/source.yaml (100%)
rename e2e/yaks/{ => common}/knative/sources.feature (100%)
rename e2e/yaks/{ => common}/knative/yaks-config.yaml (100%)
copy e2e/yaks/{ => common}/yaks-config.yaml (100%)
delete mode 100644 e2e/yaks/kamelets/kamelet.feature
delete mode 100755 e2e/yaks/kamelets/logger.groovy
rename e2e/yaks/{ => openshift}/monitoring/Metrics.java (100%)
rename e2e/yaks/{ => openshift}/monitoring/app/pom.xml (100%)
rename e2e/yaks/{ => openshift}/monitoring/app/src/main/java/org/apache/camel/integration/Service.java (100%)
rename e2e/yaks/{ => openshift}/monitoring/metrics.feature (100%)
rename e2e/yaks/{ => openshift}/monitoring/obtainToken.sh (100%)
rename e2e/yaks/{ => openshift}/monitoring/yaks-config.yaml (100%)
rename e2e/yaks/{ => openshift}/yaks-config.yaml (100%)
create mode 100644 pkg/util/bindings/api.go
create mode 100644 pkg/util/bindings/bindings_test.go
create mode 100644 pkg/util/bindings/camel_uri.go
create mode 100644 pkg/util/bindings/catalog.go
create mode 100644 pkg/util/bindings/kamelet.go
create mode 100644 pkg/util/bindings/knative_ref.go
create mode 100644 pkg/util/bindings/knative_uri.go
[camel-k] 05/08: chore(e2e): fix missing namespace values in
knative references
Posted by nf...@apache.org.
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 7d3d9d383bd47c6e8202cebf7fcaeff919f98160
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Mon Oct 5 16:49:46 2020 +0200
chore(e2e): fix missing namespace values in knative references
---
pkg/trait/knative.go | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index ed41b6b..32df45f 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -343,6 +343,9 @@ func (t *knativeTrait) configureChannels(e *Environment, env *knativeapi.CamelEn
}
func (t *knativeTrait) createSubscription(e *Environment, ref *corev1.ObjectReference) error {
+ if ref.Namespace == "" {
+ ref.Namespace = e.Integration.Namespace
+ }
sub := knativeutil.CreateSubscription(*ref, e.Integration.Name)
e.Resources.Add(sub)
return nil
@@ -530,6 +533,9 @@ func (t *knativeTrait) createTrigger(e *Environment, ref *corev1.ObjectReference
trigger.Spec.Filter.Attributes["type"] == eventType
})
if !found {
+ if ref.Namespace == "" {
+ ref.Namespace = e.Integration.Namespace
+ }
trigger := knativeutil.CreateTrigger(*ref, e.Integration.Name, eventType)
e.Resources.Add(trigger)
}
[camel-k] 06/08: chore(e2e): clarification on kamelet syntax
Posted by nf...@apache.org.
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 f15f1eee470b1369c169fe68ddea27c3b38796d1
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Mon Oct 5 16:54:40 2020 +0200
chore(e2e): clarification on kamelet syntax
---
docs/modules/ROOT/pages/kamelets/kamelets.adoc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/modules/ROOT/pages/kamelets/kamelets.adoc b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
index 6a0beea..a5d7889 100644
--- a/docs/modules/ROOT/pages/kamelets/kamelets.adoc
+++ b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
@@ -497,8 +497,10 @@ spec:
----
Source and sink flows will connect to the outside route via the `kamelet:source` or `kamelet:sink` special endpoints:
-- A source Kamelet must start **from** `direct:{{routeId}}`
-- A sink Kamelet must contain a call **to** `direct:{{routeId}}`
+- A source Kamelet must contain a call **to** `kamelet:sink`
+- A sink Kamelet must start **from** `kamelet:source`
+
+NOTE: The `kamelet:source` and `kamelet:sink` endpoints are special endpoints that are only available in Kamelet route templates and will be replaced with actual references at runtime.
Kamelets contain a **single route template** written in YAML DSL, as in the previous example.
[camel-k] 02/08: chore(e2e): fix
Posted by nf...@apache.org.
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 39318e839d4189290ce121c4f8f9d57466eafaee
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Oct 2 16:00:26 2020 +0200
chore(e2e): fix
---
.../camel-k.v1.2.0-snapshot.clusterserviceversion.yaml | 2 +-
docs/modules/ROOT/pages/kamelets/kamelets.adoc | 6 +++---
e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml | 2 +-
e2e/yaks/kamelet-binding/timer-source.kamelet.yaml | 2 +-
e2e/yaks/kamelet/echo-sink.kamelet.yaml | 2 +-
e2e/yaks/kamelet/timer-source.kamelet.yaml | 2 +-
examples/kamelets/timer-source.kamelet.yaml | 2 +-
7 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/camel-k.v1.2.0-snapshot.clusterserviceversion.yaml b/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/camel-k.v1.2.0-snapshot.clusterserviceversion.yaml
index 274dc97..77cbde0 100644
--- a/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/camel-k.v1.2.0-snapshot.clusterserviceversion.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/camel-k.v1.2.0-snapshot.clusterserviceversion.yaml
@@ -120,7 +120,7 @@ metadata:
}
},
{
- "to": "direct:{{routeId}}"
+ "to": "kamelet:sink"
}
],
"uri": "timer:tick"
diff --git a/docs/modules/ROOT/pages/kamelets/kamelets.adoc b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
index f98756d..6a0beea 100644
--- a/docs/modules/ROOT/pages/kamelets/kamelets.adoc
+++ b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
@@ -88,7 +88,7 @@ spec:
- filter:
simple: "${body} != null"
- log: "${body}"
- - to: "direct:{{routeId}}"
+ - to: "kamelet:sink"
----
<1> The Kamelet ID, to be used in integrations that want to leverage the Kamelet
<2> Annotations such as icon provide additional display features to the Kamelet
@@ -493,10 +493,10 @@ spec:
- filter:
simple: "${body} != null"
- log: "${body}"
- - to: "direct:{{routeId}}"
+ - to: "kamelet:sink"
----
-Source and sink flows will connect to the outside route via the `direct:{{routeId}}` endpoint:
+Source and sink flows will connect to the outside route via the `kamelet:source` or `kamelet:sink` special endpoints:
- A source Kamelet must start **from** `direct:{{routeId}}`
- A sink Kamelet must contain a call **to** `direct:{{routeId}}`
diff --git a/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml b/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
index a28fc94..d401a7a 100644
--- a/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
+++ b/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
@@ -21,6 +21,6 @@ spec:
mediaType: text/plain
flow:
from:
- uri: "direct:{{routeId}}"
+ uri: "kamelet:source"
steps:
- log: "{{prefix}}${body}"
diff --git a/e2e/yaks/kamelet-binding/timer-source.kamelet.yaml b/e2e/yaks/kamelet-binding/timer-source.kamelet.yaml
index a521e07..48df261 100644
--- a/e2e/yaks/kamelet-binding/timer-source.kamelet.yaml
+++ b/e2e/yaks/kamelet-binding/timer-source.kamelet.yaml
@@ -34,4 +34,4 @@ spec:
steps:
- set-body:
constant: "{{message}}"
- - to: "direct:{{routeId}}"
+ - to: "kamelet:sink"
diff --git a/e2e/yaks/kamelet/echo-sink.kamelet.yaml b/e2e/yaks/kamelet/echo-sink.kamelet.yaml
index c21ea6b..08a3a0e 100644
--- a/e2e/yaks/kamelet/echo-sink.kamelet.yaml
+++ b/e2e/yaks/kamelet/echo-sink.kamelet.yaml
@@ -21,7 +21,7 @@ spec:
mediaType: text/plain
flow:
from:
- uri: "direct:{{routeId}}"
+ uri: "kamelet:source"
steps:
- set-body:
simple: "{{prefix}}${body}"
diff --git a/e2e/yaks/kamelet/timer-source.kamelet.yaml b/e2e/yaks/kamelet/timer-source.kamelet.yaml
index a521e07..48df261 100644
--- a/e2e/yaks/kamelet/timer-source.kamelet.yaml
+++ b/e2e/yaks/kamelet/timer-source.kamelet.yaml
@@ -34,4 +34,4 @@ spec:
steps:
- set-body:
constant: "{{message}}"
- - to: "direct:{{routeId}}"
+ - to: "kamelet:sink"
diff --git a/examples/kamelets/timer-source.kamelet.yaml b/examples/kamelets/timer-source.kamelet.yaml
index 17e4826..74f5824 100644
--- a/examples/kamelets/timer-source.kamelet.yaml
+++ b/examples/kamelets/timer-source.kamelet.yaml
@@ -34,4 +34,4 @@ spec:
steps:
- set-body:
constant: "#property:message"
- - to: "direct:{{routeId}}"
+ - to: "kamelet:sink"
[camel-k] 04/08: chore(e2e): add reserved kamelet names
Posted by nf...@apache.org.
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 9c07fc6a329f56dfff5bd34e40650bdb313f3140
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Mon Oct 5 10:49:35 2020 +0200
chore(e2e): add reserved kamelet names
---
pkg/apis/camel/v1alpha1/kamelet_types.go | 11 +++++++++
pkg/apis/camel/v1alpha1/kamelet_types_support.go | 4 ++++
pkg/controller/kamelet/common.go | 30 +++++++++++++++++-------
pkg/trait/kamelets.go | 2 +-
4 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/pkg/apis/camel/v1alpha1/kamelet_types.go b/pkg/apis/camel/v1alpha1/kamelet_types.go
index 22be293..7b356c1 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_types.go
@@ -27,6 +27,10 @@ const (
AnnotationIcon = "camel.apache.org/kamelet.icon"
)
+var (
+ reservedKameletNames = map[string]bool{"source": true, "sink": true}
+)
+
// KameletSpec defines the desired state of Kamelet
type KameletSpec struct {
Definition JSONSchemaProps `json:"definition,omitempty"`
@@ -89,6 +93,11 @@ const (
KameletConditionReady KameletConditionType = "Ready"
)
+const (
+ // KameletConditionIllegalName --
+ KameletConditionIllegalName string = "IllegalName"
+)
+
type KameletPhase string
const (
@@ -99,6 +108,8 @@ const (
KameletPhaseNone KameletPhase = ""
// KameletPhaseReady --
KameletPhaseReady KameletPhase = "Ready"
+ // KameletPhaseError --
+ KameletPhaseError KameletPhase = "Error"
)
// +genclient
diff --git a/pkg/apis/camel/v1alpha1/kamelet_types_support.go b/pkg/apis/camel/v1alpha1/kamelet_types_support.go
index 9a9fcfd..2aa2c85 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_types_support.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_types_support.go
@@ -136,3 +136,7 @@ func (in *KameletStatus) RemoveCondition(condType KameletConditionType) {
in.Conditions = newConditions
}
+
+func ValidKameletName(name string) bool {
+ return !reservedKameletNames[name]
+}
diff --git a/pkg/controller/kamelet/common.go b/pkg/controller/kamelet/common.go
index d6bf99f..f0e9d97 100644
--- a/pkg/controller/kamelet/common.go
+++ b/pkg/controller/kamelet/common.go
@@ -12,16 +12,28 @@ import (
func updateStatus(kamelet *v1alpha1.Kamelet) (*v1alpha1.Kamelet, error) {
target := kamelet.DeepCopy()
- target.Status.Phase = v1alpha1.KameletPhaseReady
- target.Status.SetCondition(
- v1alpha1.KameletConditionReady,
- corev1.ConditionTrue,
- "",
- "",
- )
- if err := recomputeProperties(target); err != nil {
- return nil, err
+
+ if !v1alpha1.ValidKameletName(kamelet.Name) {
+ target.Status.Phase = v1alpha1.KameletPhaseError
+ target.Status.SetCondition(
+ v1alpha1.KameletConditionReady,
+ corev1.ConditionFalse,
+ v1alpha1.KameletConditionIllegalName,
+ fmt.Sprintf("Kamelet name %q is reserved", kamelet.Name),
+ )
+ } else {
+ target.Status.Phase = v1alpha1.KameletPhaseReady
+ target.Status.SetCondition(
+ v1alpha1.KameletConditionReady,
+ corev1.ConditionTrue,
+ "",
+ "",
+ )
+ if err := recomputeProperties(target); err != nil {
+ return nil, err
+ }
}
+
return target, nil
}
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 1b3c9dc..a13dcc6 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -273,7 +273,7 @@ func (t *kameletsTrait) getKameletKeys() []string {
if strings.Contains(i, "/") {
i = strings.SplitN(i, "/", 2)[0]
}
- if i != "" {
+ if i != "" && v1alpha1.ValidKameletName(i) {
util.StringSliceUniqueAdd(&answer, i)
}
}
[camel-k] 01/08: chore(binding): refactor binding mechanism and add
many more tests
Posted by nf...@apache.org.
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 19b66cffb432f98f8e29ca0bf71e6112f375c989
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Thu Oct 1 18:04:54 2020 +0200
chore(binding): refactor binding mechanism and add many more tests
---
deploy/crd-kamelet-binding.yaml | 80 ++++----
.../kameletbindings.camel.apache.org.crd.yaml | 80 ++++----
.../display.groovy} | 9 +-
e2e/yaks/kamelet-binding/kamelet.feature | 5 +
.../logger-sink-binding.yaml} | 15 +-
.../logger-sink.kamelet.yaml} | 13 +-
.../messages-channel.yaml | 0
.../timer-source-binding-display.yaml} | 10 +-
.../timer-source-binding.yaml | 0
.../timer-source.kamelet.yaml | 0
.../{kamelets => kamelet-binding}/yaks-config.yaml | 10 +-
.../{kamelets => kamelet}/echo-sink.kamelet.yaml | 0
e2e/yaks/kamelet/kamelet.feature | 5 +
e2e/yaks/{kamelets => kamelet}/source-sink.groovy | 3 +-
.../timer-source.kamelet.yaml | 0
e2e/yaks/{kamelets => kamelet}/yaks-config.yaml | 6 -
e2e/yaks/kamelets/kamelet.feature | 9 -
helm/camel-k/crds/crd-kamelet-binding.yaml | 80 ++++----
pkg/apis/camel/v1alpha1/kamelet_binding_types.go | 9 +-
.../v1alpha1/kamelet_binding_types_support.go | 21 ++
pkg/controller/kameletbinding/initialize.go | 85 +-------
pkg/util/bindings/api.go | 48 +++++
pkg/util/bindings/bindings_test.go | 222 +++++++++++++++++++++
pkg/util/bindings/camel_uri.go | 58 ++++++
pkg/util/bindings/catalog.go | 61 ++++++
pkg/util/bindings/kamelet.go | 68 +++++++
pkg/util/bindings/knative_ref.go | 116 +++++++++++
pkg/util/bindings/knative_uri.go | 102 ++++++++++
pkg/util/knative/apis.go | 30 +++
29 files changed, 915 insertions(+), 230 deletions(-)
diff --git a/deploy/crd-kamelet-binding.yaml b/deploy/crd-kamelet-binding.yaml
index 74575d8..53bf707 100644
--- a/deploy/crd-kamelet-binding.yaml
+++ b/deploy/crd-kamelet-binding.yaml
@@ -189,31 +189,35 @@ spec:
apiVersion:
description: API version of the referent.
type: string
- blockOwnerDeletion:
- description: If true, AND if the owner has the "foregroundDeletion"
- finalizer, then the owner cannot be deleted from the key-value
- store until this reference is removed. Defaults to false.
- To set this field, a user needs "delete" permission of the
- owner, otherwise 422 (Unprocessable Entity) will be returned.
- type: boolean
- controller:
- description: If true, this reference points to the managing
- controller.
- type: boolean
+ fieldPath:
+ description: 'If referring to a piece of an object instead of
+ an entire object, this string should contain a valid JSON/Go
+ field access statement, such as desiredState.manifest.containers[2].
+ For example, if the object reference is to a container within
+ a pod, this would take on a value like: "spec.containers{name}"
+ (where "name" refers to the name of the container that triggered
+ the event) or if no container name is specified "spec.containers[2]"
+ (container with index 2 in this pod). This syntax is chosen
+ only to have some well-defined way of referencing a part of
+ an object. TODO: this design is not final and this field is
+ subject to change in the future.'
+ type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
- description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
+ type: string
+ namespace:
+ description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
+ type: string
+ resourceVersion:
+ description: 'Specific resourceVersion to which this reference
+ is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
- description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
+ description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
- required:
- - apiVersion
- - kind
- - name
- - uid
type: object
uri:
description: URI can alternatively be used to specify the (Camel)
@@ -235,31 +239,35 @@ spec:
apiVersion:
description: API version of the referent.
type: string
- blockOwnerDeletion:
- description: If true, AND if the owner has the "foregroundDeletion"
- finalizer, then the owner cannot be deleted from the key-value
- store until this reference is removed. Defaults to false.
- To set this field, a user needs "delete" permission of the
- owner, otherwise 422 (Unprocessable Entity) will be returned.
- type: boolean
- controller:
- description: If true, this reference points to the managing
- controller.
- type: boolean
+ fieldPath:
+ description: 'If referring to a piece of an object instead of
+ an entire object, this string should contain a valid JSON/Go
+ field access statement, such as desiredState.manifest.containers[2].
+ For example, if the object reference is to a container within
+ a pod, this would take on a value like: "spec.containers{name}"
+ (where "name" refers to the name of the container that triggered
+ the event) or if no container name is specified "spec.containers[2]"
+ (container with index 2 in this pod). This syntax is chosen
+ only to have some well-defined way of referencing a part of
+ an object. TODO: this design is not final and this field is
+ subject to change in the future.'
+ type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
- description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
+ type: string
+ namespace:
+ description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
+ type: string
+ resourceVersion:
+ description: 'Specific resourceVersion to which this reference
+ is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
- description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
+ description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
- required:
- - apiVersion
- - kind
- - name
- - uid
type: object
uri:
description: URI can alternatively be used to specify the (Camel)
diff --git a/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/kameletbindings.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/kameletbindings.camel.apache.org.crd.yaml
index 74575d8..53bf707 100644
--- a/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/kameletbindings.camel.apache.org.crd.yaml
+++ b/deploy/olm-catalog/camel-k-dev/1.2.0-snapshot/kameletbindings.camel.apache.org.crd.yaml
@@ -189,31 +189,35 @@ spec:
apiVersion:
description: API version of the referent.
type: string
- blockOwnerDeletion:
- description: If true, AND if the owner has the "foregroundDeletion"
- finalizer, then the owner cannot be deleted from the key-value
- store until this reference is removed. Defaults to false.
- To set this field, a user needs "delete" permission of the
- owner, otherwise 422 (Unprocessable Entity) will be returned.
- type: boolean
- controller:
- description: If true, this reference points to the managing
- controller.
- type: boolean
+ fieldPath:
+ description: 'If referring to a piece of an object instead of
+ an entire object, this string should contain a valid JSON/Go
+ field access statement, such as desiredState.manifest.containers[2].
+ For example, if the object reference is to a container within
+ a pod, this would take on a value like: "spec.containers{name}"
+ (where "name" refers to the name of the container that triggered
+ the event) or if no container name is specified "spec.containers[2]"
+ (container with index 2 in this pod). This syntax is chosen
+ only to have some well-defined way of referencing a part of
+ an object. TODO: this design is not final and this field is
+ subject to change in the future.'
+ type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
- description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
+ type: string
+ namespace:
+ description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
+ type: string
+ resourceVersion:
+ description: 'Specific resourceVersion to which this reference
+ is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
- description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
+ description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
- required:
- - apiVersion
- - kind
- - name
- - uid
type: object
uri:
description: URI can alternatively be used to specify the (Camel)
@@ -235,31 +239,35 @@ spec:
apiVersion:
description: API version of the referent.
type: string
- blockOwnerDeletion:
- description: If true, AND if the owner has the "foregroundDeletion"
- finalizer, then the owner cannot be deleted from the key-value
- store until this reference is removed. Defaults to false.
- To set this field, a user needs "delete" permission of the
- owner, otherwise 422 (Unprocessable Entity) will be returned.
- type: boolean
- controller:
- description: If true, this reference points to the managing
- controller.
- type: boolean
+ fieldPath:
+ description: 'If referring to a piece of an object instead of
+ an entire object, this string should contain a valid JSON/Go
+ field access statement, such as desiredState.manifest.containers[2].
+ For example, if the object reference is to a container within
+ a pod, this would take on a value like: "spec.containers{name}"
+ (where "name" refers to the name of the container that triggered
+ the event) or if no container name is specified "spec.containers[2]"
+ (container with index 2 in this pod). This syntax is chosen
+ only to have some well-defined way of referencing a part of
+ an object. TODO: this design is not final and this field is
+ subject to change in the future.'
+ type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
- description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
+ type: string
+ namespace:
+ description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
+ type: string
+ resourceVersion:
+ description: 'Specific resourceVersion to which this reference
+ is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
- description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
+ description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
- required:
- - apiVersion
- - kind
- - name
- - uid
type: object
uri:
description: URI can alternatively be used to specify the (Camel)
diff --git a/e2e/yaks/kamelets/logger.groovy b/e2e/yaks/kamelet-binding/display.groovy
old mode 100755
new mode 100644
similarity index 84%
rename from e2e/yaks/kamelets/logger.groovy
rename to e2e/yaks/kamelet-binding/display.groovy
index a28afe3..b3ba363
--- a/e2e/yaks/kamelets/logger.groovy
+++ b/e2e/yaks/kamelet-binding/display.groovy
@@ -1,5 +1,4 @@
-// camel-k: language=groovy dependency=mvn:org.apache.camel.k:camel-kamelet:1.5.1-SNAPSHOT
-
+// camel-k: language=groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -17,5 +16,7 @@
* limitations under the License.
*/
-from('knative:channel/messages')
- .log('${body}')
+from('knative:endpoint/display')
+ .log('${body}')
+ .setBody().header('CE-Type')
+ .log('type: ${body}');
diff --git a/e2e/yaks/kamelet-binding/kamelet.feature b/e2e/yaks/kamelet-binding/kamelet.feature
new file mode 100644
index 0000000..2d04ce1
--- /dev/null
+++ b/e2e/yaks/kamelet-binding/kamelet.feature
@@ -0,0 +1,5 @@
+Feature: Camel K can bind Kamelets
+
+ Scenario: Running integration using a simple Kamelet with KameletBinding
+ Given integration logger-sink-binding is running
+ Then integration logger-sink-binding should print message: Hello Kamelets
diff --git a/e2e/yaks/kamelets/timer-source-binding.yaml b/e2e/yaks/kamelet-binding/logger-sink-binding.yaml
similarity index 69%
copy from e2e/yaks/kamelets/timer-source-binding.yaml
copy to e2e/yaks/kamelet-binding/logger-sink-binding.yaml
index 32aeefb..bcdd95e 100644
--- a/e2e/yaks/kamelets/timer-source-binding.yaml
+++ b/e2e/yaks/kamelet-binding/logger-sink-binding.yaml
@@ -1,18 +1,15 @@
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
- name: timer-source-binding
+ name: logger-sink-binding
spec:
source:
ref:
- kind: Kamelet
- apiVersion: camel.apache.org/v1alpha1
- name: timer-source
- properties:
- message: Hello Kamelets
- period: 1000
- sink:
- ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1beta1
name: messages
+ sink:
+ ref:
+ kind: Kamelet
+ apiVersion: camel.apache.org/v1alpha1
+ name: logger-sink
diff --git a/e2e/yaks/kamelets/echo-sink.kamelet.yaml b/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
similarity index 57%
copy from e2e/yaks/kamelets/echo-sink.kamelet.yaml
copy to e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
index c21ea6b..a28fc94 100644
--- a/e2e/yaks/kamelets/echo-sink.kamelet.yaml
+++ b/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
@@ -1,19 +1,19 @@
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
- name: echo-sink
+ name: logger-sink
label:
camel.apache.org/kamelet.type: "sink"
spec:
definition:
- title: "Echo"
- description: "Replies with an echo message to each incoming event"
+ title: "Logger"
+ description: "Logs the received payload of each incoming event"
properties:
prefix:
title: Prefix
- description: The prefix to prepend to the incoming event
+ description: The prefix to prepend to the logged message
type: string
- default: "echo: "
+ default: "message: "
types:
in:
mediaType: text/plain
@@ -23,5 +23,4 @@ spec:
from:
uri: "direct:{{routeId}}"
steps:
- - set-body:
- simple: "{{prefix}}${body}"
+ - log: "{{prefix}}${body}"
diff --git a/e2e/yaks/kamelets/messages-channel.yaml b/e2e/yaks/kamelet-binding/messages-channel.yaml
similarity index 100%
rename from e2e/yaks/kamelets/messages-channel.yaml
rename to e2e/yaks/kamelet-binding/messages-channel.yaml
diff --git a/e2e/yaks/kamelets/timer-source-binding.yaml b/e2e/yaks/kamelet-binding/timer-source-binding-display.yaml
similarity index 52%
copy from e2e/yaks/kamelets/timer-source-binding.yaml
copy to e2e/yaks/kamelet-binding/timer-source-binding-display.yaml
index 32aeefb..b217445 100644
--- a/e2e/yaks/kamelets/timer-source-binding.yaml
+++ b/e2e/yaks/kamelet-binding/timer-source-binding-display.yaml
@@ -1,7 +1,7 @@
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
- name: timer-source-binding
+ name: timer-source-binding-display
spec:
source:
ref:
@@ -9,10 +9,6 @@ spec:
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
- message: Hello Kamelets
- period: 1000
+ message: Hello
sink:
- ref:
- kind: InMemoryChannel
- apiVersion: messaging.knative.dev/v1beta1
- name: messages
+ uri: http://display.{namespace}.svc.cluster.local
diff --git a/e2e/yaks/kamelets/timer-source-binding.yaml b/e2e/yaks/kamelet-binding/timer-source-binding.yaml
similarity index 100%
rename from e2e/yaks/kamelets/timer-source-binding.yaml
rename to e2e/yaks/kamelet-binding/timer-source-binding.yaml
diff --git a/e2e/yaks/kamelets/timer-source.kamelet.yaml b/e2e/yaks/kamelet-binding/timer-source.kamelet.yaml
similarity index 100%
copy from e2e/yaks/kamelets/timer-source.kamelet.yaml
copy to e2e/yaks/kamelet-binding/timer-source.kamelet.yaml
diff --git a/e2e/yaks/kamelets/yaks-config.yaml b/e2e/yaks/kamelet-binding/yaks-config.yaml
similarity index 72%
copy from e2e/yaks/kamelets/yaks-config.yaml
copy to e2e/yaks/kamelet-binding/yaks-config.yaml
index 8679b79..59fec0a 100644
--- a/e2e/yaks/kamelets/yaks-config.yaml
+++ b/e2e/yaks/kamelet-binding/yaks-config.yaml
@@ -26,10 +26,14 @@ pre:
kubectl apply -f messages-channel.yaml -n $YAKS_NAMESPACE
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
- kubectl apply -f echo-sink.kamelet.yaml -n $YAKS_NAMESPACE
+ kubectl apply -f logger-sink.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f timer-source-binding.yaml -n $YAKS_NAMESPACE
+ kubectl apply -f logger-sink-binding.yaml -n $YAKS_NAMESPACE
+
kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
+ kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
- kamel run logger.groovy -w -n $YAKS_NAMESPACE
- kamel run source-sink.groovy -w -n $YAKS_NAMESPACE
+ kamel run display.groovy -w -n $YAKS_NAMESPACE
+ cat timer-source-binding-display.yaml | sed 's/{namespace}/'"${YAKS_NAMESPACE}"'/' | kubectl apply -f -
+ kubectl wait kameletbinding timer-source-binding-display --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
diff --git a/e2e/yaks/kamelets/echo-sink.kamelet.yaml b/e2e/yaks/kamelet/echo-sink.kamelet.yaml
similarity index 100%
rename from e2e/yaks/kamelets/echo-sink.kamelet.yaml
rename to e2e/yaks/kamelet/echo-sink.kamelet.yaml
diff --git a/e2e/yaks/kamelet/kamelet.feature b/e2e/yaks/kamelet/kamelet.feature
new file mode 100644
index 0000000..01aca6f
--- /dev/null
+++ b/e2e/yaks/kamelet/kamelet.feature
@@ -0,0 +1,5 @@
+Feature: Camel K can run Kamelets
+
+ Scenario: Integrations can use multiple kamelets
+ Given integration source-sink is running
+ Then integration source-sink should print nice echo: Camel K
diff --git a/e2e/yaks/kamelets/source-sink.groovy b/e2e/yaks/kamelet/source-sink.groovy
similarity index 94%
rename from e2e/yaks/kamelets/source-sink.groovy
rename to e2e/yaks/kamelet/source-sink.groovy
index 3666bad..e607a9f 100755
--- a/e2e/yaks/kamelets/source-sink.groovy
+++ b/e2e/yaks/kamelet/source-sink.groovy
@@ -17,8 +17,7 @@
* limitations under the License.
*/
-from('timer:tick')
- .setBody().constant('Camel K')
+from('kamelet:timer-source?message=Camel+K')
.to("kamelet:echo-sink")
.to("kamelet:echo-sink?prefix=nice+")
.log('${body}')
diff --git a/e2e/yaks/kamelets/timer-source.kamelet.yaml b/e2e/yaks/kamelet/timer-source.kamelet.yaml
similarity index 100%
rename from e2e/yaks/kamelets/timer-source.kamelet.yaml
rename to e2e/yaks/kamelet/timer-source.kamelet.yaml
diff --git a/e2e/yaks/kamelets/yaks-config.yaml b/e2e/yaks/kamelet/yaks-config.yaml
similarity index 81%
rename from e2e/yaks/kamelets/yaks-config.yaml
rename to e2e/yaks/kamelet/yaks-config.yaml
index 8679b79..6ff2355 100644
--- a/e2e/yaks/kamelets/yaks-config.yaml
+++ b/e2e/yaks/kamelet/yaks-config.yaml
@@ -23,13 +23,7 @@ pre:
run: |
kamel install -n $YAKS_NAMESPACE
- kubectl apply -f messages-channel.yaml -n $YAKS_NAMESPACE
-
kubectl apply -f timer-source.kamelet.yaml -n $YAKS_NAMESPACE
kubectl apply -f echo-sink.kamelet.yaml -n $YAKS_NAMESPACE
- kubectl apply -f timer-source-binding.yaml -n $YAKS_NAMESPACE
- kubectl wait kameletbinding timer-source-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
-
- kamel run logger.groovy -w -n $YAKS_NAMESPACE
kamel run source-sink.groovy -w -n $YAKS_NAMESPACE
diff --git a/e2e/yaks/kamelets/kamelet.feature b/e2e/yaks/kamelets/kamelet.feature
deleted file mode 100644
index 2a4d932..0000000
--- a/e2e/yaks/kamelets/kamelet.feature
+++ /dev/null
@@ -1,9 +0,0 @@
-Feature: Camel K can run Kamelets and bind them
-
- Scenario: Running integration using a simple Kamelet with KameletBinding
- Given integration logger is running
- Then integration logger should print Hello Kamelets
-
- Scenario: Integrations can use multiple kamelets
- Given integration source-sink is running
- Then integration source-sink should print nice echo: Camel K
diff --git a/helm/camel-k/crds/crd-kamelet-binding.yaml b/helm/camel-k/crds/crd-kamelet-binding.yaml
index 74575d8..53bf707 100644
--- a/helm/camel-k/crds/crd-kamelet-binding.yaml
+++ b/helm/camel-k/crds/crd-kamelet-binding.yaml
@@ -189,31 +189,35 @@ spec:
apiVersion:
description: API version of the referent.
type: string
- blockOwnerDeletion:
- description: If true, AND if the owner has the "foregroundDeletion"
- finalizer, then the owner cannot be deleted from the key-value
- store until this reference is removed. Defaults to false.
- To set this field, a user needs "delete" permission of the
- owner, otherwise 422 (Unprocessable Entity) will be returned.
- type: boolean
- controller:
- description: If true, this reference points to the managing
- controller.
- type: boolean
+ fieldPath:
+ description: 'If referring to a piece of an object instead of
+ an entire object, this string should contain a valid JSON/Go
+ field access statement, such as desiredState.manifest.containers[2].
+ For example, if the object reference is to a container within
+ a pod, this would take on a value like: "spec.containers{name}"
+ (where "name" refers to the name of the container that triggered
+ the event) or if no container name is specified "spec.containers[2]"
+ (container with index 2 in this pod). This syntax is chosen
+ only to have some well-defined way of referencing a part of
+ an object. TODO: this design is not final and this field is
+ subject to change in the future.'
+ type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
- description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
+ type: string
+ namespace:
+ description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
+ type: string
+ resourceVersion:
+ description: 'Specific resourceVersion to which this reference
+ is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
- description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
+ description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
- required:
- - apiVersion
- - kind
- - name
- - uid
type: object
uri:
description: URI can alternatively be used to specify the (Camel)
@@ -235,31 +239,35 @@ spec:
apiVersion:
description: API version of the referent.
type: string
- blockOwnerDeletion:
- description: If true, AND if the owner has the "foregroundDeletion"
- finalizer, then the owner cannot be deleted from the key-value
- store until this reference is removed. Defaults to false.
- To set this field, a user needs "delete" permission of the
- owner, otherwise 422 (Unprocessable Entity) will be returned.
- type: boolean
- controller:
- description: If true, this reference points to the managing
- controller.
- type: boolean
+ fieldPath:
+ description: 'If referring to a piece of an object instead of
+ an entire object, this string should contain a valid JSON/Go
+ field access statement, such as desiredState.manifest.containers[2].
+ For example, if the object reference is to a container within
+ a pod, this would take on a value like: "spec.containers{name}"
+ (where "name" refers to the name of the container that triggered
+ the event) or if no container name is specified "spec.containers[2]"
+ (container with index 2 in this pod). This syntax is chosen
+ only to have some well-defined way of referencing a part of
+ an object. TODO: this design is not final and this field is
+ subject to change in the future.'
+ type: string
kind:
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
- description: 'Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names'
+ description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
+ type: string
+ namespace:
+ description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
+ type: string
+ resourceVersion:
+ description: 'Specific resourceVersion to which this reference
+ is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
type: string
uid:
- description: 'UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids'
+ description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
- required:
- - apiVersion
- - kind
- - name
- - uid
type: object
uri:
description: URI can alternatively be used to specify the (Camel)
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
index 64702c2..4214074 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
@@ -38,13 +38,20 @@ type KameletBindingSpec struct {
// Endpoint represents a source/sink external entity
type Endpoint struct {
// Ref can be used to declare a Kubernetes resource as source/sink endpoint
- Ref *metav1.OwnerReference `json:"ref,omitempty"`
+ Ref *corev1.ObjectReference `json:"ref,omitempty"`
// URI can alternatively be used to specify the (Camel) endpoint explicitly
URI *string `json:"uri,omitempty"`
// Properties are a key value representation of endpoint properties
Properties EndpointProperties `json:"properties,omitempty"`
}
+type EndpointType string
+
+const (
+ EndpointTypeSource EndpointType = "source"
+ EndpointTypeSink EndpointType = "sink"
+)
+
// EndpointProperties is a key/value struct represented as JSON raw to allow numeric/boolean values
// +kubebuilder:validation:Type=object
type EndpointProperties struct {
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
index f630013..d470dc6 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
@@ -18,6 +18,9 @@ limitations under the License.
package v1alpha1
import (
+ "encoding/json"
+ "fmt"
+
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -137,6 +140,24 @@ func (in *KameletBindingStatus) RemoveCondition(condType KameletBindingCondition
in.Conditions = newConditions
}
+// GetPropertyMap returns the EndpointProperties as map
+func (p EndpointProperties) GetPropertyMap() (map[string]string, error) {
+ if len(p.RawMessage) == 0 {
+ return nil, nil
+ }
+
+ // Convert json property values to objects before getting their string representation
+ var props map[string]interface{}
+ if err := json.Unmarshal(p.RawMessage, &props); err != nil {
+ return nil, err
+ }
+ stringProps := make(map[string]string, len(props))
+ for k, v := range props {
+ stringProps[k] = fmt.Sprintf("%v", v)
+ }
+ return stringProps, nil
+}
+
// NewKameletBinding --
func NewKameletBinding(namespace string, name string) KameletBinding {
return KameletBinding{
diff --git a/pkg/controller/kameletbinding/initialize.go b/pkg/controller/kameletbinding/initialize.go
index d047ae6..1054c3f 100644
--- a/pkg/controller/kameletbinding/initialize.go
+++ b/pkg/controller/kameletbinding/initialize.go
@@ -20,14 +20,11 @@ package kameletbinding
import (
"context"
"encoding/json"
- "fmt"
- "net/url"
- "strings"
v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/bindings"
"github.com/apache/camel-k/pkg/util/kubernetes"
- "github.com/apache/camel-k/pkg/util/uri"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -61,40 +58,33 @@ func (action *initializeAction) Handle(ctx context.Context, kameletbinding *v1al
it.Spec = *kameletbinding.Spec.Integration.DeepCopy()
}
- fromURI, err := getEndpointURI(kameletbinding.Spec.Source)
+ from, err := bindings.Translate(v1alpha1.EndpointTypeSource, kameletbinding.Spec.Source)
if err != nil {
return nil, errors.Wrap(err, "could not determine source URI")
}
- toURI, err := getEndpointURI(kameletbinding.Spec.Sink)
+ to, err := bindings.Translate(v1alpha1.EndpointTypeSink, kameletbinding.Spec.Sink)
if err != nil {
return nil, errors.Wrap(err, "could not determine sink URI")
}
- // TODO remove this after making sinkbinding the default (https://github.com/apache/camel-k/issues/1654)
- if strings.HasPrefix(toURI, "knative:") {
- knativeConfig := map[string]interface{}{
- "sinkBinding": true,
- }
- knativeConfigJSON, err := json.Marshal(knativeConfig)
- if err != nil {
- return nil, err
- }
+ if len(from.Traits) > 0 || len(to.Traits) > 0 {
if it.Spec.Traits == nil {
it.Spec.Traits = make(map[string]v1.TraitSpec)
}
- it.Spec.Traits["knative"] = v1.TraitSpec{
- Configuration: v1.TraitConfiguration{
- RawMessage: knativeConfigJSON,
- },
+ for k, v := range from.Traits {
+ it.Spec.Traits[k] = v
+ }
+ for k, v := range to.Traits {
+ it.Spec.Traits[k] = v
}
}
flow := map[string]interface{}{
"from": map[string]interface{}{
- "uri": fromURI,
+ "uri": from.URI,
"steps": []map[string]interface{}{
{
- "to": toURI,
+ "to": to.URI,
},
},
},
@@ -113,56 +103,3 @@ func (action *initializeAction) Handle(ctx context.Context, kameletbinding *v1al
target.Status.Phase = v1alpha1.KameletBindingPhaseCreating
return target, nil
}
-
-func getEndpointURI(e v1alpha1.Endpoint) (string, error) {
- baseURI, err := getEndpointBaseURI(e)
- if err != nil {
- return baseURI, err
- }
-
- // Convert json properties to string before using them in URI
- if len(e.Properties.RawMessage) > 0 {
- var props map[string]interface{}
- if err := json.Unmarshal(e.Properties.RawMessage, &props); err != nil {
- return "", err
- }
- stringProps := make(map[string]string, len(props))
- for k, v := range props {
- stringProps[k] = fmt.Sprintf("%v", v)
- }
- return uri.AppendParameters(baseURI, stringProps), nil
- }
-
- return baseURI, nil
-}
-
-func getEndpointBaseURI(e v1alpha1.Endpoint) (string, error) {
- if err := validateEndpoint(e); err != nil {
- return "", err
- }
-
- // return the URI if explicitly stated
- if e.URI != nil {
- return *e.URI, nil
- }
-
- // Kamelets are a known type
- if e.Ref.Kind == v1alpha1.KameletKind {
- return fmt.Sprintf("kamelet:%s", url.PathEscape(e.Ref.Name)), nil
- }
-
- // assume we're using Knative for the time being (Kafka resources may be added in the future)
- return uri.AppendParameters(fmt.Sprintf("knative:endpoint/%s", url.PathEscape(e.Ref.Name)), map[string]string{
- "apiVersion": e.Ref.APIVersion,
- "kind": e.Ref.Kind,
- }), nil
-}
-
-func validateEndpoint(e v1alpha1.Endpoint) error {
- if e.Ref == nil && e.URI == nil {
- return errors.New("no ref or URI specified in endpoint")
- } else if e.Ref != nil && e.URI != nil {
- return errors.New("cannot use both ref and URI to specify an endpoint: only one of them should be used")
- }
- return nil
-}
diff --git a/pkg/util/bindings/api.go b/pkg/util/bindings/api.go
new file mode 100644
index 0000000..c9daf72
--- /dev/null
+++ b/pkg/util/bindings/api.go
@@ -0,0 +1,48 @@
+/*
+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 bindings provides APIs to transform Kubernetes objects into Camel URIs equivalents
+package bindings
+
+import (
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+)
+
+const (
+ OrderFirst = 0
+ OrderStandard = 50
+ OrderLast = 100
+)
+
+// Binding represents how a Kubernetes object is represented in Camel K resources
+type Binding struct {
+ // URI is the Camel URI equivalent
+ URI string
+ // Traits is a partial trait specification that should be merged into the integration
+ Traits map[string]v1.TraitSpec
+}
+
+// BindingProvider maps a KameletBinding endpoint into Camel K resources
+type BindingProvider interface {
+ // ID returns the name of the binding provider
+ ID() string
+ // Translate does the actual mapping
+ Translate(endpointType v1alpha1.EndpointType, endpoint v1alpha1.Endpoint) (*Binding, error)
+ // Order returns the relative order of execution of the binding provider
+ Order() int
+}
diff --git a/pkg/util/bindings/bindings_test.go b/pkg/util/bindings/bindings_test.go
new file mode 100644
index 0000000..1f7696a
--- /dev/null
+++ b/pkg/util/bindings/bindings_test.go
@@ -0,0 +1,222 @@
+/*
+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 bindings
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/url"
+ "testing"
+
+ camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ knativeapis "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/stretchr/testify/assert"
+ corev1 "k8s.io/api/core/v1"
+)
+
+func TestBindings(t *testing.T) {
+ testcases := []struct {
+ endpointType v1alpha1.EndpointType
+ endpoint v1alpha1.Endpoint
+ uri string
+ traits map[string]camelv1.TraitSpec
+ }{
+ {
+ endpointType: v1alpha1.EndpointTypeSink,
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Service",
+ APIVersion: "serving.knative.dev/v1",
+ Name: "myservice",
+ },
+ },
+ uri: "knative:endpoint/myservice?apiVersion=serving.knative.dev%2Fv1&kind=Service",
+ traits: asTraitSpec("knative", map[string]interface{}{
+ "sinkBinding": true,
+ }),
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSink,
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Service",
+ APIVersion: "serving.knative.dev/v1",
+ Name: "myservice",
+ },
+ Properties: asEndpointProperties(map[string]string{
+ "ce.override.ce-type": "mytype",
+ }),
+ },
+ uri: "knative:endpoint/myservice?apiVersion=serving.knative.dev%2Fv1&ce.override.ce-type=mytype&kind=Service",
+ traits: asTraitSpec("knative", map[string]interface{}{
+ "sinkBinding": true,
+ }),
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSink,
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Channel",
+ APIVersion: "messaging.knative.dev/v1",
+ Name: "mychannel",
+ },
+ },
+ uri: "knative:channel/mychannel?apiVersion=messaging.knative.dev%2Fv1&kind=Channel",
+ traits: asTraitSpec("knative", map[string]interface{}{
+ "sinkBinding": true,
+ }),
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSource,
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Channel",
+ APIVersion: "messaging.knative.dev/v1",
+ Name: "mychannel",
+ },
+ },
+ uri: "knative:channel/mychannel?apiVersion=messaging.knative.dev%2Fv1&kind=Channel",
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSource,
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "KafkaChannel",
+ APIVersion: "messaging.knative.dev/v1beta1",
+ Name: "mychannel",
+ },
+ },
+ uri: "knative:channel/mychannel?apiVersion=messaging.knative.dev%2Fv1beta1&kind=KafkaChannel",
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSource,
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Broker",
+ APIVersion: "eventing.knative.dev/v1beta1",
+ Name: "default",
+ },
+ Properties: asEndpointProperties(map[string]string{
+ "type": "myeventtype",
+ }),
+ },
+ uri: "knative:event/myeventtype?apiVersion=eventing.knative.dev%2Fv1beta1&kind=Broker",
+ },
+ {
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Kamelet",
+ APIVersion: "camel.apache.org/v1any1",
+ Name: "mykamelet",
+ },
+ },
+ uri: "kamelet:mykamelet",
+ },
+ {
+ endpoint: v1alpha1.Endpoint{
+ Ref: &corev1.ObjectReference{
+ Kind: "Kamelet",
+ APIVersion: "camel.apache.org/v1any1",
+ Name: "mykamelet",
+ },
+ Properties: asEndpointProperties(map[string]string{
+ "mymessage": "myval",
+ "encodedkey?": "encoded=val",
+ }),
+ },
+ uri: "kamelet:mykamelet?encodedkey%3F=encoded%3Dval&mymessage=myval",
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSink,
+ endpoint: v1alpha1.Endpoint{
+ URI: asStringPointer("https://myurl/hey"),
+ Properties: asEndpointProperties(map[string]string{
+ "ce.override.ce-type": "mytype",
+ }),
+ },
+ uri: "knative:endpoint/sink?ce.override.ce-type=mytype",
+ traits: asTraitSpec("knative", map[string]interface{}{
+ "configuration": asKnativeConfig("https://myurl/hey"),
+ }),
+ },
+ {
+ endpointType: v1alpha1.EndpointTypeSink,
+ endpoint: v1alpha1.Endpoint{
+ URI: asStringPointer("docker://xxx"),
+ },
+ uri: "docker://xxx",
+ },
+ }
+
+ for i, tc := range testcases {
+ t.Run(fmt.Sprintf("test-%d-%s", i, tc.uri), func(t *testing.T) {
+ binding, err := Translate(tc.endpointType, tc.endpoint)
+ assert.NoError(t, err)
+ assert.NotNil(t, binding)
+ assert.Equal(t, tc.uri, binding.URI)
+ assert.Equal(t, tc.traits, binding.Traits)
+ })
+ }
+}
+
+func asEndpointProperties(props map[string]string) v1alpha1.EndpointProperties {
+ serialized, err := json.Marshal(props)
+ if err != nil {
+ panic(err)
+ }
+ return v1alpha1.EndpointProperties{
+ RawMessage: serialized,
+ }
+}
+
+func asTraitSpec(key string, data map[string]interface{}) map[string]camelv1.TraitSpec {
+ res := make(map[string]camelv1.TraitSpec)
+ serialized, err := json.Marshal(data)
+ if err != nil {
+ panic(err)
+ }
+ res[key] = camelv1.TraitSpec{
+ Configuration: camelv1.TraitConfiguration{
+ RawMessage: serialized,
+ },
+ }
+ return res
+}
+
+func asStringPointer(str string) *string {
+ return &str
+}
+
+func asKnativeConfig(endpointURL string) string {
+ serviceURL, err := url.Parse(endpointURL)
+ if err != nil {
+ panic(err)
+ }
+ def, err := knativeapis.BuildCamelServiceDefinition("sink", knativeapis.CamelEndpointKindSink, knativeapis.CamelServiceTypeEndpoint, *serviceURL, "", "")
+ if err != nil {
+ panic(err)
+ }
+ env := knativeapis.NewCamelEnvironment()
+ env.Services = append(env.Services, def)
+ serialized, err := json.Marshal(env)
+ if err != nil {
+ panic(err)
+ }
+ return string(serialized)
+}
diff --git a/pkg/util/bindings/camel_uri.go b/pkg/util/bindings/camel_uri.go
new file mode 100644
index 0000000..6dfea5f
--- /dev/null
+++ b/pkg/util/bindings/camel_uri.go
@@ -0,0 +1,58 @@
+/*
+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 bindings
+
+import (
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/uri"
+)
+
+// CamelURIBindingProvider converts an explicit URI into a Camel endpoint.
+// It's used as fallback if the URI scheme is not known by other providers.
+type CamelURIBindingProvider struct{}
+
+func (k CamelURIBindingProvider) ID() string {
+ return "camel-uri"
+}
+
+func (k CamelURIBindingProvider) Translate(endpointType v1alpha1.EndpointType, e v1alpha1.Endpoint) (*Binding, error) {
+ if e.URI == nil {
+ // works only on uris
+ return nil, nil
+ }
+
+ endpointURI := *e.URI
+ props, err := e.Properties.GetPropertyMap()
+ if err != nil {
+ return nil, err
+ }
+ endpointURI = uri.AppendParameters(endpointURI, props)
+
+ return &Binding{
+ URI: endpointURI,
+ }, nil
+}
+
+func (k CamelURIBindingProvider) Order() int {
+ // Using it as fallback
+ return OrderLast
+}
+
+func init() {
+ RegisterBindingProvider(CamelURIBindingProvider{})
+}
diff --git a/pkg/util/bindings/catalog.go b/pkg/util/bindings/catalog.go
new file mode 100644
index 0000000..0fa42ee
--- /dev/null
+++ b/pkg/util/bindings/catalog.go
@@ -0,0 +1,61 @@
+/*
+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 bindings
+
+import (
+ "errors"
+ "sort"
+
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+)
+
+var bindingProviders []BindingProvider
+
+func RegisterBindingProvider(bp BindingProvider) {
+ bindingProviders = append(bindingProviders, bp)
+ sort.Slice(bindingProviders, func(i, j int) bool {
+ bi := bindingProviders[i]
+ bj := bindingProviders[j]
+ return (bi.Order() < bj.Order()) ||
+ (bi.Order() == bj.Order() && bi.ID() < bj.ID())
+ })
+}
+
+// Translate execute all chained binding providers, returning the first success or the first error
+func Translate(endpointType v1alpha1.EndpointType, endpoint v1alpha1.Endpoint) (*Binding, error) {
+ if err := validateEndpoint(endpoint); err != nil {
+ return nil, err
+ }
+
+ for _, bp := range bindingProviders {
+ b, err := bp.Translate(endpointType, endpoint)
+ if b != nil || err != nil {
+ return b, err
+ }
+ }
+ return nil, nil
+}
+
+func validateEndpoint(e v1alpha1.Endpoint) error {
+ if e.Ref == nil && e.URI == nil {
+ return errors.New("no ref or URI specified in endpoint")
+ } else if e.Ref != nil && e.URI != nil {
+ return errors.New("cannot use both ref and URI to specify an endpoint: only one of them should be used")
+ }
+ return nil
+}
diff --git a/pkg/util/bindings/kamelet.go b/pkg/util/bindings/kamelet.go
new file mode 100644
index 0000000..7e8d166
--- /dev/null
+++ b/pkg/util/bindings/kamelet.go
@@ -0,0 +1,68 @@
+/*
+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 bindings
+
+import (
+ "fmt"
+ "net/url"
+
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/uri"
+ "k8s.io/apimachinery/pkg/runtime/schema"
+)
+
+// KameletBindingProvider converts a reference to a Kamelet into a Camel URI
+type KameletBindingProvider struct{}
+
+func (k KameletBindingProvider) ID() string {
+ return "kamelet"
+}
+
+func (k KameletBindingProvider) Translate(endpointType v1alpha1.EndpointType, e v1alpha1.Endpoint) (*Binding, error) {
+ if e.Ref == nil {
+ // works only on refs
+ return nil, nil
+ }
+ gv, err := schema.ParseGroupVersion(e.Ref.APIVersion)
+ if err != nil {
+ return nil, err
+ }
+ // it translates only Kamelet refs
+ if e.Ref.Kind == v1alpha1.KameletKind && gv.Group == v1alpha1.SchemeGroupVersion.Group {
+ kameletURI := fmt.Sprintf("kamelet:%s", url.PathEscape(e.Ref.Name))
+
+ props, err := e.Properties.GetPropertyMap()
+ if err != nil {
+ return nil, err
+ }
+ kameletURI = uri.AppendParameters(kameletURI, props)
+
+ return &Binding{
+ URI: kameletURI,
+ }, nil
+ }
+ return nil, nil
+}
+
+func (k KameletBindingProvider) Order() int {
+ return OrderStandard
+}
+
+func init() {
+ RegisterBindingProvider(KameletBindingProvider{})
+}
diff --git a/pkg/util/bindings/knative_ref.go b/pkg/util/bindings/knative_ref.go
new file mode 100644
index 0000000..bd7f7a3
--- /dev/null
+++ b/pkg/util/bindings/knative_ref.go
@@ -0,0 +1,116 @@
+/*
+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 bindings
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/url"
+
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ knativeapis "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/knative"
+ "github.com/apache/camel-k/pkg/util/uri"
+)
+
+// KnativeRefBindingProvider converts a reference to a Kubernetes object into a Camel URI.
+// It's used as fallback if no other providers can decode the object reference.
+type KnativeRefBindingProvider struct{}
+
+func (k KnativeRefBindingProvider) ID() string {
+ return "knative-ref"
+}
+
+func (k KnativeRefBindingProvider) Translate(endpointType v1alpha1.EndpointType, e v1alpha1.Endpoint) (*Binding, error) {
+ if e.Ref == nil {
+ // works only on refs
+ return nil, nil
+ }
+
+ serviceType, err := knative.GetServiceType(*e.Ref)
+ if err != nil {
+ return nil, err
+ }
+
+ if serviceType == nil {
+ endpointType := knativeapis.CamelServiceTypeEndpoint
+ serviceType = &endpointType
+ }
+
+ props, err := e.Properties.GetPropertyMap()
+ if err != nil {
+ return nil, err
+ }
+ if props == nil {
+ props = make(map[string]string)
+ }
+ if props["apiVersion"] == "" {
+ props["apiVersion"] = e.Ref.APIVersion
+ }
+ if props["kind"] == "" {
+ props["kind"] = e.Ref.Kind
+ }
+
+ var serviceURI string
+ if *serviceType == knativeapis.CamelServiceTypeEvent {
+ if eventType, ok := props["type"]; ok {
+ // consume prop
+ delete(props, "type")
+ serviceURI = fmt.Sprintf("knative:%s/%s", *serviceType, eventType)
+ } else {
+ serviceURI = fmt.Sprintf("knative:%s", *serviceType)
+ }
+ } else {
+ serviceURI = fmt.Sprintf("knative:%s/%s", *serviceType, url.PathEscape(e.Ref.Name))
+ }
+
+ serviceURI = uri.AppendParameters(serviceURI, props)
+
+ var traits map[string]v1.TraitSpec
+ if endpointType == v1alpha1.EndpointTypeSink {
+ knativeConfig := make(map[string]interface{})
+ // TODO remove this after making sinkbinding the default (https://github.com/apache/camel-k/issues/1654)
+ knativeConfig["sinkBinding"] = true
+ knativeConfigJSON, err := json.Marshal(knativeConfig)
+ if err != nil {
+ return nil, err
+ }
+ traits = map[string]v1.TraitSpec{
+ "knative": {
+ Configuration: v1.TraitConfiguration{
+ RawMessage: knativeConfigJSON,
+ },
+ },
+ }
+ }
+
+ return &Binding{
+ URI: serviceURI,
+ Traits: traits,
+ }, nil
+}
+
+func (k KnativeRefBindingProvider) Order() int {
+ // Executes as last, as it can be used as fallback for all unknown object references
+ return OrderLast
+}
+
+func init() {
+ RegisterBindingProvider(KnativeRefBindingProvider{})
+}
diff --git a/pkg/util/bindings/knative_uri.go b/pkg/util/bindings/knative_uri.go
new file mode 100644
index 0000000..0f43cfa
--- /dev/null
+++ b/pkg/util/bindings/knative_uri.go
@@ -0,0 +1,102 @@
+/*
+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 bindings
+
+import (
+ "encoding/json"
+ "net/url"
+ "strings"
+
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+ knativeapis "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
+ "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+ "github.com/apache/camel-k/pkg/util/uri"
+)
+
+// KnativeURIBindingProvider converts a HTTP/HTTPS URI into a Camel Knative endpoint (to call it via CloudEvents).
+type KnativeURIBindingProvider struct{}
+
+func (k KnativeURIBindingProvider) ID() string {
+ return "knative-uri"
+}
+
+func (k KnativeURIBindingProvider) Translate(endpointType v1alpha1.EndpointType, e v1alpha1.Endpoint) (*Binding, error) {
+ if e.URI == nil {
+ // works only on uris
+ return nil, nil
+ }
+ if !strings.HasPrefix(*e.URI, "http:") && !strings.HasPrefix(*e.URI, "https:") {
+ // only translates http/https uri to Knative calls
+ return nil, nil
+ }
+ if endpointType == v1alpha1.EndpointTypeSource {
+ // HTTP/HTTPS uri are translated to Knative endpoints only when used as sinks
+ return nil, nil
+ }
+
+ knativeConfig := make(map[string]interface{})
+ originalURI, err := url.Parse(*e.URI)
+ if err != nil {
+ return nil, err
+ }
+ env := knativeapis.NewCamelEnvironment()
+ svc, err := knativeapis.BuildCamelServiceDefinition("sink",
+ knativeapis.CamelEndpointKindSink,
+ knativeapis.CamelServiceTypeEndpoint,
+ *originalURI, "", "")
+ if err != nil {
+ return nil, err
+ }
+ env.Services = append(env.Services, svc)
+ config, err := env.Serialize()
+ if err != nil {
+ return nil, err
+ }
+ knativeConfig["configuration"] = config
+ knativeConfigJSON, err := json.Marshal(knativeConfig)
+ if err != nil {
+ return nil, err
+ }
+
+ // Rewrite URI to match the service definition
+ serviceURI := "knative:endpoint/sink"
+ props, err := e.Properties.GetPropertyMap()
+ if err != nil {
+ return nil, err
+ }
+ serviceURI = uri.AppendParameters(serviceURI, props)
+
+ return &Binding{
+ URI: serviceURI,
+ Traits: map[string]v1.TraitSpec{
+ "knative": {
+ Configuration: v1.TraitConfiguration{
+ RawMessage: knativeConfigJSON,
+ },
+ },
+ },
+ }, nil
+}
+
+func (k KnativeURIBindingProvider) Order() int {
+ return OrderStandard
+}
+
+func init() {
+ RegisterBindingProvider(KnativeURIBindingProvider{})
+}
diff --git a/pkg/util/knative/apis.go b/pkg/util/knative/apis.go
index 72607f1..67bf5b2 100644
--- a/pkg/util/knative/apis.go
+++ b/pkg/util/knative/apis.go
@@ -176,6 +176,36 @@ func FillMissingReferenceData(serviceType knativev1.CamelServiceType, ref v1.Obj
return refs
}
+func GetServiceType(ref v1.ObjectReference) (*knativev1.CamelServiceType, error) {
+ refGV, err := schema.ParseGroupVersion(ref.APIVersion)
+ if err != nil {
+ return nil, err
+ }
+
+ for _, c := range KnownChannelKinds {
+ if c.Group == refGV.Group && c.Kind == ref.Kind {
+ channelType := knativev1.CamelServiceTypeChannel
+ return &channelType, nil
+ }
+ }
+
+ for _, c := range KnownBrokerKinds {
+ if c.Group == refGV.Group && c.Kind == ref.Kind {
+ eventType := knativev1.CamelServiceTypeEvent
+ return &eventType, nil
+ }
+ }
+
+ for _, c := range KnownEndpointKinds {
+ if c.Group == refGV.Group && c.Kind == ref.Kind {
+ endpointType := knativev1.CamelServiceTypeEndpoint
+ return &endpointType, nil
+ }
+ }
+
+ return nil, nil
+}
+
// nolint: gocritic
func fillMissingReferenceDataWith(serviceTypes []GroupVersionKindResource, ref v1.ObjectReference) []v1.ObjectReference {
list := make([]v1.ObjectReference, 0)
[camel-k] 07/08: chore(e2e): fix deepcopy and regen
Posted by nf...@apache.org.
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 69bb64a766907d463ae5c933982dcaa395f5ea8c
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Mon Oct 5 17:20:00 2020 +0200
chore(e2e): fix deepcopy and regen
---
deploy/resources.go | 57 +-----------------------
go.mod | 1 +
pkg/apis/camel/v1alpha1/kamelet_binding_types.go | 6 +--
pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go | 6 +--
pkg/client/camel/go.mod | 1 +
5 files changed, 10 insertions(+), 61 deletions(-)
diff --git a/deploy/resources.go b/deploy/resources.go
index b6c4ef3..76daba7 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -112,9 +112,9 @@ var assets = func() http.FileSystem {
"/crd-build.yaml": &vfsgen۰CompressedFileInfo{
name: "crd-build.yaml",
modTime: time.Time{},
- uncompressedSize: 301996,
+ uncompressedSize: 301790,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x6b\x73\x23\xb9\x91\x28\x0c\x7f\x9f\x5f\x81\xd0\x38\x42\xd2\x5a\xa4\xba\xbd\x5e\xaf\xdd\xde\xd8\x09\x4d\x4b\x3d\xab\xd7\x7d\xd1\x69\xaa\x67\xde\x13\x63\xaf\x03\xac\x02\x49\xac\xaa\x80\x1a\x00\x25\x35\x7d\x66\xff\xfb\x13\x48\x00\x75\xe1\xad\x12\x45\x4a\xad\x19\x17\xbe\x74\x8b\x64\x65\x01\x89\x44\x22\xef\xf9\x35\x19\x1d\x6e\x7c\xf5\x35\x79\xcb\x13\x26\x34\x4b\x89\x91\xc4\x2c\x18\xb9\x28\x68\xb2\x60\x64\x22\x67\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x6b\x73\x1b\x37\x96\x30\x8e\xbf\xcf\xa7\x40\x29\x53\x25\x69\x23\x52\xf6\x6c\x76\x76\x46\xb3\x35\x29\xc5\x92\x33\xfa\x27\xb6\xf5\x58\x72\xf2\x7f\x2a\x93\x9d\x02\xbb\x41\x12\xab\x6e\xa0\x03\xa0\x25\x73\x9e\xec\x77\xff\x15\x0e\x80\xbe\xf0\xd6\x07\x4d\x4a\x56\x92\xc6\x1b\x5b\x24\xfb\x34\x2e\x07\xe7\x7e\xf9\x9c\x8c\xf6\x37\x3e\xfb\x9c\x7c\xc7\x13\x26\x34\x4b\x89\x91\xc4\xcc\x19\x39\x2f\x68\x32\x67\xe4\x46\x4e\xcd\x [...]
},
"/crd-camel-catalog.yaml": &vfsgen۰CompressedFileInfo{
name: "crd-camel-catalog.yaml",
@@ -158,59 +158,6 @@ var assets = func() http.FileSystem {
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xd4\x7d\x6d\x73\xdb\xba\xb1\xff\x7b\x7f\x8a\x1d\xbb\x33\xb5\x67\x4c\x59\xf2\x43\x9a\xe8\xff\x22\xe3\x3a\x49\xff\xea\xc9\x89\x33\xb6\xd3\x4e\x6f\x7c\x3a\x81\xc8\x95\x84\x9a\x04\x58\x00\xb4\xad\x36\xf9\xee\x77\xf0\x40\x91\x92\x40\x90\x92\xed\x9c\xb9\x98\xc9\x44\xa4\x80\xc5\x62\xb1\xd8\x5d\x2c\xf0\xb3\xf6\x20\x7a\xbe\xb2\xb3\x07\x1f\x69\x8c\x4c\x62\x02\x8a\x83\x9a\x21\x9c\xe7\x24\x9e\x21\x5c\xf3\x89\x7a\x20\x02\xe1\x03\x [...]
},
- "/crds": &vfsgen۰DirInfo{
- name: "crds",
- modTime: time.Time{},
- },
- "/crds/camel.apache.org_builds.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_builds.yaml",
- modTime: time.Time{},
- uncompressedSize: 301128,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xbd\xeb\x72\x23\x37\x92\x30\xfa\x7f\x9e\x02\xa1\x99\x08\x49\x6b\x91\xea\x9e\xf5\xce\xce\xf4\x6e\x8c\x43\x6e\xa9\x3d\x3a\xee\x8b\xbe\x56\xb7\x7d\x4e\x78\xbc\x13\x60\x15\x48\x62\x54\x05\x94\x01\x94\xd4\x9c\xcf\xfb\xee\x27\x90\x00\xea\xc2\x5b\x25\x8a\xa4\x5a\xb6\x0b\x7f\xba\x45\xb2\xb2\x80\x44\x22\x91\xf7\xfc\xdd\x68\x34\xfa\x1d\x2d\xf8\x77\x4c\x69\x2e\xc5\x0b\x42\x0b\xce\x3e\x19\x26\xec\x5f\x7a\x7c\xf7\x67\x3d\xe6\x [...]
- },
- "/crds/camel.apache.org_camelcatalogs.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_camelcatalogs.yaml",
- modTime: time.Time{},
- uncompressedSize: 8416,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x59\xcd\x72\xdb\x38\x12\xbe\xeb\x29\xba\xb2\x87\x5c\x96\x94\xec\x6c\x52\x89\x6e\x29\x25\x07\x6f\x7e\xd6\x15\xbb\x7c\x6f\x81\x2d\x09\x31\x09\x60\x01\x50\x15\xcf\xd4\xbc\xfb\x14\x00\x52\x22\x25\x92\x40\x12\x27\x99\xa9\x1a\x9c\x44\xa0\xd9\x3f\x5f\xf7\xd7\x04\x84\x59\x96\x65\x33\x54\xfc\x8e\xb4\xe1\x52\x2c\x01\x15\xa7\x2f\x96\x84\x7b\x32\xf9\xfd\x4b\x93\x73\x39\xdf\x5f\xac\xc9\xe2\xc5\xec\x9e\x8b\x62\x09\xab\xda\x58\x [...]
- },
- "/crds/camel.apache.org_integrationkits.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_integrationkits.yaml",
- modTime: time.Time{},
- uncompressedSize: 6536,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x59\x4d\x73\xdb\xbc\x11\xbe\xeb\x57\xec\xbc\x3d\xe4\x12\x52\xb6\xd3\x64\x12\xdd\x3c\x6e\x33\xe3\xe6\xa3\x1e\xdb\xc9\xc9\x97\x25\xb8\x92\x50\x81\x00\x0b\x2c\x95\xb8\x9d\xfe\xf7\x0e\x00\x92\x22\x45\x52\x96\x94\x37\x3a\x19\xc0\x62\xf7\xd9\x07\xfb\x01\xc2\xb3\x24\x49\x66\x58\xca\xef\x64\x9d\x34\x7a\x01\x58\x4a\xfa\xc9\xa4\xfd\xc8\xa5\x9b\xf7\x2e\x95\x66\xbe\xbd\xcc\x88\xf1\x72\xb6\x91\x3a\x5f\xc0\x4d\xe5\xd8\x14\xf7\x [...]
- },
- "/crds/camel.apache.org_integrationplatforms.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_integrationplatforms.yaml",
- modTime: time.Time{},
- uncompressedSize: 14137,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5b\x4f\x73\xeb\xb6\x11\xbf\xeb\x53\xec\x24\x07\x5f\x4c\xc9\xcf\x69\x32\x89\x2e\x9d\x57\xa5\x9d\x71\x93\x97\xa7\xb1\x1d\xdf\x57\xe4\x4a\x42\x05\x02\x2c\x16\x94\xa3\x74\xfa\xdd\x3b\x00\x48\x8a\x94\x40\x49\x96\x9b\x76\x92\x21\x2e\x12\x49\xec\xe2\xb7\x8b\xfd\xc7\x25\x39\x4a\x92\x64\x84\x85\x78\x21\xc3\x42\xab\x29\x60\x21\xe8\x17\x4b\xca\x1d\xf1\x78\xf3\x2d\x8f\x85\x9e\x6c\x3f\x2c\xc8\xe2\x87\xd1\x46\xa8\x6c\x0a\xb3\x [...]
- },
- "/crds/camel.apache.org_integrations.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_integrations.yaml",
- modTime: time.Time{},
- uncompressedSize: 11598,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x1a\xcb\x72\xe3\xb8\xf1\xae\xaf\xe8\x9a\x1c\x26\xa9\x1a\x4a\x1e\x4f\x66\x6b\x57\x37\x97\x93\xad\x72\xe6\x11\x97\xed\x9d\x7b\x13\x68\x4a\x88\x41\x80\x01\x40\x79\x9c\x54\xfe\x3d\x05\x80\x14\x1f\x22\x65\x8a\x9e\xcd\x21\x25\x9c\x04\x10\x8d\x7e\xa2\x5f\xc2\x22\x49\x92\x05\x16\xe2\x1b\x19\x2b\xb4\x5a\x03\x16\x82\xbe\x3b\x52\x7e\x66\x97\x8f\x3f\xdb\xa5\xd0\xab\xdd\xfb\x94\x1c\xbe\x5f\x3c\x0a\xc5\xd7\x70\x5d\x5a\xa7\xf3\x [...]
- },
- "/crds/camel.apache.org_kameletbindings.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_kameletbindings.yaml",
- modTime: time.Time{},
- uncompressedSize: 12192,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5a\xcd\x72\xe3\x36\x12\xbe\xeb\x29\xba\x9c\xc3\x4c\xaa\x4c\xca\xf6\x64\x52\x89\x6e\x5e\x3b\x5b\xe5\x9d\xd9\x89\xcb\x3f\x73\x6f\x02\x4d\x09\x2b\x10\xe0\x02\xa0\x1d\x65\x6b\xdf\x3d\x05\x80\xa4\x28\x89\xa4\x64\x6b\xa6\x72\x31\x4f\x12\x01\x34\xfa\xbf\x3f\x34\x31\x49\x92\x64\x82\xa5\xf8\x4a\xc6\x0a\xad\x66\x80\xa5\xa0\x3f\x1c\x29\xff\xcf\xa6\xcb\x5f\x6c\x2a\xf4\xf4\xe9\x3c\x23\x87\xe7\x93\xa5\x50\x7c\x06\x57\x95\x75\x [...]
- },
- "/crds/camel.apache.org_kamelets.yaml": &vfsgen۰CompressedFileInfo{
- name: "camel.apache.org_kamelets.yaml",
- modTime: time.Time{},
- uncompressedSize: 31119,
-
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xdc\x5d\x6f\x6f\xdb\x38\xd2\x7f\xdf\x4f\x31\xc8\x2d\xb0\x09\x10\x39\x76\x9c\x74\x5b\xbf\x29\xb2\xed\xf6\x90\x67\xb7\xdb\x20\x49\xf7\xc5\xd3\xf4\x50\x5a\x1a\xdb\xbc\x48\xa4\x8e\xa4\x92\x78\xaf\xfd\xee\x0f\xf8\x47\xb6\x6c\x93\x94\xec\x24\x7b\x78\x8e\xc0\x62\x23\x99\x1c\x0e\x87\xc3\x99\xe1\x90\xbf\xea\x45\x92\x24\x2f\x48\x49\xff\x40\x21\x29\x67\x23\x20\x25\xc5\x07\x85\x4c\x3f\xc9\xde\xed\x2b\xd9\xa3\xfc\xe8\x6e\x30\x46\x [...]
- },
"/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-deployment.yaml",
modTime: time.Time{},
diff --git a/go.mod b/go.mod
index 3f22a24..e101e31 100644
--- a/go.mod
+++ b/go.mod
@@ -56,6 +56,7 @@ replace (
k8s.io/apimachinery => k8s.io/apimachinery v0.17.6
k8s.io/client-go => k8s.io/client-go v0.17.6
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.5.11
+ k8s.io/code-generator => k8s.io/code-generator v0.17.6
)
replace github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 // Required by Helm
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
index 4214074..b1cc853 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
@@ -105,13 +105,13 @@ const (
KameletBindingPhaseReady KameletBindingPhase = "Ready"
)
-// KameletBinding is the Schema for the kamelets binding API
-// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
-// +k8s:openapi-gen=true
+// +kubebuilder:object:root=true
// +genclient
// +kubebuilder:resource:path=kameletbindings,scope=Namespaced,shortName=klb,categories=kamel;camel
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`,description="The Kamelet Binding phase"
+
+// KameletBinding is the Schema for the kamelets binding API
type KameletBinding struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
diff --git a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
index 5f5082b..2601efc 100644
--- a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
@@ -7,7 +7,7 @@ package v1alpha1
import (
"encoding/json"
"github.com/apache/camel-k/pkg/apis/camel/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)
@@ -31,8 +31,8 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
*out = *in
if in.Ref != nil {
in, out := &in.Ref, &out.Ref
- *out = new(metav1.OwnerReference)
- (*in).DeepCopyInto(*out)
+ *out = new(corev1.ObjectReference)
+ **out = **in
}
if in.URI != nil {
in, out := &in.URI, &out.URI
diff --git a/pkg/client/camel/go.mod b/pkg/client/camel/go.mod
index be09399..040a55b 100644
--- a/pkg/client/camel/go.mod
+++ b/pkg/client/camel/go.mod
@@ -11,6 +11,7 @@ require (
replace (
k8s.io/apimachinery => k8s.io/apimachinery v0.17.6
k8s.io/client-go => k8s.io/client-go v0.17.6
+ k8s.io/code-generator => k8s.io/code-generator v0.17.6
)
// Local modules
[camel-k] 08/08: chore(e2e): fix test chore(e2e): fix http
cloudevent test
Posted by nf...@apache.org.
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 7de8fb20602a5851b222227a23eaf6fd8ea6af00
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Mon Oct 5 18:13:45 2020 +0200
chore(e2e): fix test
chore(e2e): fix http cloudevent test
---
e2e/yaks/common/kamelet-binding/display.groovy | 2 +-
e2e/yaks/common/kamelet-binding/kamelet.feature | 5 +++++
e2e/yaks/common/kamelet-binding/yaks-config.yaml | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/e2e/yaks/common/kamelet-binding/display.groovy b/e2e/yaks/common/kamelet-binding/display.groovy
index b3ba363..a6e32c3 100644
--- a/e2e/yaks/common/kamelet-binding/display.groovy
+++ b/e2e/yaks/common/kamelet-binding/display.groovy
@@ -18,5 +18,5 @@
from('knative:endpoint/display')
.log('${body}')
- .setBody().header('CE-Type')
+ .setBody().header('CamelCloudEventType')
.log('type: ${body}');
diff --git a/e2e/yaks/common/kamelet-binding/kamelet.feature b/e2e/yaks/common/kamelet-binding/kamelet.feature
index 2d04ce1..84e2a76 100644
--- a/e2e/yaks/common/kamelet-binding/kamelet.feature
+++ b/e2e/yaks/common/kamelet-binding/kamelet.feature
@@ -3,3 +3,8 @@ Feature: Camel K can bind Kamelets
Scenario: Running integration using a simple Kamelet with KameletBinding
Given integration logger-sink-binding is running
Then integration logger-sink-binding should print message: Hello Kamelets
+
+ Scenario: Binding to a HTTP URI should use CloudEvents
+ Given integration display is running
+ Then integration display should print type: org.apache.camel.event
+ Then integration display should print Hello
diff --git a/e2e/yaks/common/kamelet-binding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
index 59fec0a..1e0370b 100644
--- a/e2e/yaks/common/kamelet-binding/yaks-config.yaml
+++ b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
@@ -35,5 +35,5 @@ pre:
kubectl wait kameletbinding logger-sink-binding --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
kamel run display.groovy -w -n $YAKS_NAMESPACE
- cat timer-source-binding-display.yaml | sed 's/{namespace}/'"${YAKS_NAMESPACE}"'/' | kubectl apply -f -
+ cat timer-source-binding-display.yaml | sed 's/{namespace}/'"${YAKS_NAMESPACE}"'/' | kubectl apply -n $YAKS_NAMESPACE -f -
kubectl wait kameletbinding timer-source-binding-display --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
[camel-k] 03/08: chore(e2e): refactor tests to run all them
Posted by nf...@apache.org.
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 7fea5bf492330db0e6edd3eb53005b81b8a462ef
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Fri Oct 2 17:32:49 2020 +0200
chore(e2e): refactor tests to run all them
---
.github/workflows/knative.yml | 3 +--
deploy/resources.go | 4 ++--
e2e/yaks/{ => common}/kamelet-binding/display.groovy | 0
e2e/yaks/{ => common}/kamelet-binding/kamelet.feature | 0
e2e/yaks/{ => common}/kamelet-binding/logger-sink-binding.yaml | 0
e2e/yaks/{ => common}/kamelet-binding/logger-sink.kamelet.yaml | 0
.../kamelet-binding}/messages-channel.yaml | 0
.../{ => common}/kamelet-binding/timer-source-binding-display.yaml | 0
e2e/yaks/{ => common}/kamelet-binding/timer-source-binding.yaml | 0
.../{kamelet => common/kamelet-binding}/timer-source.kamelet.yaml | 0
e2e/yaks/{ => common}/kamelet-binding/yaks-config.yaml | 0
e2e/yaks/{ => common}/kamelet/echo-sink.kamelet.yaml | 0
e2e/yaks/{ => common}/kamelet/kamelet.feature | 0
e2e/yaks/{ => common}/kamelet/source-sink.groovy | 0
.../{kamelet-binding => common/kamelet}/timer-source.kamelet.yaml | 0
e2e/yaks/{ => common}/kamelet/yaks-config.yaml | 0
.../knative-sinkbinding}/messages-channel.yaml | 0
e2e/yaks/{ => common}/knative-sinkbinding/receiver.groovy | 0
e2e/yaks/{ => common}/knative-sinkbinding/sinkbinding.feature | 0
e2e/yaks/{ => common}/knative-sinkbinding/source.yaml | 0
e2e/yaks/{ => common}/knative-sinkbinding/yaks-config.yaml | 0
e2e/yaks/{ => common}/knative/receiver.groovy | 0
e2e/yaks/{ => common}/knative/source.yaml | 0
e2e/yaks/{ => common}/knative/sources.feature | 0
e2e/yaks/{ => common}/knative/yaks-config.yaml | 0
e2e/yaks/{ => common}/yaks-config.yaml | 0
e2e/yaks/{ => openshift}/monitoring/Metrics.java | 0
e2e/yaks/{ => openshift}/monitoring/app/pom.xml | 0
.../app/src/main/java/org/apache/camel/integration/Service.java | 0
e2e/yaks/{ => openshift}/monitoring/metrics.feature | 0
e2e/yaks/{ => openshift}/monitoring/obtainToken.sh | 0
e2e/yaks/{ => openshift}/monitoring/yaks-config.yaml | 0
e2e/yaks/{ => openshift}/yaks-config.yaml | 0
33 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml
index e27f1e1..4e01d19 100644
--- a/.github/workflows/knative.yml
+++ b/.github/workflows/knative.yml
@@ -333,5 +333,4 @@ jobs:
export CAMEL_K_TEST_IMAGE_NAME=${CAMEL_K_REGISTRY}:5000/apache/camel-k
export CAMEL_K_TEST_IMAGE_VERSION=$(make version)
- yaks test e2e/yaks/knative
- yaks test e2e/yaks/knative-sinkbinding
+ yaks test e2e/yaks/common
diff --git a/deploy/resources.go b/deploy/resources.go
index 3f1fabd..b6c4ef3 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -147,9 +147,9 @@ var assets = func() http.FileSystem {
"/crd-kamelet-binding.yaml": &vfsgen۰CompressedFileInfo{
name: "crd-kamelet-binding.yaml",
modTime: time.Time{},
- uncompressedSize: 13060,
+ uncompressedSize: 14596,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5b\x4d\x73\xe3\x36\xd2\xbe\xf3\x57\x74\x49\x87\xcc\x54\x59\x94\xc7\xf9\xa8\x44\xef\x49\xb1\x67\xea\xd5\x8e\xd7\x76\x59\x72\x52\x39\x82\x64\x8b\xc2\x0a\x04\xb8\x00\x68\x8d\xb2\xb5\xff\x7d\x0b\x0d\x92\xa2\x24\x92\xd2\xd8\x93\xca\xc5\x3c\x59\x04\xd0\xe8\xef\x7e\xd0\x84\x87\x30\xfa\x76\x4f\x30\x84\x5b\x1e\xa3\x34\x98\x80\x55\x60\x57\x08\xd3\x9c\xc5\x2b\x84\xb9\x5a\xda\x0d\xd3\x08\x9f\x54\x21\x13\x66\xb9\x92\xf0\x6e\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5b\x5f\x73\xdb\x36\x12\x7f\xd7\xa7\xd8\xb1\x1e\x92\xcc\x58\x94\xe3\x5e\x3b\xad\xee\xc9\x75\x92\x3b\x5d\x72\x76\xc6\x52\xda\xe9\x74\xfa\x00\x91\x2b\x09\x27\x10\xe0\x01\xa0\x64\x5d\xa7\xdf\xfd\x66\x17\x24\x45\x49\x24\xad\xd8\x49\xfb\x62\xbe\xd8\x22\xc1\xc5\xfe\xc3\xee\x0f\xbb\x60\x1f\x06\x5f\xee\xea\xf5\xe1\x83\x8c\x51\x3b\x4c\xc0\x1b\xf0\x4b\x84\xab\x4c\xc4\x4b\x84\x89\x99\xfb\x8d\xb0\x08\xef\x4c\xae\x13\xe1\xa5\x [...]
},
"/crd-kamelet.yaml": &vfsgen۰CompressedFileInfo{
name: "crd-kamelet.yaml",
diff --git a/e2e/yaks/kamelet-binding/display.groovy b/e2e/yaks/common/kamelet-binding/display.groovy
similarity index 100%
rename from e2e/yaks/kamelet-binding/display.groovy
rename to e2e/yaks/common/kamelet-binding/display.groovy
diff --git a/e2e/yaks/kamelet-binding/kamelet.feature b/e2e/yaks/common/kamelet-binding/kamelet.feature
similarity index 100%
rename from e2e/yaks/kamelet-binding/kamelet.feature
rename to e2e/yaks/common/kamelet-binding/kamelet.feature
diff --git a/e2e/yaks/kamelet-binding/logger-sink-binding.yaml b/e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/logger-sink-binding.yaml
rename to e2e/yaks/common/kamelet-binding/logger-sink-binding.yaml
diff --git a/e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml b/e2e/yaks/common/kamelet-binding/logger-sink.kamelet.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/logger-sink.kamelet.yaml
rename to e2e/yaks/common/kamelet-binding/logger-sink.kamelet.yaml
diff --git a/e2e/yaks/knative-sinkbinding/messages-channel.yaml b/e2e/yaks/common/kamelet-binding/messages-channel.yaml
similarity index 100%
rename from e2e/yaks/knative-sinkbinding/messages-channel.yaml
rename to e2e/yaks/common/kamelet-binding/messages-channel.yaml
diff --git a/e2e/yaks/kamelet-binding/timer-source-binding-display.yaml b/e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/timer-source-binding-display.yaml
rename to e2e/yaks/common/kamelet-binding/timer-source-binding-display.yaml
diff --git a/e2e/yaks/kamelet-binding/timer-source-binding.yaml b/e2e/yaks/common/kamelet-binding/timer-source-binding.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/timer-source-binding.yaml
rename to e2e/yaks/common/kamelet-binding/timer-source-binding.yaml
diff --git a/e2e/yaks/kamelet/timer-source.kamelet.yaml b/e2e/yaks/common/kamelet-binding/timer-source.kamelet.yaml
similarity index 100%
rename from e2e/yaks/kamelet/timer-source.kamelet.yaml
rename to e2e/yaks/common/kamelet-binding/timer-source.kamelet.yaml
diff --git a/e2e/yaks/kamelet-binding/yaks-config.yaml b/e2e/yaks/common/kamelet-binding/yaks-config.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/yaks-config.yaml
rename to e2e/yaks/common/kamelet-binding/yaks-config.yaml
diff --git a/e2e/yaks/kamelet/echo-sink.kamelet.yaml b/e2e/yaks/common/kamelet/echo-sink.kamelet.yaml
similarity index 100%
rename from e2e/yaks/kamelet/echo-sink.kamelet.yaml
rename to e2e/yaks/common/kamelet/echo-sink.kamelet.yaml
diff --git a/e2e/yaks/kamelet/kamelet.feature b/e2e/yaks/common/kamelet/kamelet.feature
similarity index 100%
rename from e2e/yaks/kamelet/kamelet.feature
rename to e2e/yaks/common/kamelet/kamelet.feature
diff --git a/e2e/yaks/kamelet/source-sink.groovy b/e2e/yaks/common/kamelet/source-sink.groovy
similarity index 100%
rename from e2e/yaks/kamelet/source-sink.groovy
rename to e2e/yaks/common/kamelet/source-sink.groovy
diff --git a/e2e/yaks/kamelet-binding/timer-source.kamelet.yaml b/e2e/yaks/common/kamelet/timer-source.kamelet.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/timer-source.kamelet.yaml
rename to e2e/yaks/common/kamelet/timer-source.kamelet.yaml
diff --git a/e2e/yaks/kamelet/yaks-config.yaml b/e2e/yaks/common/kamelet/yaks-config.yaml
similarity index 100%
rename from e2e/yaks/kamelet/yaks-config.yaml
rename to e2e/yaks/common/kamelet/yaks-config.yaml
diff --git a/e2e/yaks/kamelet-binding/messages-channel.yaml b/e2e/yaks/common/knative-sinkbinding/messages-channel.yaml
similarity index 100%
rename from e2e/yaks/kamelet-binding/messages-channel.yaml
rename to e2e/yaks/common/knative-sinkbinding/messages-channel.yaml
diff --git a/e2e/yaks/knative-sinkbinding/receiver.groovy b/e2e/yaks/common/knative-sinkbinding/receiver.groovy
similarity index 100%
rename from e2e/yaks/knative-sinkbinding/receiver.groovy
rename to e2e/yaks/common/knative-sinkbinding/receiver.groovy
diff --git a/e2e/yaks/knative-sinkbinding/sinkbinding.feature b/e2e/yaks/common/knative-sinkbinding/sinkbinding.feature
similarity index 100%
rename from e2e/yaks/knative-sinkbinding/sinkbinding.feature
rename to e2e/yaks/common/knative-sinkbinding/sinkbinding.feature
diff --git a/e2e/yaks/knative-sinkbinding/source.yaml b/e2e/yaks/common/knative-sinkbinding/source.yaml
similarity index 100%
rename from e2e/yaks/knative-sinkbinding/source.yaml
rename to e2e/yaks/common/knative-sinkbinding/source.yaml
diff --git a/e2e/yaks/knative-sinkbinding/yaks-config.yaml b/e2e/yaks/common/knative-sinkbinding/yaks-config.yaml
similarity index 100%
rename from e2e/yaks/knative-sinkbinding/yaks-config.yaml
rename to e2e/yaks/common/knative-sinkbinding/yaks-config.yaml
diff --git a/e2e/yaks/knative/receiver.groovy b/e2e/yaks/common/knative/receiver.groovy
similarity index 100%
rename from e2e/yaks/knative/receiver.groovy
rename to e2e/yaks/common/knative/receiver.groovy
diff --git a/e2e/yaks/knative/source.yaml b/e2e/yaks/common/knative/source.yaml
similarity index 100%
rename from e2e/yaks/knative/source.yaml
rename to e2e/yaks/common/knative/source.yaml
diff --git a/e2e/yaks/knative/sources.feature b/e2e/yaks/common/knative/sources.feature
similarity index 100%
rename from e2e/yaks/knative/sources.feature
rename to e2e/yaks/common/knative/sources.feature
diff --git a/e2e/yaks/knative/yaks-config.yaml b/e2e/yaks/common/knative/yaks-config.yaml
similarity index 100%
rename from e2e/yaks/knative/yaks-config.yaml
rename to e2e/yaks/common/knative/yaks-config.yaml
diff --git a/e2e/yaks/yaks-config.yaml b/e2e/yaks/common/yaks-config.yaml
similarity index 100%
copy from e2e/yaks/yaks-config.yaml
copy to e2e/yaks/common/yaks-config.yaml
diff --git a/e2e/yaks/monitoring/Metrics.java b/e2e/yaks/openshift/monitoring/Metrics.java
similarity index 100%
rename from e2e/yaks/monitoring/Metrics.java
rename to e2e/yaks/openshift/monitoring/Metrics.java
diff --git a/e2e/yaks/monitoring/app/pom.xml b/e2e/yaks/openshift/monitoring/app/pom.xml
similarity index 100%
rename from e2e/yaks/monitoring/app/pom.xml
rename to e2e/yaks/openshift/monitoring/app/pom.xml
diff --git a/e2e/yaks/monitoring/app/src/main/java/org/apache/camel/integration/Service.java b/e2e/yaks/openshift/monitoring/app/src/main/java/org/apache/camel/integration/Service.java
similarity index 100%
rename from e2e/yaks/monitoring/app/src/main/java/org/apache/camel/integration/Service.java
rename to e2e/yaks/openshift/monitoring/app/src/main/java/org/apache/camel/integration/Service.java
diff --git a/e2e/yaks/monitoring/metrics.feature b/e2e/yaks/openshift/monitoring/metrics.feature
similarity index 100%
rename from e2e/yaks/monitoring/metrics.feature
rename to e2e/yaks/openshift/monitoring/metrics.feature
diff --git a/e2e/yaks/monitoring/obtainToken.sh b/e2e/yaks/openshift/monitoring/obtainToken.sh
similarity index 100%
rename from e2e/yaks/monitoring/obtainToken.sh
rename to e2e/yaks/openshift/monitoring/obtainToken.sh
diff --git a/e2e/yaks/monitoring/yaks-config.yaml b/e2e/yaks/openshift/monitoring/yaks-config.yaml
similarity index 100%
rename from e2e/yaks/monitoring/yaks-config.yaml
rename to e2e/yaks/openshift/monitoring/yaks-config.yaml
diff --git a/e2e/yaks/yaks-config.yaml b/e2e/yaks/openshift/yaks-config.yaml
similarity index 100%
rename from e2e/yaks/yaks-config.yaml
rename to e2e/yaks/openshift/yaks-config.yaml