Repository: apache/camel-k
Pull request #1985 (2021-02-02 10:52:24)

fix(OLM): Add missing internal-objects annotation to Kustomize base CSV manifest
**Release Note**
```release-note
fix(OLM): Add missing internal-objects annotation to Kustomize base CSV manifest
```



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fa7fab630..72e8a5265 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,15 @@
 
 **Closed issues:**
 
+- Cannot use special characters in KameletBindings [\#1986](https://github.com/apache/camel-k/issues/1986)
 - Make changelog action work again [\#1981](https://github.com/apache/camel-k/issues/1981)
 - Add a Backport Github action  [\#1969](https://github.com/apache/camel-k/issues/1969)
+- Release 1.3.0 [\#1867](https://github.com/apache/camel-k/issues/1867)
 
 **Merged pull requests:**
 
+- Fix a little typo good for testing backport action [\#1989](https://github.com/apache/camel-k/pull/1989) ([oscerd](https://github.com/oscerd))
+- Fix \#1986: use properties instead of URL encoding for Kamelets in bin… [\#1987](https://github.com/apache/camel-k/pull/1987) ([nicolaferraro](https://github.com/nicolaferraro))
 - Re-introduce changelog action [\#1982](https://github.com/apache/camel-k/pull/1982) ([oscerd](https://github.com/oscerd))
 - fix\(OLM\): OLM bundle generation fixes [\#1977](https://github.com/apache/camel-k/pull/1977) ([astefanutti](https://github.com/astefanutti))
 - Backport action: Added license [\#1975](https://github.com/apache/camel-k/pull/1975) ([oscerd](https://github.com/oscerd))
@@ -1522,6 +1526,7 @@
 - knative: create full camel environment [\#571](https://github.com/apache/camel-k/pull/571) ([lburgazzoli](https://github.com/lburgazzoli))
 - dependencies: add support for boms [\#565](https://github.com/apache/camel-k/pull/565) ([lburgazzoli](https://github.com/lburgazzoli))
 - Upgrade Operator SDK to version 0.6.0 [\#562](https://github.com/apache/camel-k/pull/562) ([astefanutti](https://github.com/astefanutti))
+- knative: fix copy secrets to env vars [\#555](https://github.com/apache/camel-k/pull/555) ([lburgazzoli](https://github.com/lburgazzoli))
 
 ## [0.3.1](https://github.com/apache/camel-k/tree/0.3.1) (2019-03-15)
 
@@ -1542,7 +1547,6 @@
 
 - Fix \#557: fix generated images [\#560](https://github.com/apache/camel-k/pull/560) ([nicolaferraro](https://github.com/nicolaferraro))
 - chore\(maven\): Run Maven in batch mode to reduce log noise [\#556](https://github.com/apache/camel-k/pull/556) ([jamesnetherton](https://github.com/jamesnetherton))
-- knative: fix copy secrets to env vars [\#555](https://github.com/apache/camel-k/pull/555) ([lburgazzoli](https://github.com/lburgazzoli))
 - resources: add options to configure mount path and key [\#554](https://github.com/apache/camel-k/pull/554) ([lburgazzoli](https://github.com/lburgazzoli))
 - Timeout in S2I build [\#551](https://github.com/apache/camel-k/pull/551) ([lburgazzoli](https://github.com/lburgazzoli))
 - fix: Improve how SanitizeName handles paths and URLs [\#549](https://github.com/apache/camel-k/pull/549) ([jamesnetherton](https://github.com/jamesnetherton))
@@ -1615,6 +1619,7 @@
 - Aligned the submodule runtime from camel-k-runtime [\#476](https://github.com/apache/camel-k/pull/476) ([oscerd](https://github.com/oscerd))
 - Removed JenkinsFile since it used by the runtime repo now [\#475](https://github.com/apache/camel-k/pull/475) ([oscerd](https://github.com/oscerd))
 - Fixes \#470 [\#474](https://github.com/apache/camel-k/pull/474) ([oscerd](https://github.com/oscerd))
+- fix\(traints\): ensure an error is returned to the caller if a catalog cannot be found [\#472](https://github.com/apache/camel-k/pull/472) ([lburgazzoli](https://github.com/lburgazzoli))
 - Remove unecessary Go dep overrides [\#467](https://github.com/apache/camel-k/pull/467) ([astefanutti](https://github.com/astefanutti))
 - fix\(semver\): support exact version match when looking up camel catalog [\#465](https://github.com/apache/camel-k/pull/465) ([lburgazzoli](https://github.com/lburgazzoli))
 - Fix lint errors [\#464](https://github.com/apache/camel-k/pull/464) ([astefanutti](https://github.com/astefanutti))
@@ -1653,7 +1658,6 @@
 
 **Merged pull requests:**
 
-- fix\(traints\): ensure an error is returned to the caller if a catalog cannot be found [\#472](https://github.com/apache/camel-k/pull/472) ([lburgazzoli](https://github.com/lburgazzoli))
 - Added a FailIfNoTests option to Surefire [\#457](https://github.com/apache/camel-k/pull/457) ([oscerd](https://github.com/oscerd))
 - Enable status subresource for integration context [\#456](https://github.com/apache/camel-k/pull/456) ([astefanutti](https://github.com/astefanutti))
 - Enable status subresource for integration platform [\#455](https://github.com/apache/camel-k/pull/455) ([astefanutti](https://github.com/astefanutti))
diff --git a/README.adoc b/README.adoc
index 5b570e366..a15f4cbe9 100644
--- a/README.adoc
+++ b/README.adoc
@@ -101,7 +101,7 @@ camel-k-groovy-builder   0/1   Completed   0     75s
 ...
 ```
 
-After a couple of minutes you can see your integration runnning. To see the output log of your integration container get the pod id:
+After a couple of minutes you can see your integration running. To see the output log of your integration container get the pod id:
 
 ```
 kubectl get pods | grep sample
diff --git a/config/manifests/bases/camel-k.clusterserviceversion.yaml b/config/manifests/bases/camel-k.clusterserviceversion.yaml
index 0f2fb6b60..999a943fd 100644
--- a/config/manifests/bases/camel-k.clusterserviceversion.yaml
+++ b/config/manifests/bases/camel-k.clusterserviceversion.yaml
@@ -24,6 +24,7 @@ metadata:
     certified: "false"
     description: Apache Camel K is a lightweight integration platform, born on Kubernetes, with serverless superpowers.
     operators.operatorframework.io/builder: operator-sdk-v1.0.1
+    operators.operatorframework.io/internal-objects: '["builds.camel.apache.org","integrationkits.camel.apache.org","camelcatalogs.camel.apache.org"]'
     operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
     support: Camel
   name: camel-k.v1.3.0
diff --git a/pkg/controller/kameletbinding/common.go b/pkg/controller/kameletbinding/common.go
index a50b2023f..1fc8dc67b 100644
--- a/pkg/controller/kameletbinding/common.go
+++ b/pkg/controller/kameletbinding/common.go
@@ -20,6 +20,8 @@ package kameletbinding
 import (
 	"context"
 	"encoding/json"
+	"fmt"
+	"sort"
 
 	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
@@ -90,6 +92,23 @@ func createIntegrationFor(ctx context.Context, c client.Client, kameletbinding *
 		}
 	}
 
+	if len(from.ApplicationProperties) > 0 || len(to.ApplicationProperties) > 0 {
+		propList := make([]string, 0, len(from.ApplicationProperties)+len(to.ApplicationProperties))
+		for k, v := range from.ApplicationProperties {
+			propList = append(propList, fmt.Sprintf("%s=%s", k, v))
+		}
+		for k, v := range to.ApplicationProperties {
+			propList = append(propList, fmt.Sprintf("%s=%s", k, v))
+		}
+		sort.Strings(propList)
+		for _, p := range propList {
+			it.Spec.Configuration = append(it.Spec.Configuration, v1.ConfigurationSpec{
+				Type:  "property",
+				Value: p,
+			})
+		}
+	}
+
 	flow := map[string]interface{}{
 		"from": map[string]interface{}{
 			"uri": from.URI,
diff --git a/pkg/util/bindings/api.go b/pkg/util/bindings/api.go
index 05ea12328..f5debd3ae 100644
--- a/pkg/util/bindings/api.go
+++ b/pkg/util/bindings/api.go
@@ -38,6 +38,8 @@ type Binding struct {
 	URI string
 	// Traits is a partial trait specification that should be merged into the integration
 	Traits map[string]v1.TraitSpec
+	// ApplicationProperties contain properties that should be set on the integration for the binding to work
+	ApplicationProperties map[string]string
 }
 
 // BindingProvider maps a KameletBinding endpoint into Camel K resources
diff --git a/pkg/util/bindings/kamelet.go b/pkg/util/bindings/kamelet.go
index 089a7d4db..ca832520a 100644
--- a/pkg/util/bindings/kamelet.go
+++ b/pkg/util/bindings/kamelet.go
@@ -22,7 +22,6 @@ import (
 	"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"
 )
 
@@ -44,22 +43,35 @@ func (k KameletBindingProvider) Translate(ctx BindingContext, endpointType v1alp
 	}
 	// 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))
+		kameletName := url.PathEscape(e.Ref.Name)
+		kameletURI := fmt.Sprintf("kamelet:%s", kameletName)
 
 		props, err := e.Properties.GetPropertyMap()
 		if err != nil {
 			return nil, err
 		}
 
-		if id, ok := props[v1alpha1.KameletIDProperty]; ok && id != "" {
+		id, idPresent := props[v1alpha1.KameletIDProperty]
+		if idPresent {
 			delete(props, v1alpha1.KameletIDProperty)
-			kameletURI = fmt.Sprintf("%s/%s", kameletURI, url.PathEscape(id))
+		} else {
+			// Let's use literal "source" or "sink" as ID for the Kamelet
+			id = string(endpointType)
 		}
+		kameletURI = fmt.Sprintf("%s/%s", kameletURI, url.PathEscape(id))
 
-		kameletURI = uri.AppendParameters(kameletURI, props)
+		var applicationProperties map[string]string
+		if len(props) > 0 {
+			applicationProperties = make(map[string]string, len(props))
+			for k, v := range props {
+				propKey := fmt.Sprintf("camel.kamelet.%s.%s.%s", kameletName, id, k)
+				applicationProperties[propKey] = v
+			}
+		}
 
 		return &Binding{
-			URI: kameletURI,
+			URI:                   kameletURI,
+			ApplicationProperties: applicationProperties,
 		}, nil
 	}
 	return nil, nil
diff --git a/script/gen_release_notes.sh b/script/gen_release_notes.sh
index 4caea9fed..070e08d5b 100755
--- a/script/gen_release_notes.sh
+++ b/script/gen_release_notes.sh
@@ -23,8 +23,8 @@ if [ "$#" -ne 2 ]; then
 fi
 
 location=$(dirname $0)
-last_tag=$1
-new_tag=$2
+last_tag=v$1
+new_tag=v$2
 
 echo "Generating release notes for version $new_tag starting from tag $last_tag"
 


Test patch:
diff --git a/pkg/util/bindings/bindings_test.go b/pkg/util/bindings/bindings_test.go
index 55d005fc1..084309aa6 100644
--- a/pkg/util/bindings/bindings_test.go
+++ b/pkg/util/bindings/bindings_test.go
@@ -39,6 +39,7 @@ func TestBindings(t *testing.T) {
 		profile      camelv1.TraitProfile
 		uri          string
 		traits       map[string]camelv1.TraitSpec
+		props        map[string]string
 	}{
 		{
 			endpointType: v1alpha1.EndpointTypeSink,
@@ -113,6 +114,7 @@ func TestBindings(t *testing.T) {
 			uri: "knative:event/myeventtype?apiVersion=eventing.knative.dev%2Fv1beta1&kind=Broker",
 		},
 		{
+			endpointType: v1alpha1.EndpointTypeSource,
 			endpoint: v1alpha1.Endpoint{
 				Ref: &corev1.ObjectReference{
 					Kind:       "Kamelet",
@@ -120,9 +122,10 @@ func TestBindings(t *testing.T) {
 					Name:       "mykamelet",
 				},
 			},
-			uri: "kamelet:mykamelet",
+			uri: "kamelet:mykamelet/source",
 		},
 		{
+			endpointType: v1alpha1.EndpointTypeSink,
 			endpoint: v1alpha1.Endpoint{
 				Ref: &corev1.ObjectReference{
 					Kind:       "Kamelet",
@@ -134,7 +137,11 @@ func TestBindings(t *testing.T) {
 					"encodedkey?": "encoded=val",
 				}),
 			},
-			uri: "kamelet:mykamelet?encodedkey%3F=encoded%3Dval&mymessage=myval",
+			uri: "kamelet:mykamelet/sink",
+			props: map[string]string{
+				"camel.kamelet.mykamelet.sink.encodedkey?": "encoded=val",
+				"camel.kamelet.mykamelet.sink.mymessage":   "myval",
+			},
 		},
 		{
 			endpoint: v1alpha1.Endpoint{
@@ -148,7 +155,10 @@ func TestBindings(t *testing.T) {
 					"mymessage": "myval",
 				}),
 			},
-			uri: "kamelet:mykamelet/myid%3F?mymessage=myval",
+			uri: "kamelet:mykamelet/myid%3F",
+			props: map[string]string{
+				"camel.kamelet.mykamelet.myid?.mymessage": "myval",
+			},
 		},
 		{
 			endpointType: v1alpha1.EndpointTypeSink,
@@ -206,6 +216,7 @@ func TestBindings(t *testing.T) {
 			assert.NotNil(t, binding)
 			assert.Equal(t, tc.uri, binding.URI)
 			assert.Equal(t, tc.traits, binding.Traits)
+			assert.Equal(t, tc.props, binding.ApplicationProperties)
 		})
 	}
 }