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 2019/12/09 14:13:48 UTC

[camel-k] branch master updated (0a7693c -> 20eed1a)

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 0a7693c  chore(build): disable go modules when performing go clean
     new dc69450  Fix #1112: remove Knative 0.8 compatibility mode
     new dd0b09d  Fix #1112: upgrade to knative 0.10
     new 20eed1a  Fix #1112: switch to serving.knative.dev/v1

The 3 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:
 docs/modules/ROOT/pages/traits/knative.adoc        |   5 -
 go.mod                                             |   6 +-
 go.sum                                             |  12 +--
 ...toscheme_knative_eventing_08_compat_v1alpha1.go |  43 --------
 pkg/apis/addtoscheme_knative_serving_v1alpha1.go   |   2 +-
 pkg/apis/knative08compat/knative08compat.go        | 119 ---------------------
 pkg/trait/classpath_test.go                        |   5 +-
 pkg/trait/container.go                             |   2 +-
 pkg/trait/istio_test.go                            |  32 +++---
 pkg/trait/knative.go                               |  34 +-----
 pkg/trait/knative_service.go                       |  11 +-
 pkg/trait/knative_service_test.go                  |   8 +-
 pkg/trait/knative_test.go                          |  36 ++++---
 pkg/trait/owner.go                                 |   2 +-
 pkg/trait/probes_test.go                           |  11 +-
 pkg/util/knative/apis.go                           |   6 +-
 pkg/util/knative/apis_test.go                      |   4 +-
 pkg/util/knative/knative.go                        |  29 +++--
 pkg/util/kubernetes/collection.go                  |   9 +-
 pkg/util/kubernetes/replace.go                     |   7 +-
 20 files changed, 89 insertions(+), 294 deletions(-)
 delete mode 100644 pkg/apis/addtoscheme_knative_eventing_08_compat_v1alpha1.go
 delete mode 100644 pkg/apis/knative08compat/knative08compat.go


[camel-k] 01/03: Fix #1112: remove Knative 0.8 compatibility mode

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 dc694504ec792a95fb8f97a9be6666f8348a8dd2
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Thu Dec 5 15:53:01 2019 +0100

    Fix #1112: remove Knative 0.8 compatibility mode
---
 docs/modules/ROOT/pages/traits/knative.adoc        |   5 -
 ...toscheme_knative_eventing_08_compat_v1alpha1.go |  43 --------
 pkg/apis/knative08compat/knative08compat.go        | 119 ---------------------
 pkg/trait/istio_test.go                            |   5 -
 pkg/trait/knative.go                               |  32 +-----
 pkg/trait/knative_service_test.go                  |   6 --
 pkg/util/knative/knative.go                        |   6 +-
 7 files changed, 2 insertions(+), 214 deletions(-)

diff --git a/docs/modules/ROOT/pages/traits/knative.adoc b/docs/modules/ROOT/pages/traits/knative.adoc
index f3b44a7..50d27e6 100755
--- a/docs/modules/ROOT/pages/traits/knative.adoc
+++ b/docs/modules/ROOT/pages/traits/knative.adoc
@@ -69,11 +69,6 @@ Can contain simple event types or full Camel URIs (to use a specific broker).
 that can be removed in a future version of Knative, filtering is enabled only when the integration is
 listening from more than 1 channel.
 
-| knative.knative-08-compat-mode
-| bool
-| The Knative 0.8 compatibility mode will check the installed version of Knative and
-use resource versions compatible with Knative 0.8 if found on the cluster.
-
 | knative.auto
 | bool
 | Enable automatic discovery of all trait properties.
diff --git a/pkg/apis/addtoscheme_knative_eventing_08_compat_v1alpha1.go b/pkg/apis/addtoscheme_knative_eventing_08_compat_v1alpha1.go
deleted file mode 100644
index 51734f4..0000000
--- a/pkg/apis/addtoscheme_knative_eventing_08_compat_v1alpha1.go
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-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 apis
-
-import (
-	"github.com/apache/camel-k/pkg/apis/knative08compat"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/runtime"
-)
-
-var (
-	compat08SchemeBuilder = runtime.NewSchemeBuilder(eventing08CompatKnownTypes)
-	compat08AddToScheme   = compat08SchemeBuilder.AddToScheme
-)
-
-func init() {
-	AddToSchemes = append(AddToSchemes, compat08AddToScheme)
-}
-
-// eventing08CompatKnownTypes Adds the list of known types to Scheme.
-func eventing08CompatKnownTypes(scheme *runtime.Scheme) error {
-	scheme.AddKnownTypes(knative08compat.CompatSchemeGroupVersion,
-		&knative08compat.Subscription{},
-		&knative08compat.SubscriptionList{},
-	)
-	metav1.AddToGroupVersion(scheme, knative08compat.CompatSchemeGroupVersion)
-	return nil
-}
diff --git a/pkg/apis/knative08compat/knative08compat.go b/pkg/apis/knative08compat/knative08compat.go
deleted file mode 100644
index 395aae3..0000000
--- a/pkg/apis/knative08compat/knative08compat.go
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-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 knative08compat
-
-import (
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/runtime"
-	"k8s.io/apimachinery/pkg/runtime/schema"
-	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
-)
-
-// CompatSchemeGroupVersion is the old group version used in Knative 0.8
-var CompatSchemeGroupVersion = schema.GroupVersion{
-	Group:   "eventing.knative.dev",
-	Version: "v1alpha1",
-}
-
-// Subscription is a Knative 0.8 compatibility version for messaging.Subscription
-type Subscription struct {
-	metav1.TypeMeta   `json:",inline"`
-	metav1.ObjectMeta `json:"metadata"`
-	Spec              messaging.SubscriptionSpec   `json:"spec"`
-	Status            messaging.SubscriptionStatus `json:"status,omitempty"`
-}
-
-// SubscriptionList is a Knative 0.8 compatibility version for messaging.SubscriptionList
-type SubscriptionList struct {
-	metav1.TypeMeta `json:",inline"`
-	metav1.ListMeta `json:"metadata"`
-	Items           []Subscription `json:"items"`
-}
-
-// FromMessagingSubscription creates a compat08 subscription from a messaging.Subscription
-func FromMessagingSubscription(s messaging.Subscription) *Subscription {
-	in := s.DeepCopy()
-	out := Subscription{
-		TypeMeta:   in.TypeMeta,
-		ObjectMeta: in.ObjectMeta,
-		Spec:       in.Spec,
-		Status:     in.Status,
-	}
-	// fix API group
-	out.TypeMeta.APIVersion = CompatSchemeGroupVersion.String()
-	return &out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Subscription) DeepCopyInto(out *Subscription) {
-	*out = *in
-	out.TypeMeta = in.TypeMeta
-	in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
-	in.Spec.DeepCopyInto(&out.Spec)
-	in.Status.DeepCopyInto(&out.Status)
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription.
-func (in *Subscription) DeepCopy() *Subscription {
-	if in == nil {
-		return nil
-	}
-	out := new(Subscription)
-	in.DeepCopyInto(out)
-	return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *Subscription) DeepCopyObject() runtime.Object {
-	if c := in.DeepCopy(); c != nil {
-		return c
-	}
-	return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *SubscriptionList) DeepCopyInto(out *SubscriptionList) {
-	*out = *in
-	out.TypeMeta = in.TypeMeta
-	out.ListMeta = in.ListMeta
-	if in.Items != nil {
-		in, out := &in.Items, &out.Items
-		*out = make([]Subscription, len(*in))
-		for i := range *in {
-			(*in)[i].DeepCopyInto(&(*out)[i])
-		}
-	}
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList.
-func (in *SubscriptionList) DeepCopy() *SubscriptionList {
-	if in == nil {
-		return nil
-	}
-	out := new(SubscriptionList)
-	in.DeepCopyInto(out)
-	return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *SubscriptionList) DeepCopyObject() runtime.Object {
-	if c := in.DeepCopy(); c != nil {
-		return c
-	}
-	return nil
-}
diff --git a/pkg/trait/istio_test.go b/pkg/trait/istio_test.go
index 3671420..6e2f9f4 100644
--- a/pkg/trait/istio_test.go
+++ b/pkg/trait/istio_test.go
@@ -50,11 +50,6 @@ func NewIstioTestEnv(t *testing.T, d *appsv1.Deployment, s *serving.Service, ena
 					"istio": {
 						Configuration: make(map[string]string),
 					},
-					"knative": {
-						Configuration: map[string]string{
-							"knative-08-compat-mode": "false", // disable it so it does not check resources in the cluster
-						},
-					},
 				},
 			},
 		},
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 13f36ff..8e40db5 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -26,15 +26,11 @@ import (
 	"github.com/apache/camel-k/pkg/metadata"
 	"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"
 	v1 "k8s.io/api/core/v1"
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	eventing "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
-	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
 	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
-	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 )
 
 // The Knative trait automatically discovers addresses of Knative resources and inject them into the
@@ -71,9 +67,6 @@ type knativeTrait struct {
 	// that can be removed in a future version of Knative, filtering is enabled only when the integration is
 	// listening from more than 1 channel.
 	FilterSourceChannels *bool `property:"filter-source-channels"`
-	// The Knative 0.8 compatibility mode will check the installed version of Knative and
-	// use resource versions compatible with Knative 0.8 if found on the cluster.
-	Knative08CompatMode *bool `property:"knative-08-compat-mode"`
 	// Enable automatic discovery of all trait properties.
 	Auto *bool `property:"auto"`
 }
@@ -167,14 +160,6 @@ func (t *knativeTrait) Configure(e *Environment) (bool, error) {
 			filter := true
 			t.FilterSourceChannels = &filter
 		}
-
-		if t.Knative08CompatMode == nil {
-			compat, err := t.shouldUseKnative08CompatMode(e.Integration.Namespace)
-			if err != nil {
-				return false, err
-			}
-			t.Knative08CompatMode = &compat
-		}
 	}
 
 	return true, nil
@@ -258,8 +243,7 @@ func (t *knativeTrait) configureChannels(e *Environment, env *knativeapi.CamelEn
 }
 
 func (t *knativeTrait) createSubscription(e *Environment, ref *v1.ObjectReference) error {
-	compat := t.Knative08CompatMode != nil && *t.Knative08CompatMode
-	sub := knativeutil.CreateSubscription(*ref, e.Integration.Name, compat)
+	sub := knativeutil.CreateSubscription(*ref, e.Integration.Name)
 	e.Resources.Add(sub)
 	return nil
 }
@@ -429,17 +413,3 @@ func (t *knativeTrait) extractServices(names string, serviceType knativeapi.Came
 	}
 	return answer
 }
-
-func (t *knativeTrait) shouldUseKnative08CompatMode(namespace string) (bool, error) {
-	lst := messaging.SubscriptionList{
-		TypeMeta: metav1.TypeMeta{
-			Kind:       "Subscription",
-			APIVersion: messaging.SchemeGroupVersion.String(),
-		},
-	}
-	err := t.client.List(t.ctx, &lst, k8sclient.InNamespace(namespace))
-	if err != nil && kubernetes.IsUnknownAPIError(err) {
-		return true, nil
-	}
-	return false, err
-}
diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go
index 661afb4..833f847 100644
--- a/pkg/trait/knative_service_test.go
+++ b/pkg/trait/knative_service_test.go
@@ -45,9 +45,6 @@ func TestKnativeService(t *testing.T) {
 	assert.Nil(t, err)
 
 	traitCatalog := NewCatalog(context.TODO(), nil)
-	knativeTrait := traitCatalog.GetTrait("knative").(*knativeTrait)
-	falze := false
-	knativeTrait.Knative08CompatMode = &falze
 
 	environment := Environment{
 		CamelCatalog: catalog,
@@ -187,9 +184,6 @@ func TestKnativeServiceWithCustomContainerName(t *testing.T) {
 	assert.Nil(t, err)
 
 	traitCatalog := NewCatalog(context.TODO(), nil)
-	knativeTrait := traitCatalog.GetTrait("knative").(*knativeTrait)
-	falze := false
-	knativeTrait.Knative08CompatMode = &falze
 
 	environment := Environment{
 		CamelCatalog: catalog,
diff --git a/pkg/util/knative/knative.go b/pkg/util/knative/knative.go
index 13e2704..5e4aabf 100644
--- a/pkg/util/knative/knative.go
+++ b/pkg/util/knative/knative.go
@@ -22,7 +22,6 @@ import (
 	"fmt"
 	"net/url"
 
-	"github.com/apache/camel-k/pkg/apis/knative08compat"
 	"github.com/apache/camel-k/pkg/client"
 	kubernetesutils "github.com/apache/camel-k/pkg/util/kubernetes"
 	"github.com/apache/camel-k/pkg/util/log"
@@ -71,7 +70,7 @@ func IsInstalled(ctx context.Context, c kubernetes.Interface) (bool, error) {
 }
 
 // CreateSubscription ---
-func CreateSubscription(channelReference corev1.ObjectReference, serviceName string, compat08 bool) runtime.Object {
+func CreateSubscription(channelReference corev1.ObjectReference, serviceName string) runtime.Object {
 	subs := messaging.Subscription{
 		TypeMeta: metav1.TypeMeta{
 			APIVersion: messaging.SchemeGroupVersion.String(),
@@ -97,9 +96,6 @@ func CreateSubscription(channelReference corev1.ObjectReference, serviceName str
 		},
 	}
 
-	if compat08 {
-		return knative08compat.FromMessagingSubscription(subs)
-	}
 	return &subs
 }
 


[camel-k] 03/03: Fix #1112: switch to serving.knative.dev/v1

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 20eed1a42e8f59ee59dee203dd714a8243bd2ed1
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Thu Dec 5 17:28:21 2019 +0100

    Fix #1112: switch to serving.knative.dev/v1
---
 pkg/apis/addtoscheme_knative_serving_v1alpha1.go |  2 +-
 pkg/trait/classpath_test.go                      |  5 ++--
 pkg/trait/container.go                           |  2 +-
 pkg/trait/istio_test.go                          | 27 +++++++++---------
 pkg/trait/knative.go                             |  2 +-
 pkg/trait/knative_service.go                     | 11 ++++----
 pkg/trait/knative_service_test.go                |  2 +-
 pkg/trait/knative_test.go                        | 36 ++++++++++++++++--------
 pkg/trait/owner.go                               |  2 +-
 pkg/trait/probes_test.go                         | 11 ++++----
 pkg/util/knative/apis.go                         |  6 ++--
 pkg/util/knative/apis_test.go                    |  4 +--
 pkg/util/knative/knative.go                      | 18 ++++++------
 pkg/util/kubernetes/collection.go                |  9 +++---
 pkg/util/kubernetes/replace.go                   |  7 ++---
 15 files changed, 75 insertions(+), 69 deletions(-)

diff --git a/pkg/apis/addtoscheme_knative_serving_v1alpha1.go b/pkg/apis/addtoscheme_knative_serving_v1alpha1.go
index b96c913..f270608 100644
--- a/pkg/apis/addtoscheme_knative_serving_v1alpha1.go
+++ b/pkg/apis/addtoscheme_knative_serving_v1alpha1.go
@@ -18,7 +18,7 @@ limitations under the License.
 package apis
 
 import (
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 func init() {
diff --git a/pkg/trait/classpath_test.go b/pkg/trait/classpath_test.go
index 125d75e..20d62dc 100644
--- a/pkg/trait/classpath_test.go
+++ b/pkg/trait/classpath_test.go
@@ -26,8 +26,7 @@ import (
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/util/kubernetes"
@@ -148,7 +147,7 @@ func TestApplyClasspathTraitWithKNativeResource(t *testing.T) {
 	trait, environment := createNominalClasspathTest()
 
 	s := serving.Service{}
-	s.Spec.ConfigurationSpec.Template = servingv1.RevisionTemplateSpec{}
+	s.Spec.ConfigurationSpec.Template = serving.RevisionTemplateSpec{}
 	s.Spec.ConfigurationSpec.Template.Spec.Containers = []corev1.Container{
 		{
 			Name: defaultContainerName,
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index 6bd3ae6..558e109 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -27,7 +27,7 @@ import (
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
 	"k8s.io/apimachinery/pkg/util/intstr"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 const (
diff --git a/pkg/trait/istio_test.go b/pkg/trait/istio_test.go
index 6e2f9f4..b68d374 100644
--- a/pkg/trait/istio_test.go
+++ b/pkg/trait/istio_test.go
@@ -26,8 +26,7 @@ import (
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/util/camel"
@@ -75,9 +74,9 @@ func NewIstioTestEnv(t *testing.T, d *appsv1.Deployment, s *serving.Service, ena
 
 func TestIstioInject(t *testing.T) {
 	s := serving.Service{
-		Spec: servingv1.ServiceSpec{
-			ConfigurationSpec: servingv1.ConfigurationSpec{
-				Template: servingv1.RevisionTemplateSpec{},
+		Spec: serving.ServiceSpec{
+			ConfigurationSpec: serving.ConfigurationSpec{
+				Template: serving.RevisionTemplateSpec{},
 			},
 		},
 	}
@@ -97,9 +96,9 @@ func TestIstioInject(t *testing.T) {
 
 func TestIstioForcedInjectTrue(t *testing.T) {
 	s := serving.Service{
-		Spec: servingv1.ServiceSpec{
-			ConfigurationSpec: servingv1.ConfigurationSpec{
-				Template: servingv1.RevisionTemplateSpec{},
+		Spec: serving.ServiceSpec{
+			ConfigurationSpec: serving.ConfigurationSpec{
+				Template: serving.RevisionTemplateSpec{},
 			},
 		},
 	}
@@ -121,9 +120,9 @@ func TestIstioForcedInjectTrue(t *testing.T) {
 
 func TestIstioForcedInjectFalse(t *testing.T) {
 	s := serving.Service{
-		Spec: servingv1.ServiceSpec{
-			ConfigurationSpec: servingv1.ConfigurationSpec{
-				Template: servingv1.RevisionTemplateSpec{},
+		Spec: serving.ServiceSpec{
+			ConfigurationSpec: serving.ConfigurationSpec{
+				Template: serving.RevisionTemplateSpec{},
 			},
 		},
 	}
@@ -145,9 +144,9 @@ func TestIstioForcedInjectFalse(t *testing.T) {
 
 func TestIstioDisabled(t *testing.T) {
 	s := serving.Service{
-		Spec: servingv1.ServiceSpec{
-			ConfigurationSpec: servingv1.ConfigurationSpec{
-				Template: servingv1.RevisionTemplateSpec{},
+		Spec: serving.ServiceSpec{
+			ConfigurationSpec: serving.ConfigurationSpec{
+				Template: serving.RevisionTemplateSpec{},
 			},
 		},
 	}
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 8e40db5..1256136 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -30,7 +30,7 @@ import (
 	v1 "k8s.io/api/core/v1"
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	eventing "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 // The Knative trait automatically discovers addresses of Knative resources and inject them into the
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index b57f76f..f8d5d25 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -23,8 +23,7 @@ import (
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/metadata"
@@ -280,14 +279,14 @@ func (t *knativeServiceTrait) getServiceFor(e *Environment) *serving.Service {
 			Labels:      labels,
 			Annotations: e.Integration.Annotations,
 		},
-		Spec: servingv1.ServiceSpec{
-			ConfigurationSpec: servingv1.ConfigurationSpec{
-				Template: servingv1.RevisionTemplateSpec{
+		Spec: serving.ServiceSpec{
+			ConfigurationSpec: serving.ConfigurationSpec{
+				Template: serving.RevisionTemplateSpec{
 					ObjectMeta: metav1.ObjectMeta{
 						Labels:      labels,
 						Annotations: annotations,
 					},
-					Spec: servingv1.RevisionSpec{
+					Spec: serving.RevisionSpec{
 						PodSpec: corev1.PodSpec{
 							ServiceAccountName: e.Integration.Spec.ServiceAccountName,
 						},
diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go
index 833f847..faad1b2 100644
--- a/pkg/trait/knative_service_test.go
+++ b/pkg/trait/knative_service_test.go
@@ -26,7 +26,7 @@ import (
 
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/apache/camel-k/pkg/util/camel"
diff --git a/pkg/trait/knative_test.go b/pkg/trait/knative_test.go
index 13038e5..3596188 100644
--- a/pkg/trait/knative_test.go
+++ b/pkg/trait/knative_test.go
@@ -31,8 +31,8 @@ import (
 	"knative.dev/pkg/apis"
 	duckv1 "knative.dev/pkg/apis/duck/v1"
 	duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	knativeapi "github.com/apache/camel-k/pkg/apis/camel/v1alpha1/knative"
@@ -130,14 +130,14 @@ func TestKnativeEnvConfigurationFromTrait(t *testing.T) {
 	assert.NotNil(t, cSink1)
 	assert.Equal(t, "channel-sink-1.host", cSink1.Host)
 
-	eSource1 := ne.FindService("endpoint-source-1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1beta1", "Service")
+	eSource1 := ne.FindService("endpoint-source-1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
 	assert.NotNil(t, eSource1)
 	assert.Equal(t, "0.0.0.0", eSource1.Host)
 
-	eSink1 := ne.FindService("endpoint-sink-1", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1beta1", "Service")
+	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)
-	eSink2 := ne.FindService("endpoint-sink-2", knativeapi.CamelEndpointKindSink, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1beta1", "Service")
+	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)
 }
@@ -232,13 +232,21 @@ func TestKnativeEnvConfigurationFromSource(t *testing.T) {
 	err = ne.Deserialize(kc.Value)
 	assert.Nil(t, err)
 
-	source := ne.FindService("s3fileMover1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1beta1", "Service")
+	source := ne.FindService("s3fileMover1", knativeapi.CamelEndpointKindSource, knativeapi.CamelServiceTypeEndpoint, "serving.knative.dev/v1", "Service")
 	assert.NotNil(t, source)
 	assert.Equal(t, "0.0.0.0", source.Host)
 	assert.Equal(t, 8080, source.Port)
 }
 
 func NewFakeClient(namespace string) (client.Client, error) {
+	channelSourceURL, err := apis.ParseURL("http://channel-source-1.host/")
+	if err != nil {
+		return nil, err
+	}
+	channelSinkURL, err := apis.ParseURL("http://channel-sink-1.host/")
+	if err != nil {
+		return nil, err
+	}
 	sink1URL, err := apis.ParseURL("http://endpoint-sink-1.host/")
 	if err != nil {
 		return nil, err
@@ -260,7 +268,9 @@ func NewFakeClient(namespace string) (client.Client, error) {
 			Status: messaging.ChannelStatus{
 				AddressStatus: duckv1alpha1.AddressStatus{
 					Address: &duckv1alpha1.Addressable{
-						Hostname: "channel-source-1.host",
+						Addressable: duckv1beta1.Addressable{
+							URL: channelSourceURL,
+						},
 					},
 				},
 			},
@@ -277,7 +287,9 @@ func NewFakeClient(namespace string) (client.Client, error) {
 			Status: messaging.ChannelStatus{
 				AddressStatus: duckv1alpha1.AddressStatus{
 					Address: &duckv1alpha1.Addressable{
-						Hostname: "channel-sink-1.host",
+						Addressable: duckv1beta1.Addressable{
+							URL: channelSinkURL,
+						},
 					},
 				},
 			},
@@ -291,8 +303,8 @@ func NewFakeClient(namespace string) (client.Client, error) {
 				Namespace: namespace,
 				Name:      "endpoint-sink-1",
 			},
-			Status: servingv1.ServiceStatus{
-				RouteStatusFields: servingv1.RouteStatusFields{
+			Status: serving.ServiceStatus{
+				RouteStatusFields: serving.RouteStatusFields{
 
 					Address: &duckv1.Addressable{
 						URL: sink1URL,
@@ -309,8 +321,8 @@ func NewFakeClient(namespace string) (client.Client, error) {
 				Namespace: namespace,
 				Name:      "endpoint-sink-2",
 			},
-			Status: servingv1.ServiceStatus{
-				RouteStatusFields: servingv1.RouteStatusFields{
+			Status: serving.ServiceStatus{
+				RouteStatusFields: serving.RouteStatusFields{
 					Address: &duckv1.Addressable{
 						URL: sink2URL,
 					},
diff --git a/pkg/trait/owner.go b/pkg/trait/owner.go
index 3b1ff11..784a650 100644
--- a/pkg/trait/owner.go
+++ b/pkg/trait/owner.go
@@ -24,7 +24,7 @@ import (
 
 	appsv1 "k8s.io/api/apps/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 // The Owner trait ensures that all created resources belong to the integration being created
diff --git a/pkg/trait/probes_test.go b/pkg/trait/probes_test.go
index e2d1b09..69ab235 100644
--- a/pkg/trait/probes_test.go
+++ b/pkg/trait/probes_test.go
@@ -27,8 +27,7 @@ import (
 
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 func TestProbesDeps(t *testing.T) {
@@ -101,10 +100,10 @@ func TestProbesOnDeployment(t *testing.T) {
 
 func TestProbesOnKnativeService(t *testing.T) {
 	target := serving.Service{
-		Spec: servingv1.ServiceSpec{
-			ConfigurationSpec: servingv1.ConfigurationSpec{
-				Template: servingv1.RevisionTemplateSpec{
-					Spec: servingv1.RevisionSpec{
+		Spec: serving.ServiceSpec{
+			ConfigurationSpec: serving.ConfigurationSpec{
+				Template: serving.RevisionTemplateSpec{
+					Spec: serving.RevisionSpec{
 						PodSpec: corev1.PodSpec{
 							Containers: []corev1.Container{
 								{
diff --git a/pkg/util/knative/apis.go b/pkg/util/knative/apis.go
index bb80509..43708bc 100644
--- a/pkg/util/knative/apis.go
+++ b/pkg/util/knative/apis.go
@@ -59,17 +59,17 @@ var (
 		{
 			Kind:    "Service",
 			Group:   "serving.knative.dev",
-			Version: "v1beta1",
+			Version: "v1",
 		},
 		{
 			Kind:    "Service",
 			Group:   "serving.knative.dev",
-			Version: "v1alpha1",
+			Version: "v1beta1",
 		},
 		{
 			Kind:    "Service",
 			Group:   "serving.knative.dev",
-			Version: "v1",
+			Version: "v1alpha1",
 		},
 	}
 
diff --git a/pkg/util/knative/apis_test.go b/pkg/util/knative/apis_test.go
index ab573b9..9078273 100644
--- a/pkg/util/knative/apis_test.go
+++ b/pkg/util/knative/apis_test.go
@@ -32,7 +32,7 @@ func TestAPIs(t *testing.T) {
 	checkValidRefs(t, refs)
 	assert.Equal(t, v1.ObjectReference{
 		Kind:       "Service",
-		APIVersion: "serving.knative.dev/v1beta1",
+		APIVersion: "serving.knative.dev/v1",
 		Name:       "ciao",
 	}, refs[0])
 
@@ -75,7 +75,7 @@ func TestAPIs(t *testing.T) {
 	checkValidRefs(t, refs)
 	assert.Equal(t, v1.ObjectReference{
 		Kind:       "Service",
-		APIVersion: "serving.knative.dev/v1beta1",
+		APIVersion: "serving.knative.dev/v1",
 		Name:       "ciao",
 	}, refs[0])
 
diff --git a/pkg/util/knative/knative.go b/pkg/util/knative/knative.go
index 8c24d3d..003912b 100644
--- a/pkg/util/knative/knative.go
+++ b/pkg/util/knative/knative.go
@@ -38,9 +38,9 @@ import (
 	eventing "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
 	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
 	"knative.dev/pkg/apis/duck"
-	duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
+	duckv1 "knative.dev/pkg/apis/duck/v1"
 	apisv1alpha1 "knative.dev/pkg/apis/v1alpha1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 // IsEnabledInNamespace returns true if we can list some basic knative objects in the given namespace
@@ -176,23 +176,23 @@ func GetSinkURI(ctx context.Context, c client.Client, sink *corev1.ObjectReferen
 
 	objIdentifier := fmt.Sprintf("\"%s/%s\" (%s)", u.GetNamespace(), u.GetName(), u.GroupVersionKind())
 	// Special case v1/Service to allow it be addressable
-	if u.GroupVersionKind().Kind == "Service" && u.GroupVersionKind().Version == "v1" {
+	if u.GroupVersionKind().Kind == "Service" && u.GroupVersionKind().Group == "" && u.GroupVersionKind().Version == "v1" {
 		return fmt.Sprintf("http://%s.%s.svc/", u.GetName(), u.GetNamespace()), nil
 	}
 
-	t := duckv1alpha1.AddressableType{}
+	t := duckv1.AddressableType{}
 	err = duck.FromUnstructured(u, &t)
 	if err != nil {
 		return "", fmt.Errorf("failed to deserialize sink %s: %v", objIdentifier, err)
 	}
 
-	if t.Status.Address == nil {
-		return "", fmt.Errorf("sink %s does not contain address", objIdentifier)
+	if t.Status.Address == nil || t.Status.Address.URL == nil {
+		return "", fmt.Errorf("sink %s does not contain address or URL", objIdentifier)
 	}
 
-	url := t.Status.Address.GetURL()
-	if url.Host == "" {
+	addressURL := t.Status.Address.URL
+	if addressURL.Host == "" {
 		return "", fmt.Errorf("sink %s contains an empty hostname", objIdentifier)
 	}
-	return url.String(), nil
+	return addressURL.String(), nil
 }
diff --git a/pkg/util/kubernetes/collection.go b/pkg/util/kubernetes/collection.go
index 20a2c25..d825a78 100644
--- a/pkg/util/kubernetes/collection.go
+++ b/pkg/util/kubernetes/collection.go
@@ -25,8 +25,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	eventing "knative.dev/eventing/pkg/apis/eventing/v1alpha1"
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 )
 
 // A Collection is a container of Kubernetes resources
@@ -298,7 +297,7 @@ func (c *Collection) VisitContainer(visitor func(container *corev1.Container)) {
 			visitor(cntref)
 		}
 	})
-	c.VisitKnativeConfigurationSpec(func(cs *servingv1.ConfigurationSpec) {
+	c.VisitKnativeConfigurationSpec(func(cs *serving.ConfigurationSpec) {
 		for id := range cs.Template.Spec.Containers {
 			cntref := &cs.Template.Spec.Containers[id]
 			visitor(cntref)
@@ -311,13 +310,13 @@ func (c *Collection) VisitPodSpec(visitor func(container *corev1.PodSpec)) {
 	c.VisitDeployment(func(d *appsv1.Deployment) {
 		visitor(&d.Spec.Template.Spec)
 	})
-	c.VisitKnativeConfigurationSpec(func(cs *servingv1.ConfigurationSpec) {
+	c.VisitKnativeConfigurationSpec(func(cs *serving.ConfigurationSpec) {
 		visitor(&cs.Template.Spec.PodSpec)
 	})
 }
 
 // VisitKnativeConfigurationSpec executes the visitor function on all knative ConfigurationSpec inside serving Services
-func (c *Collection) VisitKnativeConfigurationSpec(visitor func(container *servingv1.ConfigurationSpec)) {
+func (c *Collection) VisitKnativeConfigurationSpec(visitor func(container *serving.ConfigurationSpec)) {
 	c.VisitKnativeService(func(s *serving.Service) {
 		visitor(&s.Spec.ConfigurationSpec)
 	})
diff --git a/pkg/util/kubernetes/replace.go b/pkg/util/kubernetes/replace.go
index 7a25ab3..c0c417a 100644
--- a/pkg/util/kubernetes/replace.go
+++ b/pkg/util/kubernetes/replace.go
@@ -28,8 +28,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
-	servingv1 "knative.dev/serving/pkg/apis/serving/v1"
-	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
+	serving "knative.dev/serving/pkg/apis/serving/v1"
 	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 )
 
@@ -121,8 +120,8 @@ func mapRequiredKnativeServiceV1Beta1Data(from runtime.Object, to runtime.Object
 }
 
 func mapRequiredKnativeServiceV1Data(from runtime.Object, to runtime.Object) {
-	if fromC, ok := from.(*servingv1.Service); ok {
-		if toC, ok := to.(*servingv1.Service); ok {
+	if fromC, ok := from.(*serving.Service); ok {
+		if toC, ok := to.(*serving.Service); ok {
 			if toC.ObjectMeta.Annotations == nil {
 				toC.ObjectMeta.Annotations = make(map[string]string)
 			}


[camel-k] 02/03: Fix #1112: upgrade to knative 0.10

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 dd0b09d37d71bb42d0bb806368a9882281b76c52
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Thu Dec 5 16:22:13 2019 +0100

    Fix #1112: upgrade to knative 0.10
---
 go.mod                      |  6 +++---
 go.sum                      | 12 ++++++------
 pkg/util/knative/knative.go |  5 +++--
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/go.mod b/go.mod
index d35bfdf..5af83f5 100644
--- a/go.mod
+++ b/go.mod
@@ -31,9 +31,9 @@ require (
 	k8s.io/apimachinery v0.0.0
 	k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
 	k8s.io/gengo v0.0.0-20191010091904-7fa3014cb28f
-	knative.dev/eventing v0.9.0
-	knative.dev/pkg v0.0.0-20191017202117-b5a8deb92e5c
-	knative.dev/serving v0.9.0
+	knative.dev/eventing v0.10.0
+	knative.dev/pkg v0.0.0-20191107185656-884d50f09454
+	knative.dev/serving v0.10.0
 	sigs.k8s.io/controller-runtime v0.3.0
 )
 
diff --git a/go.sum b/go.sum
index cebac5f..c55c3c8 100644
--- a/go.sum
+++ b/go.sum
@@ -776,12 +776,12 @@ k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3
 k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
 k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5 h1:VBM/0P5TWxwk+Nw6Z+lAw3DKgO76g90ETOiA6rfLV1Y=
 k8s.io/utils v0.0.0-20190506122338-8fab8cb257d5/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
-knative.dev/eventing v0.9.0 h1:0eqp7rES1E5DE5Hj3MOHHyM2BzCe/7Mtp5tPjYoeCxs=
-knative.dev/eventing v0.9.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
-knative.dev/pkg v0.0.0-20191017202117-b5a8deb92e5c h1:8JcuEBoJQJ6XyR72emqB2cQg/3UZfRREY2lMAJw92n4=
-knative.dev/pkg v0.0.0-20191017202117-b5a8deb92e5c/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
-knative.dev/serving v0.9.0 h1:GVnsksAEX6vMXGygvzsGPIrFTypiesaseK7emm0LKWQ=
-knative.dev/serving v0.9.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0=
+knative.dev/eventing v0.10.0 h1:dDrOjBWWgloOCUjxR8ixUIh8nqCTbmM5BbGo8rvf1bc=
+knative.dev/eventing v0.10.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58=
+knative.dev/pkg v0.0.0-20191107185656-884d50f09454 h1:nkslWFyRWaJp3nPDm+GSQOSvN8NpZg8qIYTR+XssNNg=
+knative.dev/pkg v0.0.0-20191107185656-884d50f09454/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
+knative.dev/serving v0.10.0 h1:T1csznAQrc/DvCE4KROz4NqOtJ24mnU9eF9RMeeYaCc=
+knative.dev/serving v0.10.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/util/knative/knative.go b/pkg/util/knative/knative.go
index 5e4aabf..8c24d3d 100644
--- a/pkg/util/knative/knative.go
+++ b/pkg/util/knative/knative.go
@@ -39,6 +39,7 @@ import (
 	messaging "knative.dev/eventing/pkg/apis/messaging/v1alpha1"
 	"knative.dev/pkg/apis/duck"
 	duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
+	apisv1alpha1 "knative.dev/pkg/apis/v1alpha1"
 	serving "knative.dev/serving/pkg/apis/serving/v1beta1"
 )
 
@@ -86,7 +87,7 @@ func CreateSubscription(channelReference corev1.ObjectReference, serviceName str
 				Kind:       channelReference.Kind,
 				Name:       channelReference.Name,
 			},
-			Subscriber: &messaging.SubscriberSpec{
+			Subscriber: &apisv1alpha1.Destination{
 				Ref: &corev1.ObjectReference{
 					APIVersion: serving.SchemeGroupVersion.String(),
 					Kind:       "Service",
@@ -117,7 +118,7 @@ func CreateTrigger(brokerReference corev1.ObjectReference, serviceName string, e
 				},
 			},
 			Broker: brokerReference.Name,
-			Subscriber: &messaging.SubscriberSpec{
+			Subscriber: &apisv1alpha1.Destination{
 				Ref: &corev1.ObjectReference{
 					APIVersion: serving.SchemeGroupVersion.String(),
 					Kind:       "Service",