This is an automated email from the ASF dual-hosted git repository.

cdeppisch 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 82df6091b fix(#3433): Platform trait create default option
82df6091b is described below

commit 82df6091b5e99abb5c564ce8e63c3074868990a7
Author: Christoph Deppisch <cdeppi...@redhat.com>
AuthorDate: Tue Feb 20 15:29:16 2024 +0100

    fix(#3433): Platform trait create default option
    
    - Deprecate option to create default integration platform as part of the 
trait
    - Option to create default integration platform needs to be explicitly 
enabled (e.g. with auto=true, create-default=true)
    - Usually platform gets automatically created already as part of the 
operator installation startup procedure
    - Fix trait documentation
---
 pkg/apis/camel/v1/trait/platform.go |  5 ++++-
 pkg/trait/platform.go               | 39 +++++++++++++++++--------------------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/pkg/apis/camel/v1/trait/platform.go 
b/pkg/apis/camel/v1/trait/platform.go
index 116de6ad0..3d31ab1d0 100644
--- a/pkg/apis/camel/v1/trait/platform.go
+++ b/pkg/apis/camel/v1/trait/platform.go
@@ -27,9 +27,12 @@ package trait
 type PlatformTrait struct {
        PlatformBaseTrait `property:",squash" json:",inline"`
        // To create a default (empty) platform when the platform is missing.
+       // Deprecated: Platform is auto generated by the operator install 
procedure - maintained for backward compatibility
        CreateDefault *bool `property:"create-default" 
json:"createDefault,omitempty"`
        // Indicates if the platform should be created globally in the case of 
global operator (default true).
+       // Deprecated: Platform is auto generated by the operator install 
procedure - maintained for backward compatibility
        Global *bool `property:"global" json:"global,omitempty"`
-       // To automatically detect from the environment if a default platform 
can be created (it will be created on OpenShift only).
+       // To automatically detect from the environment if a default platform 
can be created (it will be created on OpenShift or when a registry address is 
set).
+       // Deprecated: Platform is auto generated by the operator install 
procedure - maintained for backward compatibility
        Auto *bool `property:"auto" json:"auto,omitempty"`
 }
diff --git a/pkg/trait/platform.go b/pkg/trait/platform.go
index ec3fb1e04..397310501 100644
--- a/pkg/trait/platform.go
+++ b/pkg/trait/platform.go
@@ -44,7 +44,8 @@ func newPlatformTrait() Trait {
 }
 
 func (t *platformTrait) Configure(e *Environment) (bool, *TraitCondition, 
error) {
-       if e.Integration == nil {
+       if e.Integration == nil || e.Integration.IsSynthetic() {
+               // Don't run this trait for a synthetic integration
                return false, nil, nil
        }
 
@@ -52,29 +53,25 @@ func (t *platformTrait) Configure(e *Environment) (bool, 
*TraitCondition, error)
                return false, nil, nil
        }
 
-       if !pointer.BoolDeref(t.Auto, false) {
-               if e.Platform == nil {
-                       if t.CreateDefault == nil {
-                               // Calculate if the platform should be 
automatically created when missing.
-                               if ocp, err := openshift.IsOpenShift(t.Client); 
err != nil {
-                                       return false, nil, err
-                               } else if ocp {
-                                       t.CreateDefault = &ocp
-                               } else if addr, err := 
image.GetRegistryAddress(e.Ctx, t.Client); err != nil {
-                                       return false, nil, err
-                               } else if addr != nil {
-                                       t.CreateDefault = pointer.Bool(true)
-                               }
-                       }
-                       if t.Global == nil {
-                               globalOperator := 
platform.IsCurrentOperatorGlobal()
-                               t.Global = &globalOperator
-                       }
+       if t.CreateDefault == nil && pointer.BoolDeref(t.Auto, false) && 
e.Platform == nil {
+               // Calculate if the platform should be automatically created 
when missing.
+               if ocp, err := openshift.IsOpenShift(t.Client); err != nil {
+                       return false, nil, err
+               } else if ocp {
+                       t.CreateDefault = pointer.Bool(true)
+               } else if addr, err := image.GetRegistryAddress(e.Ctx, 
t.Client); err != nil {
+                       return false, nil, err
+               } else if addr != nil {
+                       t.CreateDefault = pointer.Bool(true)
                }
        }
 
-       // Don't run this trait for a synthetic Integration
-       return e.Integration == nil || !e.Integration.IsSynthetic(), nil, nil
+       if t.Global == nil {
+               globalOperator := platform.IsCurrentOperatorGlobal()
+               t.Global = &globalOperator
+       }
+
+       return true, nil, nil
 }
 
 func (t *platformTrait) Apply(e *Environment) error {

Reply via email to