Repository: apache/camel-k
Pull request #1728 (2020-10-01 16:19:06)

[fix] Use correct name of kameletbinding
Fixes this error ```Error from server (NotFound): kameletbindings.camel.apache.org "timer-source" not found```

llowinge: @nicolaferraro 

Patch:
diff --git a/.github/workflows/automatic-changelog-update.yml b/.github/workflows/automatic-changelog-update.yml
index 314d7e370..2ed9c9dc2 100644
--- a/.github/workflows/automatic-changelog-update.yml
+++ b/.github/workflows/automatic-changelog-update.yml
@@ -26,6 +26,7 @@ jobs:
   generate_changelog:
     runs-on: ubuntu-latest
     name: Generate changelog for master branch
+    if: github.ref == 'refs/heads/master' && github.repository == 'apache/camel-k'
     steps:
       - uses: actions/checkout@v1
 
diff --git a/docs/modules/ROOT/pages/kamelets/kamelets.adoc b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
index 7b9bf17ef..f98756d29 100644
--- a/docs/modules/ROOT/pages/kamelets/kamelets.adoc
+++ b/docs/modules/ROOT/pages/kamelets/kamelets.adoc
@@ -248,7 +248,7 @@ In some contexts (for example **"serverless"**) users often want to leverage the
 doing additional processing (such as tranformations or other enterprise integration patterns).
 
 A common use case is that of **Knative Sources**, for which the Apache Camel developers maintain the https://knative.dev/docs/eventing/samples/apache-camel-source/[Knative CamelSources].
-Kamelets represent an **evolution** of the model proposed in CamelSources, but they allow using the same declarative style of binding, via a resource named **KameledBinding**.
+Kamelets represent an **evolution** of the model proposed in CamelSources, but they allow using the same declarative style of binding, via a resource named **KameletBinding**.
 
 A KameletBinding allows to declaratively move data from a system described by a Kamelet towards a Knative destination (or other kind of destinations, in the future), or from
 a Knative channel/broker to another external system described by a Kamelet.
diff --git a/pkg/apis/camel/v1/knative/types.go b/pkg/apis/camel/v1/knative/types.go
index 430c2239a..c4147d6a8 100644
--- a/pkg/apis/camel/v1/knative/types.go
+++ b/pkg/apis/camel/v1/knative/types.go
@@ -33,11 +33,14 @@ func NewCamelEnvironment() CamelEnvironment {
 
 // CamelServiceDefinition defines the parameters to connect to Knative service. It's also used for exposed services
 type CamelServiceDefinition struct {
-	ServiceType CamelServiceType  `json:"type"`
-	Name        string            `json:"name"`
-	Host        string            `json:"host,omitempty"`
-	Port        *int              `json:"port,omitempty"`
-	Metadata    map[string]string `json:"metadata,omitempty"`
+	ServiceType CamelServiceType `json:"type"`
+	Name        string           `json:"name"`
+	// Deprecated: use URL instead
+	Host string `json:"host,omitempty"`
+	// Deprecated: use URL instead
+	Port     *int              `json:"port,omitempty"`
+	URL      string            `json:"url,omitempty"`
+	Metadata map[string]string `json:"metadata,omitempty"`
 }
 
 // CamelEndpointKind --
@@ -73,11 +76,6 @@ func (s CamelServiceType) ResourceDescription(subject string) string {
 // Meta Options
 const (
 	CamelMetaServicePath = "service.path"
-	CamelMetaServiceID   = "service.id"
-	CamelMetaServiceName = "service.name"
-	CamelMetaServiceHost = "service.host"
-	CamelMetaServicePort = "service.port"
-	CamelMetaServiceZone = "service.zone"
 
 	CamelMetaKnativeKind       = "knative.kind"
 	CamelMetaKnativeAPIVersion = "knative.apiVersion"
diff --git a/pkg/apis/camel/v1/knative/types_support.go b/pkg/apis/camel/v1/knative/types_support.go
index 796b89d3b..f98677436 100644
--- a/pkg/apis/camel/v1/knative/types_support.go
+++ b/pkg/apis/camel/v1/knative/types_support.go
@@ -20,19 +20,15 @@ package knative
 import (
 	"encoding/json"
 	"net/url"
-	"strconv"
 )
 
 // BuildCamelServiceDefinition creates a CamelServiceDefinition from a given URL
 func BuildCamelServiceDefinition(name string, endpointKind CamelEndpointKind, serviceType CamelServiceType,
 	serviceURL url.URL, apiVersion, kind string) (CamelServiceDefinition, error) {
 
-	port := 80
-
 	definition := CamelServiceDefinition{
 		Name:        name,
-		Host:        serviceURL.Host,
-		Port:        &port,
+		URL:         serviceURL.String(),
 		ServiceType: serviceType,
 		Metadata: map[string]string{
 			CamelMetaEndpointKind:      string(endpointKind),
@@ -40,17 +36,6 @@ func BuildCamelServiceDefinition(name string, endpointKind CamelEndpointKind, se
 			CamelMetaKnativeKind:       kind,
 		},
 	}
-	portStr := serviceURL.Port()
-	if portStr != "" {
-		port, err := strconv.Atoi(portStr)
-		if err != nil {
-			return CamelServiceDefinition{}, err
-		}
-		definition.Port = &port
-	}
-	if serviceURL.Path != "" {
-		definition.Metadata[CamelMetaServicePath] = serviceURL.Path
-	}
 
 	return definition, nil
 }
diff --git a/pkg/trait/jolokia.go b/pkg/trait/jolokia.go
index 8363bbbf0..f48b8df41 100644
--- a/pkg/trait/jolokia.go
+++ b/pkg/trait/jolokia.go
@@ -85,9 +85,20 @@ func (t *jolokiaTrait) Configure(e *Environment) (bool, error) {
 func (t *jolokiaTrait) Apply(e *Environment) (err error) {
 	if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
 		// Add the Camel management and Jolokia agent dependencies
-		util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel/camel-management")
+		// Also add the Camel JAXB dependency, that's required by Hawtio
+
+		switch e.CamelCatalog.Runtime.Provider {
+		case v1.RuntimeProviderQuarkus:
+			util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel.quarkus/camel-quarkus-management")
+			util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "camel-quarkus:jaxb")
+		case v1.RuntimeProviderMain:
+			util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.apache.camel/camel-management")
+			util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "camel:jaxb")
+		}
+
 		// TODO: We may want to make the Jolokia version configurable
 		util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "mvn:org.jolokia/jolokia-jvm:jar:agent:1.6.2")
+
 		return nil
 	}
 
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 5ff9c46cd..ed41b6b62 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -21,15 +21,16 @@ import (
 	"fmt"
 	"net/url"
 	"reflect"
+	"strconv"
 	"strings"
 
-	"github.com/apache/camel-k/pkg/util/kubernetes"
 	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 	knativeapi "github.com/apache/camel-k/pkg/apis/camel/v1/knative"
 	"github.com/apache/camel-k/pkg/metadata"
 	"github.com/apache/camel-k/pkg/util"
 	"github.com/apache/camel-k/pkg/util/envvar"
 	knativeutil "github.com/apache/camel-k/pkg/util/knative"
+	"github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/pkg/errors"
 	corev1 "k8s.io/api/core/v1"
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
@@ -243,6 +244,21 @@ func (t *knativeTrait) Apply(e *Environment) error {
 			}
 		}
 
+		// Convert deprecated Host and Port fields to URL field
+		// Can be removed once CamelSource controller migrate to the new API
+		for i, service := range env.Services {
+			if service.URL == "" {
+				URL := "http://" + service.Host
+				if service.Port != nil {
+					URL = URL + ":" + strconv.Itoa(*service.Port)
+				}
+				service.URL = URL
+				service.Host = ""
+				service.Port = nil
+				env.Services[i] = service
+			}
+		}
+
 		if err := t.configureChannels(e, &env); err != nil {
 			return err
 		}


Test patch:
diff --git a/e2e/yaks/kamelets/yaks-config.yaml b/e2e/yaks/kamelets/yaks-config.yaml
index 40f19ba21..8679b79cf 100644
--- a/e2e/yaks/kamelets/yaks-config.yaml
+++ b/e2e/yaks/kamelets/yaks-config.yaml
@@ -29,7 +29,7 @@ pre:
     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 --for=condition=Ready --timeout=10m -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/monitoring/metrics.feature b/e2e/yaks/monitoring/metrics.feature
index 4c6cf18da..451f0ccad 100644
--- a/e2e/yaks/monitoring/metrics.feature
+++ b/e2e/yaks/monitoring/metrics.feature
@@ -6,7 +6,7 @@ Feature: Camel K can serve metrics to Prometheus
   Scenario: Integration gets the message from the timer
     Given integration metrics is running
     Then integration metrics should print Successfully processed
-    Then sleep 10000 ms
+    Then sleep 120000 ms
 
   Scenario: Thanos is able to serve custom microprofile annotation metrics
     Given HTTP request header Authorization is "Bearer TOKEN"
diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go
index 63586c95a..6bea95333 100644
--- a/pkg/trait/knative_test.go
+++ b/pkg/trait/knative_test.go
@@ -123,28 +123,28 @@ func TestKnativeEnvConfigurationFromTrait(t *testing.T) {
 
 	cSource1 := ne.FindService("channel-source-1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeChannel, "messaging.knative.dev/v1beta1", "Channel")
 	assert.NotNil(t, cSource1)
-	assert.Empty(t, cSource1.Host)
+	assert.Empty(t, cSource1.URL)
 
 	cSink1 := ne.FindService("channel-sink-1", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeChannel, "messaging.knative.dev/v1beta1", "Channel")
 	assert.NotNil(t, cSink1)
-	assert.Equal(t, "channel-sink-1.host", cSink1.Host)
+	assert.Equal(t, "http://channel-sink-1.host/", cSink1.URL)
 
 	eSource1 := ne.FindService("endpoint-source-1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
 	assert.NotNil(t, eSource1)
-	assert.Empty(t, eSource1.Host)
+	assert.Empty(t, eSource1.URL)
 
 	eSink1 := ne.FindService("endpoint-sink-1", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
 	assert.NotNil(t, eSink1)
-	assert.Equal(t, "endpoint-sink-1.host", eSink1.Host)
+	assert.Equal(t, "http://endpoint-sink-1.host/", eSink1.URL)
 	eSink2 := ne.FindService("endpoint-sink-2", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
 	assert.NotNil(t, eSink2)
-	assert.Equal(t, "endpoint-sink-2.host", eSink2.Host)
+	assert.Equal(t, "http://endpoint-sink-2.host/", eSink2.URL)
 
 	eEventSource := ne.FindService("default", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEvent, "eventing.knative.dev/v1beta1", "Broker")
 	assert.NotNil(t, eEventSource)
 	eEventSink := ne.FindService("default", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEvent, "eventing.knative.dev/v1beta1", "Broker")
 	assert.NotNil(t, eEventSink)
-	assert.Equal(t, "broker-default.host", eEventSink.Host)
+	assert.Equal(t, "http://broker-default.host/", eEventSink.URL)
 }
 
 func TestKnativeEnvConfigurationFromSource(t *testing.T) {
@@ -243,8 +243,7 @@ func TestKnativeEnvConfigurationFromSource(t *testing.T) {
 
 	source := ne.FindService("s3fileMover1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
 	assert.NotNil(t, source)
-	assert.Empty(t, source.Host)
-	assert.Nil(t, source.Port)
+	assert.Empty(t, source.URL)
 	assert.Empty(t, source.Metadata[knativeapi.CamelMetaKnativeReply])
 
 	channel := ne.FindService("channel-source-1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeChannel, "", "")