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

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

commit d522efbcee0eca97bafa8c5709f1e012a8bbb4f1
Author: nferraro <ni.ferr...@gmail.com>
AuthorDate: Mon Dec 24 10:42:27 2018 +0100

    Force setting the default port if missing
---
 pkg/apis/camel/v1alpha1/knative/types_support.go | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/knative/types_support.go 
b/pkg/apis/camel/v1alpha1/knative/types_support.go
index 97c6fe7..25f9ac9 100644
--- a/pkg/apis/camel/v1alpha1/knative/types_support.go
+++ b/pkg/apis/camel/v1alpha1/knative/types_support.go
@@ -29,12 +29,13 @@ func BuildCamelServiceDefinition(name string, serviceType 
CamelServiceType, rawu
        if err != nil {
                return nil, err
        }
+       protocol := CamelProtocol(serviceURL.Scheme)
        definition := CamelServiceDefinition{
                Name:        name,
                Host:        serviceURL.Host,
-               Port:        -1,
+               Port:        defaultCamelProtocolPort(protocol),
                ServiceType: serviceType,
-               Protocol:    CamelProtocol(serviceURL.Scheme),
+               Protocol:    protocol,
                Metadata:    make(map[string]string),
        }
        portStr := serviceURL.Port()
@@ -54,6 +55,17 @@ func BuildCamelServiceDefinition(name string, serviceType 
CamelServiceType, rawu
        return &definition, nil
 }
 
+func defaultCamelProtocolPort(prot CamelProtocol) int {
+       switch prot {
+       case CamelProtocolHTTP:
+               return 80
+       case CamelProtocolHTTPS:
+               return 443
+       default:
+               return -1
+       }
+}
+
 // Serialize serializes a CamelEnvironment
 func (env *CamelEnvironment) Serialize() (string, error) {
        res, err := json.Marshal(env)

Reply via email to