camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nferr...@apache.org
Subject [camel-k] branch master updated: Fix #1414: upgrade to knative 0.14 and support v1beta1 channels and broker
Date Thu, 30 Apr 2020 09:59:06 GMT
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


The following commit(s) were added to refs/heads/master by this push:
     new 25d6122  Fix #1414: upgrade to knative 0.14 and support v1beta1 channels and broker
25d6122 is described below

commit 25d61221b1517208bbd9d51581e5a95eaa2a30c8
Author: Nicola Ferraro <ni.ferraro@gmail.com>
AuthorDate: Wed Apr 29 14:52:49 2020 +0200

    Fix #1414: upgrade to knative 0.14 and support v1beta1 channels and broker
---
 cmd/util/doc-gen/generators/traitmetadatagen.go |  6 ++----
 e2e/knative/knative_test.go                     | 20 +++++++++++++++++---
 e2e/support/test_support.go                     | 25 +++++++++++++++++++++----
 go.mod                                          | 10 ++++------
 go.sum                                          |  7 +++++++
 pkg/apis/addtoscheme_knative_eventing.go        | 12 ++++++++----
 pkg/cmd/trait_help.go                           |  1 +
 pkg/trait/knative_test.go                       |  2 +-
 pkg/util/knative/apis.go                        | 24 ++++++++++++++++++++++++
 pkg/util/knative/apis_test.go                   |  8 ++++----
 pkg/util/knative/knative.go                     |  4 ++--
 11 files changed, 91 insertions(+), 28 deletions(-)

diff --git a/cmd/util/doc-gen/generators/traitmetadatagen.go b/cmd/util/doc-gen/generators/traitmetadatagen.go
index d1b48a0..ac39845 100644
--- a/cmd/util/doc-gen/generators/traitmetadatagen.go
+++ b/cmd/util/doc-gen/generators/traitmetadatagen.go
@@ -19,13 +19,13 @@ package generators
 
 import (
 	"fmt"
-	"gopkg.in/yaml.v2"
 	"io"
 	"os"
 	"path"
 	"reflect"
 	"strings"
 
+	"gopkg.in/yaml.v2"
 	"k8s.io/gengo/args"
 	"k8s.io/gengo/generator"
 	"k8s.io/gengo/types"
@@ -152,9 +152,7 @@ func (g *traitMetaDataGen) buildMembers(t *types.Type, content *[]string,
td *tr
 				pd.Name = prop
 				pd.TypeName = strings.TrimPrefix(m.Type.Name.Name, "*")
 
-				for _, line := range filterOutTagsAndComments(m.CommentLines) {
-					res = append(res, line)
-				}
+				res = append(res, filterOutTagsAndComments(m.CommentLines)...)
 				pd.Description = strings.Join(res, "")
 				td.Properties = append(td.Properties, pd)
 			}
diff --git a/e2e/knative/knative_test.go b/e2e/knative/knative_test.go
index c8e79dc..20a996d 100644
--- a/e2e/knative/knative_test.go
+++ b/e2e/knative/knative_test.go
@@ -51,10 +51,24 @@ func TestRunServiceCombo(t *testing.T) {
 	})
 }
 
-func TestRunChannelCombo(t *testing.T) {
+func TestRunChannelComboV1Alpha1(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
 
-		Expect(CreateKnativeChannel(ns, "messages")()).Should(BeNil())
+		Expect(CreateKnativeChannelv1Alpha1(ns, "messages")()).Should(BeNil())
+		Expect(Kamel("install", "-n", ns, "--trait-profile", "knative").Execute()).Should(BeNil())
+		Expect(Kamel("run", "-n", ns, "files/knativech2.groovy").Execute()).Should(BeNil())
+		Expect(Kamel("run", "-n", ns, "files/knativech1.groovy").Execute()).Should(BeNil())
+		Eventually(IntegrationPodPhase(ns, "knativech2"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+		Eventually(IntegrationPodPhase(ns, "knativech1"), TestTimeoutLong).Should(Equal(v1.PodRunning))
+		Eventually(IntegrationLogs(ns, "knativech2"), TestTimeoutMedium).Should(ContainSubstring("Received:
Hello from knativech1"))
+		Expect(Kamel("delete", "--all", "-n", ns).Execute()).Should(BeNil())
+	})
+}
+
+func TestRunChannelComboV1Beta1(t *testing.T) {
+	WithNewTestNamespace(t, func(ns string) {
+
+		Expect(CreateKnativeChannelv1Beta1(ns, "messages")()).Should(BeNil())
 		Expect(Kamel("install", "-n", ns, "--trait-profile", "knative").Execute()).Should(BeNil())
 		Expect(Kamel("run", "-n", ns, "files/knativech2.groovy").Execute()).Should(BeNil())
 		Expect(Kamel("run", "-n", ns, "files/knativech1.groovy").Execute()).Should(BeNil())
@@ -68,7 +82,7 @@ func TestRunChannelCombo(t *testing.T) {
 func TestRunChannelComboGetToPost(t *testing.T) {
 	WithNewTestNamespace(t, func(ns string) {
 
-		Expect(CreateKnativeChannel(ns, "messages")()).Should(BeNil())
+		Expect(CreateKnativeChannelv1Beta1(ns, "messages")()).Should(BeNil())
 		Expect(Kamel("install", "-n", ns, "--trait-profile", "knative").Execute()).Should(BeNil())
 		Expect(Kamel("run", "-n", ns, "files/knativegetpost2.groovy").Execute()).Should(BeNil())
 		Expect(Kamel("run", "-n", ns, "files/knativegetpost1.groovy").Execute()).Should(BeNil())
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index c622164..3a21b74 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -58,7 +58,8 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	eventing "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
-	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
+	messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
+	messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1"
 	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 
 	// let's enable addons in all tests
@@ -864,12 +865,28 @@ func CreateKamelPod(ns string, name string, command ...string) error
{
 	Knative
 */
 
-func CreateKnativeChannel(ns string, name string) func() error {
+func CreateKnativeChannelv1Alpha1(ns string, name string) func() error {
 	return func() error {
-		channel := messaging.InMemoryChannel{
+		channel := messagingv1alpha1.InMemoryChannel{
 			TypeMeta: metav1.TypeMeta{
 				Kind:       "InMemoryChannel",
-				APIVersion: messaging.SchemeGroupVersion.String(),
+				APIVersion: messagingv1alpha1.SchemeGroupVersion.String(),
+			},
+			ObjectMeta: metav1.ObjectMeta{
+				Namespace: ns,
+				Name:      name,
+			},
+		}
+		return TestClient.Create(TestContext, &channel)
+	}
+}
+
+func CreateKnativeChannelv1Beta1(ns string, name string) func() error {
+	return func() error {
+		channel := messagingv1beta1.InMemoryChannel{
+			TypeMeta: metav1.TypeMeta{
+				Kind:       "InMemoryChannel",
+				APIVersion: messagingv1beta1.SchemeGroupVersion.String(),
 			},
 			ObjectMeta: metav1.ObjectMeta{
 				Namespace: ns,
diff --git a/go.mod b/go.mod
index b042de0..7790d36 100644
--- a/go.mod
+++ b/go.mod
@@ -5,8 +5,6 @@ go 1.13
 require (
 	contrib.go.opencensus.io/exporter/ocagent v0.6.0 // indirect
 	contrib.go.opencensus.io/exporter/prometheus v0.1.0 // indirect
-	// required by knative 0.12
-	contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff // indirect
 	github.com/Masterminds/semver v1.5.0
 	github.com/container-tools/spectrum v0.3.2
 	github.com/coreos/prometheus-operator v0.34.0
@@ -42,14 +40,14 @@ require (
 	k8s.io/apimachinery v0.17.4
 	k8s.io/client-go v12.0.0+incompatible
 	k8s.io/gengo v0.0.0-20191010091904-7fa3014cb28f
-	knative.dev/eventing v0.12.0
-	knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f
-	knative.dev/serving v0.12.1
+	knative.dev/eventing v0.14.1
+	knative.dev/pkg v0.0.0-20200410152005-2a1db869228c
+	knative.dev/serving v0.14.0
 	sigs.k8s.io/controller-runtime v0.4.0
 )
 
 // Pinned to kubernetes 1.16.2:
-// - Knative 0.12.0 requires 1.16.4
+// - Knative 0.14.0 requires 1.16.4
 // - Operator SDK 0.15.0 requires 1.16.2
 replace (
 	k8s.io/api => k8s.io/api v0.0.0-20191016110408-35e52d86657a
diff --git a/go.sum b/go.sum
index d5fdd68..93a0e15 100644
--- a/go.sum
+++ b/go.sum
@@ -1127,10 +1127,17 @@ k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 h1:Gi+/O1saihwDqnlmC8Vhv1M5Sp4+r
 k8s.io/utils v0.0.0-20191010214722-8d271d903fe4/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
 knative.dev/eventing v0.12.0 h1:u3Ck5+dpr2affDlsGfRKnBTb87Is/tfzWNfZz1FSAMI=
 knative.dev/eventing v0.12.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
+knative.dev/eventing v0.13.8/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
+knative.dev/eventing v0.14.1 h1:YmnEl3IBVRkBcVYWPMWZegRGifeI7ibcA9xuhHWvAaw=
+knative.dev/eventing v0.14.1/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
 knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f h1:EFhlUkg97lfwyAxsNZUqbmHxVzQ0YpPdNyf/o16WkAw=
 knative.dev/pkg v0.0.0-20200113182502-b8dc5fbc6d2f/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
+knative.dev/pkg v0.0.0-20200410152005-2a1db869228c h1:+Ob3pOC0WuNFxKv2UdMGkC0FGSbWC24FvJleJ8+Lp1A=
+knative.dev/pkg v0.0.0-20200410152005-2a1db869228c/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
 knative.dev/serving v0.12.1 h1:ZL5pJ5rZq7vNGuhBlG2hU7dp9WnTJLlv2WfwoP9crQk=
 knative.dev/serving v0.12.1/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
+knative.dev/serving v0.14.0 h1:9iDyOqTciNuAh2D5KJP0soOq23FDR4HQHdIQNBQ/rAE=
+knative.dev/serving v0.14.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
 modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
 modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
 modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
diff --git a/pkg/apis/addtoscheme_knative_eventing.go b/pkg/apis/addtoscheme_knative_eventing.go
index 222e639..ef0486b 100644
--- a/pkg/apis/addtoscheme_knative_eventing.go
+++ b/pkg/apis/addtoscheme_knative_eventing.go
@@ -18,12 +18,16 @@ limitations under the License.
 package apis
 
 import (
-	eventing "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
-	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
+	eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
+	eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1"
+	messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
+	messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1"
 )
 
 func init() {
 	// Register the types with the Scheme so the components can map objects to GroupVersionKinds
and back
-	AddToSchemes = append(AddToSchemes, eventing.AddToScheme)
-	AddToSchemes = append(AddToSchemes, messaging.AddToScheme)
+	AddToSchemes = append(AddToSchemes, eventingv1alpha1.AddToScheme)
+	AddToSchemes = append(AddToSchemes, eventingv1beta1.AddToScheme)
+	AddToSchemes = append(AddToSchemes, messagingv1alpha1.AddToScheme)
+	AddToSchemes = append(AddToSchemes, messagingv1beta1.AddToScheme)
 }
diff --git a/pkg/cmd/trait_help.go b/pkg/cmd/trait_help.go
index 1df82e1..0e2143d 100644
--- a/pkg/cmd/trait_help.go
+++ b/pkg/cmd/trait_help.go
@@ -131,6 +131,7 @@ func (command *traitHelpCommandOptions) run(cmd *cobra.Command, args []string)
e
 
 				var targetTrait *traitDescription
 				for _, item := range traitMetaData.Traits {
+					item := item
 					if item.Name == t.ID() {
 						targetTrait = &item
 						td.Description = item.Description
diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go
index 941e557..0ef90b0 100644
--- a/pkg/trait/knative_test.go
+++ b/pkg/trait/knative_test.go
@@ -521,7 +521,7 @@ func NewFakeClient(namespace string) (client.Client, error) {
 				},
 				Broker: "default",
 				Subscriber: duckv1.Destination{
-					Ref: &corev1.ObjectReference{
+					Ref: &duckv1.KReference{
 						APIVersion: serving.SchemeGroupVersion.String(),
 						Kind:       "Service",
 						Name:       "event-source-1",
diff --git a/pkg/util/knative/apis.go b/pkg/util/knative/apis.go
index c5374ed..fbe26ce 100644
--- a/pkg/util/knative/apis.go
+++ b/pkg/util/knative/apis.go
@@ -31,6 +31,14 @@ var (
 			GroupVersionKind: schema.GroupVersionKind{
 				Kind:    "Channel",
 				Group:   "messaging.knative.dev",
+				Version: "v1beta1",
+			},
+			Resource: "channels",
+		},
+		{
+			GroupVersionKind: schema.GroupVersionKind{
+				Kind:    "Channel",
+				Group:   "messaging.knative.dev",
 				Version: "v1alpha1",
 			},
 			Resource: "channels",
@@ -47,6 +55,14 @@ var (
 			GroupVersionKind: schema.GroupVersionKind{
 				Kind:    "InMemoryChannel",
 				Group:   "messaging.knative.dev",
+				Version: "v1beta1",
+			},
+			Resource: "inmemorychannels",
+		},
+		{
+			GroupVersionKind: schema.GroupVersionKind{
+				Kind:    "InMemoryChannel",
+				Group:   "messaging.knative.dev",
 				Version: "v1alpha1",
 			},
 			Resource: "inmemorychannels",
@@ -103,6 +119,14 @@ var (
 			GroupVersionKind: schema.GroupVersionKind{
 				Kind:    "Broker",
 				Group:   "eventing.knative.dev",
+				Version: "v1beta1",
+			},
+			Resource: "brokers",
+		},
+		{
+			GroupVersionKind: schema.GroupVersionKind{
+				Kind:    "Broker",
+				Group:   "eventing.knative.dev",
 				Version: "v1alpha1",
 			},
 			Resource: "brokers",
diff --git a/pkg/util/knative/apis_test.go b/pkg/util/knative/apis_test.go
index 7710e87..b1014b6 100644
--- a/pkg/util/knative/apis_test.go
+++ b/pkg/util/knative/apis_test.go
@@ -85,7 +85,7 @@ func TestAPIs(t *testing.T) {
 	checkValidRefs(t, refs)
 	assert.Equal(t, v1.ObjectReference{
 		Kind:       "Channel",
-		APIVersion: "messaging.knative.dev/v1alpha1",
+		APIVersion: "messaging.knative.dev/v1beta1",
 		Name:       "ciao",
 	}, refs[0])
 
@@ -105,7 +105,7 @@ func TestAPIs(t *testing.T) {
 	checkValidRefs(t, refs)
 	assert.Equal(t, v1.ObjectReference{
 		Kind:       "Channel",
-		APIVersion: "messaging.knative.dev/v1alpha1",
+		APIVersion: "messaging.knative.dev/v1beta1",
 		Name:       "ciao",
 	}, refs[0])
 
@@ -130,7 +130,7 @@ func TestAPIs(t *testing.T) {
 	checkValidRefs(t, refs)
 	assert.Equal(t, v1.ObjectReference{
 		Kind:       "Broker",
-		APIVersion: "eventing.knative.dev/v1alpha1",
+		APIVersion: "eventing.knative.dev/v1beta1",
 		Name:       "default",
 	}, refs[0])
 
@@ -150,7 +150,7 @@ func TestAPIs(t *testing.T) {
 	checkValidRefs(t, refs)
 	assert.Equal(t, v1.ObjectReference{
 		Kind:       "Broker",
-		APIVersion: "eventing.knative.dev/v1alpha1",
+		APIVersion: "eventing.knative.dev/v1beta1",
 		Name:       "aaa",
 	}, refs[0])
 }
diff --git a/pkg/util/knative/knative.go b/pkg/util/knative/knative.go
index d3f3f9b..e39eb54 100644
--- a/pkg/util/knative/knative.go
+++ b/pkg/util/knative/knative.go
@@ -56,7 +56,7 @@ func CreateSubscription(channelReference corev1.ObjectReference, serviceName
str
 				Name:       channelReference.Name,
 			},
 			Subscriber: &duckv1.Destination{
-				Ref: &corev1.ObjectReference{
+				Ref: &duckv1.KReference{
 					APIVersion: serving.SchemeGroupVersion.String(),
 					Kind:       "Service",
 					Name:       serviceName,
@@ -87,7 +87,7 @@ func CreateTrigger(brokerReference corev1.ObjectReference, serviceName string,
e
 			},
 			Broker: brokerReference.Name,
 			Subscriber: duckv1.Destination{
-				Ref: &corev1.ObjectReference{
+				Ref: &duckv1.KReference{
 					APIVersion: serving.SchemeGroupVersion.String(),
 					Kind:       "Service",
 					Name:       serviceName,


Mime
View raw message