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


The following commit(s) were added to refs/heads/main by this push:
     new ea9fb039e fix(api): deprecate .spec.integration Pipe
ea9fb039e is described below

commit ea9fb039e862775669afd74368fe09cd844d0e8d
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Thu Oct 5 15:56:59 2023 +0200

    fix(api): deprecate .spec.integration Pipe
    
    Closes #4780
---
 config/crd/bases/camel.apache.org_pipes.yaml      |  3 ++-
 docs/modules/ROOT/partials/apis/camel-k-crds.adoc |  1 +
 helm/camel-k/crds/crd-pipe.yaml                   |  3 ++-
 pkg/apis/camel/v1/pipe_types.go                   |  3 +++
 pkg/controller/pipe/initialize.go                 | 11 ++++++++++-
 pkg/controller/pipe/integration.go                |  1 +
 pkg/controller/pipe/monitor.go                    |  9 +++++++++
 7 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/config/crd/bases/camel.apache.org_pipes.yaml 
b/config/crd/bases/camel.apache.org_pipes.yaml
index 5bf2d8ff0..c8c5b8ea8 100644
--- a/config/crd/bases/camel.apache.org_pipes.yaml
+++ b/config/crd/bases/camel.apache.org_pipes.yaml
@@ -74,7 +74,8 @@ spec:
                 x-kubernetes-preserve-unknown-fields: true
               integration:
                 description: Integration is an optional integration used to 
specify
-                  custom parameters
+                  custom parameters Deprecated don't use this. Use trait 
annotations
+                  if you need to change any cluster configuration.
                 properties:
                   configuration:
                     description: 'Deprecated: Use camel trait 
(camel.properties) to
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc 
b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 39fe3ed4c..a9070f7c7 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -4218,6 +4218,7 @@ PipeSpec defines the binding between a source and a sink. 
It can include custom
 
 
 Integration is an optional integration used to specify custom parameters
+Deprecated don't use this. Use trait annotations if you need to change any 
cluster configuration.
 
 |`source` +
 *xref:#_camel_apache_org_v1_Endpoint[Endpoint]*
diff --git a/helm/camel-k/crds/crd-pipe.yaml b/helm/camel-k/crds/crd-pipe.yaml
index 5bf2d8ff0..c8c5b8ea8 100644
--- a/helm/camel-k/crds/crd-pipe.yaml
+++ b/helm/camel-k/crds/crd-pipe.yaml
@@ -74,7 +74,8 @@ spec:
                 x-kubernetes-preserve-unknown-fields: true
               integration:
                 description: Integration is an optional integration used to 
specify
-                  custom parameters
+                  custom parameters Deprecated don't use this. Use trait 
annotations
+                  if you need to change any cluster configuration.
                 properties:
                   configuration:
                     description: 'Deprecated: Use camel trait 
(camel.properties) to
diff --git a/pkg/apis/camel/v1/pipe_types.go b/pkg/apis/camel/v1/pipe_types.go
index 369e8626f..74bf55626 100644
--- a/pkg/apis/camel/v1/pipe_types.go
+++ b/pkg/apis/camel/v1/pipe_types.go
@@ -46,6 +46,7 @@ type Pipe struct {
 // PipeSpec defines the binding between a source and a sink. It can include 
custom parameters and additional intermediate steps and error handling.
 type PipeSpec struct {
        // Integration is an optional integration used to specify custom 
parameters
+       // Deprecated don't use this. Use trait annotations if you need to 
change any cluster configuration.
        Integration *IntegrationSpec `json:"integration,omitempty"`
        // Source is the starting point of the integration defined by this Pipe
        Source Endpoint `json:"source,omitempty"`
@@ -132,6 +133,8 @@ const (
        PipeConditionReady PipeConditionType = "Ready"
        // PipeIntegrationConditionError is used to report the error on the 
generated Integration.
        PipeIntegrationConditionError PipeConditionType = "IntegrationError"
+       // PipeIntegrationDeprecationNotice is used to report the usage of a 
deprecated resource.
+       PipeIntegrationDeprecationNotice PipeConditionType = "DeprecationNotice"
 )
 
 // PipePhase --.
diff --git a/pkg/controller/pipe/initialize.go 
b/pkg/controller/pipe/initialize.go
index 35b5c56f0..4cec1faf4 100644
--- a/pkg/controller/pipe/initialize.go
+++ b/pkg/controller/pipe/initialize.go
@@ -54,6 +54,15 @@ func (action *initializeAction) CanHandle(binding *v1.Pipe) 
bool {
 func (action *initializeAction) Handle(ctx context.Context, binding *v1.Pipe) 
(*v1.Pipe, error) {
        action.L.Info("Initializing Pipe")
 
+       if binding.Spec.Integration != nil {
+               action.L.Infof("Pipe %s is using deprecated .spec.integration 
parameter. Please, update and use annotation traits instead", binding.Name)
+               binding.Status.SetCondition(
+                       v1.PipeIntegrationDeprecationNotice,
+                       corev1.ConditionTrue,
+                       ".spec.integration parameter is deprecated",
+                       ".spec.integration parameter is deprecated. Use 
annotation traits instead",
+               )
+       }
        it, err := CreateIntegrationFor(ctx, action.client, binding)
        if err != nil {
                binding.Status.Phase = v1.PipePhaseError
@@ -63,7 +72,7 @@ func (action *initializeAction) Handle(ctx context.Context, 
binding *v1.Pipe) (*
        }
 
        if _, err := kubernetes.ReplaceResource(ctx, action.client, it); err != 
nil {
-               return nil, fmt.Errorf("could not create integration forPipe: 
%w", err)
+               return nil, fmt.Errorf("could not create integration for Pipe: 
%w", err)
        }
 
        // propagate Kamelet icon (best effort)
diff --git a/pkg/controller/pipe/integration.go 
b/pkg/controller/pipe/integration.go
index 9d21e1c41..cf25f0722 100644
--- a/pkg/controller/pipe/integration.go
+++ b/pkg/controller/pipe/integration.go
@@ -75,6 +75,7 @@ func CreateIntegrationFor(ctx context.Context, c 
client.Client, binding *v1.Pipe
        it.GetLabels()[kubernetes.CamelCreatorLabelKind] = binding.Kind
        it.GetLabels()[kubernetes.CamelCreatorLabelName] = binding.Name
 
+       // Deprecated
        // start from the integration spec defined in the binding
        if binding.Spec.Integration != nil {
                it.Spec = *binding.Spec.Integration.DeepCopy()
diff --git a/pkg/controller/pipe/monitor.go b/pkg/controller/pipe/monitor.go
index a2bff2456..292add27a 100644
--- a/pkg/controller/pipe/monitor.go
+++ b/pkg/controller/pipe/monitor.go
@@ -82,6 +82,15 @@ func (action *monitorAction) Handle(ctx context.Context, 
binding *v1.Pipe) (*v1.
 
        // Check if the integration needs to be changed
        expected, err := CreateIntegrationFor(ctx, action.client, binding)
+       if binding.Spec.Integration != nil {
+               action.L.Infof("Pipe %s is using deprecated .spec.integration 
parameter. Please, update and use annotation traits instead", binding.Name)
+               binding.Status.SetCondition(
+                       v1.PipeIntegrationDeprecationNotice,
+                       corev1.ConditionTrue,
+                       ".spec.integration parameter is deprecated",
+                       ".spec.integration parameter is deprecated. Use 
annotation traits instead",
+               )
+       }
        if err != nil {
                binding.Status.Phase = v1.PipePhaseError
                
binding.Status.SetErrorCondition(v1.PipeIntegrationConditionError,

Reply via email to