This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new edf6305 fix(knative): Use channel hostname to filter Knative history
header
edf6305 is described below
commit edf6305259970b0f212ff1bd87d768d51741bf2f
Author: Antonin Stefanutti <[email protected]>
AuthorDate: Thu Sep 12 17:36:40 2019 +0200
fix(knative): Use channel hostname to filter Knative history header
---
pkg/trait/knative.go | 14 +++++++++++---
pkg/trait/knative_test.go | 15 +++++++++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 619cb32..3246138 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -109,7 +109,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool,
error) {
}
if len(strings.Split(t.ChannelSources, ",")) > 1 {
// Always filter channels when the integration
subscribes to more than one
- // Using Knative experimental header:
https://github.com/knative/eventing/blob/master/pkg/provisioners/message.go#L28
+ // Using Knative experimental header:
https://github.com/knative/eventing/blob/7df0cc56c28d58223ff25d5ddfb487fa8c29a004/pkg/provisioners/message.go#L28
// TODO: filter automatically all source channels when
the feature becomes stable
filter := true
t.FilterSourceChannels = &filter
@@ -182,13 +182,21 @@ func (t *knativeTrait) configureChannels(e *Environment,
env *knativeapi.CamelEn
if env.ContainsService(ch, knativeapi.CamelServiceTypeChannel) {
continue
}
+
+ c, err := knativeutil.GetChannel(t.ctx, t.client,
e.Integration.Namespace, ch)
+ if err != nil {
+ return err
+ }
+ if c == nil {
+ return errors.Errorf("cannot find channel %s", ch)
+ }
+
meta := map[string]string{
knativeapi.CamelMetaServicePath: "/",
}
if t.FilterSourceChannels != nil && *t.FilterSourceChannels {
- fullName := ch + "." + e.Integration.Namespace +
".channels.cluster.local"
meta[knativeapi.CamelMetaFilterHeaderName] =
knativeHistoryHeader
- meta[knativeapi.CamelMetaFilterHeaderValue] = fullName
+ meta[knativeapi.CamelMetaFilterHeaderValue] =
c.Status.Address.Hostname
}
svc := knativeapi.CamelServiceDefinition{
Name: ch,
diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go
index 82e3500..3611298 100644
--- a/pkg/trait/knative_test.go
+++ b/pkg/trait/knative_test.go
@@ -245,6 +245,21 @@ func NewFakeClient(namespace string) (client.Client,
error) {
},
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
+ Name: "channel-source-1",
+ },
+ Status: eventing.ChannelStatus{
+ Address: duckv1alpha1.Addressable{
+ Hostname: "channel-source-1.host",
+ },
+ },
+ },
+ &eventing.Channel{
+ TypeMeta: metav1.TypeMeta{
+ Kind: "Channel",
+ APIVersion:
eventing.SchemeGroupVersion.String(),
+ },
+ ObjectMeta: metav1.ObjectMeta{
+ Namespace: namespace,
Name: "channel-sink-1",
},
Status: eventing.ChannelStatus{