From 5520f3d592c7dd06c400e846c89d86591ce02901 Mon Sep 17 00:00:00 2001 From: Pasquale Congiusti Date: Fri, 27 Sep 2024 07:19:50 +0200 Subject: [PATCH] feat(trait): ServiceBinding deprecation Closes #5868 --- docs/modules/traits/pages/service-binding.adoc | 1 + pkg/apis/camel/v1/trait/service_binding.go | 4 ++++ pkg/trait/service_binding.go | 14 +++++++++++++- pkg/trait/service_binding_test.go | 4 +++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/modules/traits/pages/service-binding.adoc b/docs/modules/traits/pages/service-binding.adoc index 73582ad989..7ae2879ade 100755 --- a/docs/modules/traits/pages/service-binding.adoc +++ b/docs/modules/traits/pages/service-binding.adoc @@ -1,6 +1,7 @@ = Service Binding Trait // Start of autogenerated code - DO NOT EDIT! (badges) +image:https://img.shields.io/badge/2.5.0-white?label=Deprecated&labelColor=C40C0C&color=gray[Deprecated Badge] // End of autogenerated code - DO NOT EDIT! (badges) // Start of autogenerated code - DO NOT EDIT! (description) The Service Binding trait allows users to connect to Services in Kubernetes: diff --git a/pkg/apis/camel/v1/trait/service_binding.go b/pkg/apis/camel/v1/trait/service_binding.go index 97e758fe4b..82aff8e013 100644 --- a/pkg/apis/camel/v1/trait/service_binding.go +++ b/pkg/apis/camel/v1/trait/service_binding.go @@ -17,11 +17,15 @@ limitations under the License. package trait +// WARNING: The Registry trait is **deprecated** and will removed in future release versions. +// + // The Service Binding trait allows users to connect to Services in Kubernetes: // https://github.com/k8s-service-bindings/spec#service-binding // As the specification is still evolving this is subject to change. // // +camel-k:trait=service-binding. +// +camel-k:deprecated=2.5.0. type ServiceBindingTrait struct { Trait `property:",squash" json:",inline"` // List of Services in the form [[apigroup/]version:]kind:[namespace/]name diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go index b8fd4ba45e..def9c6d628 100644 --- a/pkg/trait/service_binding.go +++ b/pkg/trait/service_binding.go @@ -78,7 +78,19 @@ func (t *serviceBindingTrait) Configure(e *Environment) (bool, *TraitCondition, return false, nil, nil } - return e.IntegrationInPhase(v1.IntegrationPhaseInitialization) || e.IntegrationInRunningPhases(), nil, nil + var condition *TraitCondition + enabled := e.IntegrationInPhase(v1.IntegrationPhaseInitialization) || e.IntegrationInRunningPhases() + if enabled { + condition = NewIntegrationCondition( + "ServiceBinding", + v1.IntegrationConditionTraitInfo, + corev1.ConditionTrue, + traitConfigurationReason, + "ServiceBinding trait is deprecated as the Service Binding Operator is no longer supported. It may be removed in future version.", + ) + } + + return enabled, condition, nil } func (t *serviceBindingTrait) Apply(e *Environment) error { diff --git a/pkg/trait/service_binding_test.go b/pkg/trait/service_binding_test.go index 81831d0f19..545b38b0b7 100644 --- a/pkg/trait/service_binding_test.go +++ b/pkg/trait/service_binding_test.go @@ -39,7 +39,9 @@ func TestServiceBinding(t *testing.T) { assert.True(t, configured) require.NoError(t, err) - assert.Nil(t, condition) + assert.NotNil(t, condition) + assert.Equal(t, "ServiceBinding trait is deprecated as the Service Binding Operator is no longer supported. It may be removed in future version.", + condition.message) // Required for local testing purposes only handlers = []pipeline.Handler{}