This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 5443d0c  chore: Remove Camel Sources support from Knative trait
5443d0c is described below

commit 5443d0c3c644d163375035a5fe2b5176778a2ce9
Author: Antonin Stefanutti <anto...@stefanutti.fr>
AuthorDate: Mon Jun 28 15:35:33 2021 +0200

    chore: Remove Camel Sources support from Knative trait
---
 pkg/apis/camel/v1/knative/types.go | 14 +++++--------
 pkg/trait/knative.go               | 41 --------------------------------------
 2 files changed, 5 insertions(+), 50 deletions(-)

diff --git a/pkg/apis/camel/v1/knative/types.go 
b/pkg/apis/camel/v1/knative/types.go
index d9808b0..dcf293b 100644
--- a/pkg/apis/camel/v1/knative/types.go
+++ b/pkg/apis/camel/v1/knative/types.go
@@ -33,15 +33,11 @@ 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"`
-       // Deprecated: use URL instead
-       Host string `json:"host,omitempty"`
-       // Deprecated: use URL instead
-       Port     *int              `json:"port,omitempty"`
-       URL      string            `json:"url,omitempty"`
-       Path     string            `json:"path,omitempty"`
-       Metadata map[string]string `json:"metadata,omitempty"`
+       ServiceType CamelServiceType  `json:"type"`
+       Name        string            `json:"name"`
+       URL         string            `json:"url,omitempty"`
+       Path        string            `json:"path,omitempty"`
+       Metadata    map[string]string `json:"metadata,omitempty"`
 }
 
 // CamelEndpointKind --
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 15f6ecf..6a9018c 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -22,7 +22,6 @@ import (
        "net/url"
        "reflect"
        "sort"
-       "strconv"
        "strings"
 
        "github.com/pkg/errors"
@@ -78,8 +77,6 @@ type knativeTrait struct {
        // Enables filtering on events based on the header "ce-knativehistory". 
Since this header has been removed in newer versions of
        // Knative, filtering is disabled by default.
        FilterSourceChannels *bool `property:"filter-source-channels" 
json:"filterSourceChannels,omitempty"`
-       // Enables Knative CamelSource pre 0.15 compatibility fixes (will be 
removed in future versions).
-       CamelSourceCompat *bool `property:"camel-source-compat" 
json:"camelSourceCompat,omitempty"`
        // Allows binding the integration to a sink via a Knative SinkBinding 
resource.
        // This can be used when the integration targets a single sink.
        // It's enabled by default when the integration targets a single sink
@@ -209,29 +206,6 @@ func (t *knativeTrait) Configure(e *Environment) (bool, 
error) {
 }
 
 func (t *knativeTrait) Apply(e *Environment) error {
-       // To be removed when Knative CamelSources < 0.15 will no longer be 
supported
-       // Older versions of Knative Sources use a loader rather than an 
interceptor
-       if util.IsNilOrTrue(t.CamelSourceCompat) {
-               for i, s := range e.Integration.Spec.Sources {
-                       if s.Loader == "knative-source" {
-                               s.Loader = ""
-                               util.StringSliceUniqueAdd(&s.Interceptors, 
"knative-source")
-                               e.Integration.Spec.Sources[i] = s
-                       }
-               }
-       }
-       // End of temporary code
-
-       if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
-               // Interceptor may have been set by a Knative CamelSource
-               if util.StringSliceExists(e.getAllInterceptors(), 
"knative-source") {
-                       // Adding required libraries for Camel sources
-                       
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
"mvn:org.apache.camel.k:camel-knative")
-                       
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
"mvn:org.apache.camel.k:camel-k-knative")
-                       
util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
"mvn:org.apache.camel.k:camel-k-knative-producer")
-               }
-       }
-
        if util.IsTrue(t.SinkBinding) {
                util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, 
"mvn:org.apache.camel.k:camel-k-knative")
        }
@@ -251,21 +225,6 @@ 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
                }

Reply via email to