You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/12/09 14:06:26 UTC
[camel-k] branch master updated: chore(api): make
Endpoint.Properties a pointer so it can be omitted
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
The following commit(s) were added to refs/heads/master by this push:
new 82bf5e2 chore(api): make Endpoint.Properties a pointer so it can be omitted
82bf5e2 is described below
commit 82bf5e22e8a97cbe93b9adbe77879bd535413113
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Wed Dec 9 13:44:57 2020 +0100
chore(api): make Endpoint.Properties a pointer so it can be omitted
---
addons/strimzi/strimzi_test.go | 7 ++++---
e2e/support/test_support.go | 6 +++---
pkg/apis/camel/v1alpha1/kamelet_binding_types.go | 2 +-
pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go | 5 ++++-
pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go | 6 +++++-
pkg/util/bindings/bindings_test.go | 4 ++--
6 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/addons/strimzi/strimzi_test.go b/addons/strimzi/strimzi_test.go
index 13fd4ed..540db88 100644
--- a/addons/strimzi/strimzi_test.go
+++ b/addons/strimzi/strimzi_test.go
@@ -20,6 +20,8 @@ package strimzi
import (
"context"
"encoding/json"
+ "testing"
+
"github.com/apache/camel-k/addons/strimzi/duck/v1beta1"
"github.com/apache/camel-k/addons/strimzi/duck/v1beta1/client/internalclientset/fake"
camelv1 "github.com/apache/camel-k/pkg/apis/camel/v1"
@@ -29,7 +31,6 @@ import (
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "testing"
)
func TestStrimziDirect(t *testing.T) {
@@ -122,12 +123,12 @@ func TestStrimziLookup(t *testing.T) {
assert.Nil(t, binding.Traits)
}
-func asEndpointProperties(props map[string]string) v1alpha1.EndpointProperties {
+func asEndpointProperties(props map[string]string) *v1alpha1.EndpointProperties {
serialized, err := json.Marshal(props)
if err != nil {
panic(err)
}
- return v1alpha1.EndpointProperties{
+ return &v1alpha1.EndpointProperties{
RawMessage: serialized,
}
}
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index e572602..3a55ff4 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -56,7 +56,7 @@ import (
routev1 "github.com/openshift/api/route/v1"
"github.com/apache/camel-k/e2e/support/util"
- "github.com/apache/camel-k/pkg/apis/camel/v1"
+ v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
"github.com/apache/camel-k/pkg/client"
"github.com/apache/camel-k/pkg/cmd"
"github.com/apache/camel-k/pkg/install"
@@ -968,12 +968,12 @@ func asFlow(source map[string]interface{}) *v1.Flow {
}
}
-func asEndpointProperties(props map[string]string) v1alpha1.EndpointProperties {
+func asEndpointProperties(props map[string]string) *v1alpha1.EndpointProperties {
bytes, err := json.Marshal(props)
if err != nil {
panic(err)
}
- return v1alpha1.EndpointProperties{
+ return &v1alpha1.EndpointProperties{
RawMessage: bytes,
}
}
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
index c39c34d..d4d7ac1 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
@@ -41,7 +41,7 @@ type Endpoint struct {
// URI can alternatively be used to specify the (Camel) endpoint explicitly
URI *string `json:"uri,omitempty"`
// Properties are a key value representation of endpoint properties
- Properties EndpointProperties `json:"properties,omitempty"`
+ Properties *EndpointProperties `json:"properties,omitempty"`
}
type EndpointType string
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
index d470dc6..b589177 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
@@ -141,7 +141,10 @@ func (in *KameletBindingStatus) RemoveCondition(condType KameletBindingCondition
}
// GetPropertyMap returns the EndpointProperties as map
-func (p EndpointProperties) GetPropertyMap() (map[string]string, error) {
+func (p *EndpointProperties) GetPropertyMap() (map[string]string, error) {
+ if p == nil {
+ return nil, nil
+ }
if len(p.RawMessage) == 0 {
return nil, nil
}
diff --git a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
index 627e680..4f57f13 100644
--- a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
@@ -39,7 +39,11 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
*out = new(string)
**out = **in
}
- in.Properties.DeepCopyInto(&out.Properties)
+ if in.Properties != nil {
+ in, out := &in.Properties, &out.Properties
+ *out = new(EndpointProperties)
+ (*in).DeepCopyInto(*out)
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Endpoint.
diff --git a/pkg/util/bindings/bindings_test.go b/pkg/util/bindings/bindings_test.go
index 2648d07..72e8ce5 100644
--- a/pkg/util/bindings/bindings_test.go
+++ b/pkg/util/bindings/bindings_test.go
@@ -196,12 +196,12 @@ func TestBindings(t *testing.T) {
}
}
-func asEndpointProperties(props map[string]string) v1alpha1.EndpointProperties {
+func asEndpointProperties(props map[string]string) *v1alpha1.EndpointProperties {
serialized, err := json.Marshal(props)
if err != nil {
panic(err)
}
- return v1alpha1.EndpointProperties{
+ return &v1alpha1.EndpointProperties{
RawMessage: serialized,
}
}