johnpoth commented on a change in pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#discussion_r708209763



##########
File path: pkg/trait/service_binding.go
##########
@@ -53,137 +54,65 @@ func (t *serviceBindingTrait) Configure(e *Environment) 
(bool, error) {
                return false, nil
        }
 
-       if len(t.ServiceBindings) == 0 {
+       if len(t.Services) == 0 {
                return false, nil
        }
 
        return e.IntegrationInPhase(
                v1.IntegrationPhaseInitialization,
-               v1.IntegrationPhaseWaitingForBindings,
                v1.IntegrationPhaseDeploying,
                v1.IntegrationPhaseRunning,
        ), nil
 }
 
 func (t *serviceBindingTrait) Apply(e *Environment) error {
-       services, err := t.parseProvisionedServices(e)
+       ctx, err := t.getContext(e)
        if err != nil {
                return err
        }
-       serviceBindings, err := t.parseServiceBindings(e)
+       // let the SBO retry policy be controlled by Camel-k
+       err = process(ctx, getHandlers())
        if err != nil {
                return err
        }
-       if len(services) > 0 {
-               serviceBindings = append(serviceBindings, e.Integration.Name)
-       }
-       if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
-               serviceBindingsCollectionReady := true
-               for _, name := range serviceBindings {
-                       isIntSB := name == e.Integration.Name
-                       serviceBinding, err := t.getServiceBinding(e, name)
-                       // Do not throw an error if the ServiceBinding is not 
found and if we are managing it: we will create it
-                       if (err != nil && !k8serrors.IsNotFound(err)) || (err 
!= nil && !isIntSB) {
-                               return err
-                       }
-                       if isIntSB {
-                               request := createServiceBinding(e, services, 
e.Integration.Name)
-                               e.Resources.Add(&request)
-                       }
-                       if isCollectionReady(serviceBinding) {
-                               setCollectionReady(e, name, 
corev1.ConditionTrue)
-                       } else {
-                               setCollectionReady(e, name, 
corev1.ConditionFalse)
-                               serviceBindingsCollectionReady = false
-                       }
-               }
-               if !serviceBindingsCollectionReady {
-                       e.PostProcessors = append(e.PostProcessors, 
func(environment *Environment) error {
-                               e.Integration.Status.Phase = 
v1.IntegrationPhaseWaitingForBindings
-                               return nil
-                       })
-               }
-               return nil
-       } else if e.IntegrationInPhase(v1.IntegrationPhaseWaitingForBindings) {
-               for _, name := range serviceBindings {
-                       serviceBinding, err := t.getServiceBinding(e, name)
-                       if err != nil {
-                               return err
-                       }
-                       if isCollectionReady(serviceBinding) {
-                               setCollectionReady(e, name, 
corev1.ConditionTrue)
-                       } else {
-                               setCollectionReady(e, name, 
corev1.ConditionFalse)
-                               return nil
-                       }
-                       if name == e.Integration.Name {
-                               request := createServiceBinding(e, services, 
name)
-                               e.Resources.Add(&request)
-                       }
-               }
-       } else if e.IntegrationInPhase(v1.IntegrationPhaseDeploying, 
v1.IntegrationPhaseRunning) {
-               e.ServiceBindings = make(map[string]string)
-               for _, name := range serviceBindings {
-                       sb, err := t.getServiceBinding(e, name)
-                       if err != nil {
-                               return err
-                       }
-                       if !isCollectionReady(sb) {
-                               setCollectionReady(e, name, 
corev1.ConditionFalse)
-                               e.PostProcessors = append(e.PostProcessors, 
func(environment *Environment) error {
-                                       e.Integration.Status.Phase = 
v1.IntegrationPhaseWaitingForBindings
-                                       return nil
-                               })
-                               return nil
-                       }
-                       e.ServiceBindings[name] = sb.Status.Secret
-                       if name == e.Integration.Name {
-                               request := createServiceBinding(e, services, 
name)
-                               e.Resources.Add(&request)
-                       }
-               }
+
+       secret := createSecret(ctx, e.Integration.Namespace)
+       if secret != nil {

Review comment:
       Hi @pedjak ! Thanks for taking a look!
   
   The Camel K Operator has it's own pipeline for creating Kubernetes resources 
(here the `Secret`). This allows to do versioning and garbage collection when 
those resources aren't needed anymore. This is why I didn't want SBO to create 
the `Secret` through it's default pipeline. I also didn't want it to create the 
"ServiceBinding" CR as it's not really needed in our "simple" case.
   
   All in all it was a pretty fluid experience using the API




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to