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 95afaeb chore(api): make KameletSpec.Definition a pointer so it can
be omitted
95afaeb is described below
commit 95afaebc68be2015df218d4d7858eb90aad950ce
Author: Luca Burgazzoli <[email protected]>
AuthorDate: Wed Dec 9 17:39:19 2020 +0100
chore(api): make KameletSpec.Definition a pointer so it can be omitted
---
e2e/support/test_support.go | 2 +-
pkg/apis/camel/v1alpha1/kamelet_types.go | 2 +-
pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go | 6 +++++-
pkg/kamelet/initialize.go | 4 ++++
pkg/trait/kamelets.go | 8 --------
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 3a55ff4..561556f 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -904,7 +904,7 @@ func CreateTimerKamelet(ns string, name string) func()
error {
Name: name,
},
Spec: v1alpha1.KameletSpec{
- Definition: v1alpha1.JSONSchemaProps{
+ Definition: &v1alpha1.JSONSchemaProps{
Properties:
map[string]v1alpha1.JSONSchemaProps{
"message": {
Type: "string",
diff --git a/pkg/apis/camel/v1alpha1/kamelet_types.go
b/pkg/apis/camel/v1alpha1/kamelet_types.go
index 252d733..7a1cef7 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_types.go
@@ -33,7 +33,7 @@ var (
// KameletSpec defines the desired state of Kamelet
type KameletSpec struct {
- Definition JSONSchemaProps `json:"definition,omitempty"`
+ Definition *JSONSchemaProps `json:"definition,omitempty"`
Sources []camelv1.SourceSpec `json:"sources,omitempty"`
Flow *camelv1.Flow `json:"flow,omitempty"`
Authorization *AuthorizationSpec
`json:"authorization,omitempty"`
diff --git a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
index 9741e33..bb1ef9e 100644
--- a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
@@ -600,7 +600,11 @@ func (in *KameletProperty) DeepCopy() *KameletProperty {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver,
writing into out. in must be non-nil.
func (in *KameletSpec) DeepCopyInto(out *KameletSpec) {
*out = *in
- in.Definition.DeepCopyInto(&out.Definition)
+ if in.Definition != nil {
+ in, out := &in.Definition, &out.Definition
+ *out = new(JSONSchemaProps)
+ (*in).DeepCopyInto(*out)
+ }
if in.Sources != nil {
in, out := &in.Sources, &out.Sources
*out = make([]v1.SourceSpec, len(*in))
diff --git a/pkg/kamelet/initialize.go b/pkg/kamelet/initialize.go
index 991b5bd..755c9fc 100644
--- a/pkg/kamelet/initialize.go
+++ b/pkg/kamelet/initialize.go
@@ -55,6 +55,10 @@ func Initialize(kamelet *v1alpha1.Kamelet)
(*v1alpha1.Kamelet, error) {
}
func recomputeProperties(kamelet *v1alpha1.Kamelet) error {
+ if kamelet.Spec.Definition == nil {
+ return nil
+ }
+
kamelet.Status.Properties = make([]v1alpha1.KameletProperty, 0,
len(kamelet.Spec.Definition.Properties))
propSet := make(map[string]bool)
for k, v := range kamelet.Spec.Definition.Properties {
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 390c754..6344160 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -18,7 +18,6 @@ limitations under the License.
package trait
import (
- "encoding/json"
"fmt"
"regexp"
"sort"
@@ -360,12 +359,6 @@ func integrationSourceFromKameletSource(e *Environment,
kamelet *v1alpha1.Kamele
}
// Create configmaps to avoid storing kamelet definitions in the
integration CR
-
- schema, err := json.Marshal(kamelet.Spec.Definition)
- if err != nil {
- return v1.SourceSpec{}, err
- }
-
// Compute the input digest and store it along with the configmap
hash, err := digest.ComputeForSource(source)
if err != nil {
@@ -395,7 +388,6 @@ func integrationSourceFromKameletSource(e *Environment,
kamelet *v1alpha1.Kamele
},
Data: map[string]string{
contentKey: source.Content,
- schemaKey: string(schema),
},
}