Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(api): make Endpoint.Properties a pointer so it can be omitted #1853

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions addons/strimzi/strimzi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
}
}
6 changes: 3 additions & 3 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/camel/v1alpha1/kamelet_binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/camel/v1alpha1/kamelet_binding_types_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/util/bindings/bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down