You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/03/01 14:34:44 UTC
[camel-k] 05/18: chore(api): Remove Flow from KameletSpec
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 51ef518a7e74b8585e6e880591933e263794a77b
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Jan 24 12:52:25 2022 +0100
chore(api): Remove Flow from KameletSpec
Ref #2751
---
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 28 ---------------
docs/modules/ROOT/partials/apis/crds-html.adoc | 29 +---------------
docs/modules/ROOT/partials/apis/kamelets-crds.adoc | 40 +++++++++++++++++++---
e2e/support/test_support.go | 8 ++---
pkg/apis/camel/v1/zz_generated.deepcopy.go | 7 ++++
pkg/apis/camel/v1alpha1/kamelet_types.go | 2 +-
pkg/apis/camel/v1alpha1/kamelet_types_support.go | 10 ------
pkg/kamelet/initialize.go | 9 -----
pkg/trait/kamelets.go | 3 +-
pkg/trait/kamelets_test.go | 26 +++++++-------
10 files changed, 62 insertions(+), 100 deletions(-)
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index d8df047..8d146da 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -1911,13 +1911,6 @@ Deprecated:
Use container trait (container.resources) to manage resources
Use openapi trait (openapi.configmaps) to manage OpenAPIs specifications
-|`kit` +
-string
-|
-
-
-Deprecated: use the IntegrationKit field
-
|`integrationKit` +
*https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#objectreference-v1-core[Kubernetes core/v1.ObjectReference]*
|
@@ -2523,7 +2516,6 @@ string
*Appears on:*
* <<#_camel_apache_org_v1_Flow, Flow>>
-* <<#_camel_apache_org_v1_Template, Template>>
* <<#_camel_apache_org_v1_TraitConfiguration, TraitConfiguration>>
RawMessage is a raw encoded JSON value.
@@ -2997,26 +2989,6 @@ Task --
|===
-[#_camel_apache_org_v1_Template]
-=== Template
-
-Template is an unstructured object representing a Kamelet template in YAML/JSON DSL
-
-[cols="2,2a",options="header"]
-|===
-|Field
-|Description
-
-|`RawMessage` +
-*xref:#_camel_apache_org_v1_RawMessage[RawMessage]*
-|(Members of `RawMessage` are embedded into this type.)
-
-
-
-
-
-|===
-
[#_camel_apache_org_v1_TraitConfiguration]
=== TraitConfiguration
diff --git a/docs/modules/ROOT/partials/apis/crds-html.adoc b/docs/modules/ROOT/partials/apis/crds-html.adoc
index c86feb7..3fe1de5 100644
--- a/docs/modules/ROOT/partials/apis/crds-html.adoc
+++ b/docs/modules/ROOT/partials/apis/crds-html.adoc
@@ -2078,8 +2078,7 @@ Kubernetes meta/v1.Time
</h3>
<p>
(<em>Appears on:</em>
-<a href="#camel.apache.org/v1.IntegrationSpec">IntegrationSpec</a>,
-<a href="#camel.apache.org/v1alpha1.KameletSpec">KameletSpec</a>)
+<a href="#camel.apache.org/v1.IntegrationSpec">IntegrationSpec</a>)
</p>
<div>
<p>Flow is an unstructured object representing a Camel Flow in YAML/JSON DSL</p>
@@ -5064,19 +5063,6 @@ Template
</tr>
<tr>
<td>
-<code>flow</code><br/>
-<em>
-<a href="#camel.apache.org/v1.Flow">
-Flow
-</a>
-</em>
-</td>
-<td>
-<p>Deprecated: use template</p>
-</td>
-</tr>
-<tr>
-<td>
<code>authorization</code><br/>
<em>
<a href="#camel.apache.org/v1alpha1.AuthorizationSpec">
@@ -6596,19 +6582,6 @@ Template
</tr>
<tr>
<td>
-<code>flow</code><br/>
-<em>
-<a href="#camel.apache.org/v1.Flow">
-Flow
-</a>
-</em>
-</td>
-<td>
-<p>Deprecated: use template</p>
-</td>
-</tr>
-<tr>
-<td>
<code>authorization</code><br/>
<em>
<a href="#camel.apache.org/v1alpha1.AuthorizationSpec">
diff --git a/docs/modules/ROOT/partials/apis/kamelets-crds.adoc b/docs/modules/ROOT/partials/apis/kamelets-crds.adoc
index 0a23dc2..3ca5d90 100644
--- a/docs/modules/ROOT/partials/apis/kamelets-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/kamelets-crds.adoc
@@ -112,7 +112,7 @@ BeanProperties represent an unstructured object properties to be set on a bean
|Description
|`RawMessage` +
-*xref:apis/camel-k.adoc#_camel_apache_org_v1_RawMessage[github.com/apache/camel-k/pkg/apis/camel/v1.RawMessage]*
+*xref:#_camel_apache_org_v1alpha1_RawMessage[RawMessage]*
|
@@ -182,7 +182,7 @@ EndpointProperties is a key/value struct represented as JSON raw to allow numeri
|Description
|`RawMessage` +
-*xref:apis/camel-k.adoc#_camel_apache_org_v1_RawMessage[github.com/apache/camel-k/pkg/apis/camel/v1.RawMessage]*
+*xref:#_camel_apache_org_v1alpha1_RawMessage[RawMessage]*
|(Members of `RawMessage` are embedded into this type.)
@@ -266,7 +266,7 @@ ErrorHandlerParameters represent an unstructured object for error handler parame
|Description
|`RawMessage` +
-*xref:apis/camel-k.adoc#_camel_apache_org_v1_RawMessage[github.com/apache/camel-k/pkg/apis/camel/v1.RawMessage]*
+*xref:#_camel_apache_org_v1alpha1_RawMessage[RawMessage]*
|
@@ -317,7 +317,7 @@ ErrorHandlerSpec represents an unstructured object for an error handler
|Description
|`RawMessage` +
-*xref:apis/camel-k.adoc#_camel_apache_org_v1_RawMessage[github.com/apache/camel-k/pkg/apis/camel/v1.RawMessage]*
+*xref:#_camel_apache_org_v1alpha1_RawMessage[RawMessage]*
|
@@ -1043,7 +1043,7 @@ KameletSpec defines the desired state of Kamelet
|`template` +
-*xref:apis/camel-k.adoc#_camel_apache_org_v1_Template[github.com/apache/camel-k/pkg/apis/camel/v1.Template]*
+*xref:#_camel_apache_org_v1alpha1_Template[Template]*
|
@@ -1123,8 +1123,38 @@ KameletStatus defines the observed state of Kamelet
*Appears on:*
+* <<#_camel_apache_org_v1alpha1_BeanProperties, BeanProperties>>
+* <<#_camel_apache_org_v1alpha1_EndpointProperties, EndpointProperties>>
+* <<#_camel_apache_org_v1alpha1_ErrorHandlerParameters, ErrorHandlerParameters>>
+* <<#_camel_apache_org_v1alpha1_ErrorHandlerSpec, ErrorHandlerSpec>>
* <<#_camel_apache_org_v1alpha1_JSON, JSON>>
+* <<#_camel_apache_org_v1alpha1_Template, Template>>
RawMessage is a raw encoded JSON value.
It implements Marshaler and Unmarshaler and can
be used to delay JSON decoding or precompute a JSON encoding.
+
+
+[#_camel_apache_org_v1alpha1_Template]
+=== Template
+
+*Appears on:*
+
+* <<#_camel_apache_org_v1alpha1_KameletSpec, KameletSpec>>
+
+Template is an unstructured object representing a Kamelet template in YAML/JSON DSL
+
+[cols="2,2a",options="header"]
+|===
+|Field
+|Description
+
+|`RawMessage` +
+*xref:#_camel_apache_org_v1alpha1_RawMessage[RawMessage]*
+|(Members of `RawMessage` are embedded into this type.)
+
+
+
+
+
+|===
\ No newline at end of file
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 9649525..fce51b8 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -1519,7 +1519,7 @@ func CreateKnativeChannel(ns string, name string) func() error {
Kamelets
*/
-func CreateKamelet(ns string, name string, flow map[string]interface{}, properties map[string]v1alpha1.JSONSchemaProp, labels map[string]string) func() error {
+func CreateKamelet(ns string, name string, template map[string]interface{}, properties map[string]v1alpha1.JSONSchemaProp, labels map[string]string) func() error {
return func() error {
kamelet := v1alpha1.Kamelet{
ObjectMeta: metav1.ObjectMeta{
@@ -1531,7 +1531,7 @@ func CreateKamelet(ns string, name string, flow map[string]interface{}, properti
Definition: &v1alpha1.JSONSchemaProps{
Properties: properties,
},
- Flow: asFlow(flow),
+ Template: asTemplate(template),
},
}
return TestClient().Create(TestContext, &kamelet)
@@ -1588,12 +1588,12 @@ func BindKameletToWithErrorHandler(ns string, name string, from corev1.ObjectRef
}
}
-func asFlow(source map[string]interface{}) *v1.Flow {
+func asTemplate(source map[string]interface{}) *v1.Template {
bytes, err := json.Marshal(source)
if err != nil {
panic(err)
}
- return &v1.Flow{
+ return &v1.Template{
RawMessage: bytes,
}
}
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 8aa48a4..01b27a7 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -439,6 +439,13 @@ func (in *CamelLoader) DeepCopyInto(out *CamelLoader) {
*out = make([]MavenArtifact, len(*in))
copy(*out, *in)
}
+ if in.Metadata != nil {
+ in, out := &in.Metadata, &out.Metadata
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CamelLoader.
diff --git a/pkg/apis/camel/v1alpha1/kamelet_types.go b/pkg/apis/camel/v1alpha1/kamelet_types.go
index 63895e0..c4b19b9 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_types.go
@@ -45,7 +45,7 @@ var (
type KameletSpec struct {
Definition *JSONSchemaProps `json:"definition,omitempty"`
Sources []camelv1.SourceSpec `json:"sources,omitempty"`
- Template *Template `json:"template,omitempty"`
+ Template *Template `json:"template,omitempty"`
// Deprecated: use template
Flow *camelv1.Flow `json:"flow,omitempty"`
Authorization *AuthorizationSpec `json:"authorization,omitempty"`
diff --git a/pkg/apis/camel/v1alpha1/kamelet_types_support.go b/pkg/apis/camel/v1alpha1/kamelet_types_support.go
index e363204..52635f2 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_types_support.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_types_support.go
@@ -192,16 +192,6 @@ func ValidKameletProperties(kamelet *Kamelet) bool {
return true
}
-func ValidKameletTemplate(kamelet *Kamelet) bool {
- if kamelet == nil {
- return true
- }
- if kamelet.Spec.Template != nil && kamelet.Spec.Flow != nil {
- return false
- }
- return true
-}
-
// NewKamelet creates a new kamelet
func NewKamelet(namespace string, name string) Kamelet {
return Kamelet{
diff --git a/pkg/kamelet/initialize.go b/pkg/kamelet/initialize.go
index 0ac666a..cb0a93b 100644
--- a/pkg/kamelet/initialize.go
+++ b/pkg/kamelet/initialize.go
@@ -50,15 +50,6 @@ func Initialize(kamelet *v1alpha1.Kamelet) (*v1alpha1.Kamelet, error) {
fmt.Sprintf("Kamelet property %q is reserved and cannot be part of the schema", v1alpha1.KameletIDProperty),
)
}
- if !v1alpha1.ValidKameletTemplate(kamelet) {
- ok = false
- target.Status.SetCondition(
- v1alpha1.KameletConditionReady,
- corev1.ConditionFalse,
- v1alpha1.KameletConditionReasonInvalidTemplate,
- `Kamelet can only specify one of "flow" or "template"`,
- )
- }
if !ok {
target.Status.Phase = v1alpha1.KameletPhaseError
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index a5c1c93..fd9ada3 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -254,8 +254,7 @@ func (t *kameletsTrait) configureApplicationProperties(e *Environment) error {
func (t *kameletsTrait) addKameletAsSource(e *Environment, kamelet *v1alpha1.Kamelet) error {
sources := make([]v1.SourceSpec, 0)
- // nolint: staticcheck
- if kamelet.Spec.Template != nil || kamelet.Spec.Flow != nil {
+ if kamelet.Spec.Template != nil {
template := kamelet.Spec.Template
if template == nil {
// Backward compatibility with Kamelets using flow
diff --git a/pkg/trait/kamelets_test.go b/pkg/trait/kamelets_test.go
index 69de59e..78e36d5 100644
--- a/pkg/trait/kamelets_test.go
+++ b/pkg/trait/kamelets_test.go
@@ -87,7 +87,7 @@ func TestKameletLookup(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -131,7 +131,7 @@ func TestKameletSecondarySourcesLookup(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -230,7 +230,7 @@ func TestMultipleKamelets(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -256,7 +256,7 @@ func TestMultipleKamelets(t *testing.T) {
Name: "logger",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "tbd:endpoint",
"steps": []interface{}{
@@ -325,7 +325,7 @@ func TestKameletConfigLookup(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -388,7 +388,7 @@ func TestKameletNamedConfigLookup(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -458,7 +458,7 @@ func TestKameletConditionFalse(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -497,7 +497,7 @@ func TestKameletConditionTrue(t *testing.T) {
Name: "timer",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -511,7 +511,7 @@ func TestKameletConditionTrue(t *testing.T) {
Name: "none",
},
Spec: v1alpha1.KameletSpec{
- Flow: marshalOrFail(map[string]interface{}{
+ Template: templateOrFail(map[string]interface{}{
"from": map[string]interface{}{
"uri": "timer:tick",
},
@@ -571,11 +571,11 @@ func createKameletsTestEnvironment(flow string, objects ...runtime.Object) (*kam
return trait, environment
}
-func marshalOrFail(flow map[string]interface{}) *v1.Flow {
- data, err := json.Marshal(flow)
+func templateOrFail(template map[string]interface{}) *v1.Template {
+ data, err := json.Marshal(template)
if err != nil {
panic(err)
}
- f := v1.Flow{RawMessage: data}
- return &f
+ t := v1.Template{RawMessage: data}
+ return &t
}