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 40e9ab5ee4e8ab853b0074da69dcedee262d1e33
Author: nferraro <ni.ferr...@gmail.com>
AuthorDate: Fri Dec 21 17:19:13 2018 +0100

    Moving Knative env serialization to API
---
 pkg/apis/camel/v1alpha1/knative/types_support.go | 11 +++++++++++
 pkg/trait/knative.go                             | 10 ++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/knative/types_support.go 
b/pkg/apis/camel/v1alpha1/knative/types_support.go
index b8cc62d..49df4c3 100644
--- a/pkg/apis/camel/v1alpha1/knative/types_support.go
+++ b/pkg/apis/camel/v1alpha1/knative/types_support.go
@@ -18,6 +18,7 @@ limitations under the License.
 package knative
 
 import (
+       "encoding/json"
        "net/url"
        "strconv"
 )
@@ -52,3 +53,13 @@ func BuildCamelServiceDefinition(name string, serviceType 
CamelServiceType, rawu
        }
        return &definition, nil
 }
+
+
+// Serialize serializes a CamelEnvironment
+func (env CamelEnvironment) Serialize() (string, error) {
+       res, err := json.Marshal(env)
+       if err != nil {
+               return "", err
+       }
+       return string(res), nil
+}
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index ae743af..60010b4 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -18,7 +18,6 @@ limitations under the License.
 package trait
 
 import (
-       "encoding/json"
        "fmt"
 
        "github.com/apache/camel-k/pkg/util/envvar"
@@ -31,9 +30,9 @@ import (
 
        "github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 
+       knativeapi "github.com/apache/camel-k/pkg/apis/camel/v1alpha1/knative"
        "github.com/apache/camel-k/pkg/metadata"
        knativeutil "github.com/apache/camel-k/pkg/util/knative"
-       knativeapi "github.com/apache/camel-k/pkg/apis/camel/v1alpha1/knative"
        eventing "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
        serving "github.com/knative/serving/pkg/apis/serving/v1alpha1"
        corev1 "k8s.io/api/core/v1"
@@ -289,12 +288,7 @@ func (t *knativeTrait) getConfigurationSerialized(e 
*Environment) (string, error
        if err != nil {
                return "", errors.Wrap(err, "unable fetch environment 
configuration")
        }
-
-       res, err := json.Marshal(env)
-       if err != nil {
-               return "", errors.Wrap(err, "unable to serialize Knative 
configuration")
-       }
-       return string(res), nil
+       return env.Serialize()
 }
 
 func (t *knativeTrait) getConfiguration(e *Environment) 
(knativeapi.CamelEnvironment, error) {

Reply via email to