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

astefanutti pushed a commit to branch release-1.4.x
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 55197ab6b4085b6a38773d2a61a8ae4ef6945b7b
Author: Pasquale Congiusti <pasquale.congiu...@gmail.com>
AuthorDate: Fri Apr 23 15:01:46 2021 +0200

    feat(trait): error handler bean
    
    Adding capability to support a bean as expected by Camel Main  - 
https://camel.apache.org/components/3.7.x/others/main.html#_specifying_custom_beans
---
 pkg/apis/camel/v1alpha1/error_handler_types.go     | 113 +++++++++++----------
 pkg/apis/camel/v1alpha1/kamelet_binding_types.go   |   2 +-
 pkg/controller/kameletbinding/error_handler.go     |  16 +--
 .../kameletbinding/error_handler_test.go           |  16 +++
 pkg/resources/resources.go                         |  44 ++++----
 pkg/trait/error_handler.go                         |  29 +++---
 6 files changed, 126 insertions(+), 94 deletions(-)

diff --git a/pkg/apis/camel/v1alpha1/error_handler_types.go 
b/pkg/apis/camel/v1alpha1/error_handler_types.go
index 949fbd6..1969e2b 100644
--- a/pkg/apis/camel/v1alpha1/error_handler_types.go
+++ b/pkg/apis/camel/v1alpha1/error_handler_types.go
@@ -21,56 +21,72 @@ import (
        v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
 )
 
-// ErrorHandler represents an unstructured object for an error handler
-type ErrorHandler struct {
+// ErrorHandlerSpec represents an unstructured object for an error handler
+type ErrorHandlerSpec struct {
        v1.RawMessage `json:",omitempty"`
 }
 
-// ErrorHandlerProperties represent an unstructured object for error handler 
parameters
-type ErrorHandlerProperties struct {
+// ErrorHandlerParameters represent an unstructured object for error handler 
parameters
+type ErrorHandlerParameters struct {
        v1.RawMessage `json:",inline"`
 }
 
-// AbstractErrorHandler is a generic interface that represent any type of 
error handler specification
-type AbstractErrorHandler interface {
+// BeanProperties represent an unstructured object properties to be set on a 
bean
+type BeanProperties struct {
+       v1.RawMessage `json:",inline"`
+}
+
+// ErrorHandler is a generic interface that represent any type of error 
handler specification
+type ErrorHandler interface {
        Type() ErrorHandlerType
-       Params() *ErrorHandlerProperties
+       Params() *ErrorHandlerParameters
        Endpoint() *Endpoint
        Ref() *string
+       Bean() *string
 }
 
-// ErrorHandlerNone --
-type ErrorHandlerNone struct {
-}
-
-// NewErrorHandlerNone represents a no (ignore) error handler type
-func NewErrorHandlerNone() ErrorHandlerNone {
-       return ErrorHandlerNone{}
+type abstractErrorHandler struct {
 }
 
 // Type --
-func (e ErrorHandlerNone) Type() ErrorHandlerType {
-       return ErrorHandlerTypeNone
+func (e abstractErrorHandler) Type() ErrorHandlerType {
+       return errorHandlerTypeAbstract
 }
 
 // Params --
-func (e ErrorHandlerNone) Params() *ErrorHandlerProperties {
+func (e abstractErrorHandler) Params() *ErrorHandlerParameters {
        return nil
 }
 
 // Endpoint --
-func (e ErrorHandlerNone) Endpoint() *Endpoint {
+func (e abstractErrorHandler) Endpoint() *Endpoint {
        return nil
 }
 
 // Ref --
-func (e ErrorHandlerNone) Ref() *string {
+func (e abstractErrorHandler) Ref() *string {
        return nil
 }
 
+// Ref --
+func (e abstractErrorHandler) Bean() *string {
+       return nil
+}
+
+// ErrorHandlerNone --
+type ErrorHandlerNone struct {
+       *abstractErrorHandler
+}
+
+// Type --
+func (e ErrorHandlerNone) Type() ErrorHandlerType {
+       return ErrorHandlerTypeNone
+}
+
 // ErrorHandlerLog represent a default (log) error handler type
 type ErrorHandlerLog struct {
-       Parameters *ErrorHandlerProperties `json:"parameters,omitempty"`
+       *abstractErrorHandler
+       Parameters *ErrorHandlerParameters `json:"parameters,omitempty"`
 }
 
 // Type --
@@ -79,20 +95,10 @@ func (e ErrorHandlerLog) Type() ErrorHandlerType {
 }
 
 // Params --
-func (e ErrorHandlerLog) Params() *ErrorHandlerProperties {
+func (e ErrorHandlerLog) Params() *ErrorHandlerParameters {
        return e.Parameters
 }
 
-// Endpoint --
-func (e ErrorHandlerLog) Endpoint() *Endpoint {
-       return nil
-}
-
-// Ref --
-func (e ErrorHandlerLog) Ref() *string {
-       return nil
-}
-
 // ErrorHandlerDeadLetterChannel represents a dead letter channel error 
handler type
 type ErrorHandlerDeadLetterChannel struct {
        *ErrorHandlerLog
@@ -104,49 +110,50 @@ func (e ErrorHandlerDeadLetterChannel) Type() 
ErrorHandlerType {
        return ErrorHandlerTypeDeadLetterChannel
 }
 
-// Params --
-func (e ErrorHandlerDeadLetterChannel) Params() *ErrorHandlerProperties {
-       return e.Parameters
-}
-
 // Endpoint --
 func (e ErrorHandlerDeadLetterChannel) Endpoint() *Endpoint {
        return e.DLCEndpoint
 }
 
-// Ref --
-func (e ErrorHandlerDeadLetterChannel) Ref() *string {
-       return nil
-}
-
 // ErrorHandlerRef represents a reference to an error handler builder 
available in the registry
-type ErrorHandlerRef string
+type ErrorHandlerRef struct {
+       *abstractErrorHandler
+       string
+}
 
 // Type --
 func (e ErrorHandlerRef) Type() ErrorHandlerType {
        return ErrorHandlerTypeRef
 }
 
-// Params --
-func (e ErrorHandlerRef) Params() *ErrorHandlerProperties {
-       return nil
+// Ref --
+func (e ErrorHandlerRef) Ref() *string {
+       s := string(e.string)
+       return &s
 }
 
-// Endpoint --
-func (e ErrorHandlerRef) Endpoint() *Endpoint {
-       return nil
+// ErrorHandlerBean represents a bean error handler type
+type ErrorHandlerBean struct {
+       *ErrorHandlerLog
+       BeanType   *string         `json:"type,omitempty"`
+       Properties *BeanProperties `json:"properties,omitempty"`
 }
 
-// Ref --
-func (e ErrorHandlerRef) Ref() *string {
-       s := string(e)
-       return &s
+// Type --
+func (e ErrorHandlerBean) Type() ErrorHandlerType {
+       return ErrorHandlerTypeBean
+}
+
+// Bean --
+func (e ErrorHandlerBean) Bean() *string {
+       return e.BeanType
 }
 
 // ErrorHandlerType --
 type ErrorHandlerType string
 
 const (
+       errorHandlerTypeAbstract ErrorHandlerType = ""
        // ErrorHandlerTypeNone --
        ErrorHandlerTypeNone ErrorHandlerType = "none"
        // ErrorHandlerTypeLog --
@@ -155,4 +162,6 @@ const (
        ErrorHandlerTypeDeadLetterChannel ErrorHandlerType = 
"dead-letter-channel"
        // ErrorHandlerTypeRef --
        ErrorHandlerTypeRef ErrorHandlerType = "ref"
+       // ErrorHandlerTypeBean --
+       ErrorHandlerTypeBean ErrorHandlerType = "bean"
 )
diff --git a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go 
b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
index 62e8079..cfe8779 100644
--- a/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
+++ b/pkg/apis/camel/v1alpha1/kamelet_binding_types.go
@@ -33,7 +33,7 @@ type KameletBindingSpec struct {
        // Sink is the destination of the integration defined by this binding
        Sink Endpoint `json:"sink,omitempty"`
        // ErrorHandler is an optional handler called upon an error occuring in 
the integration
-       ErrorHandler ErrorHandler `json:"errorHandler,omitempty"`
+       ErrorHandler ErrorHandlerSpec `json:"errorHandler,omitempty"`
        // Steps contains an optional list of intermediate steps that are 
executed between the Source and the Sink
        Steps []Endpoint `json:"steps,omitempty"`
 }
diff --git a/pkg/controller/kameletbinding/error_handler.go 
b/pkg/controller/kameletbinding/error_handler.go
index c9858f9..15e72bb 100644
--- a/pkg/controller/kameletbinding/error_handler.go
+++ b/pkg/controller/kameletbinding/error_handler.go
@@ -26,7 +26,7 @@ import (
        "github.com/pkg/errors"
 )
 
-func maybeErrorHandler(errHandlConf v1alpha1.ErrorHandler, bindingContext 
bindings.BindingContext, itSpec *v1.IntegrationSpec) (*bindings.Binding, error) 
{
+func maybeErrorHandler(errHandlConf v1alpha1.ErrorHandlerSpec, bindingContext 
bindings.BindingContext, itSpec *v1.IntegrationSpec) (*bindings.Binding, error) 
{
        var errorHandler *bindings.Binding
        if errHandlConf.RawMessage != nil {
                errorHandlerSpec, err := 
parseErrorHandler(errHandlConf.RawMessage)
@@ -41,10 +41,10 @@ func maybeErrorHandler(errHandlConf v1alpha1.ErrorHandler, 
bindingContext bindin
                        }
 
                        errorHandlerURI = errorHandler.URI
-               }
-
-               if errorHandlerSpec.Type() == v1alpha1.ErrorHandlerTypeRef {
+               } else if errorHandlerSpec.Type() == 
v1alpha1.ErrorHandlerTypeRef {
                        errorHandlerURI = *errorHandlerSpec.Ref()
+               } else if errorHandlerSpec.Type() == 
v1alpha1.ErrorHandlerTypeBean {
+                       errorHandlerURI = *errorHandlerSpec.Bean()
                }
 
                err = setIntegrationErrorHandler(itSpec, errorHandlerURI, 
errorHandlerSpec)
@@ -57,7 +57,7 @@ func maybeErrorHandler(errHandlConf v1alpha1.ErrorHandler, 
bindingContext bindin
        return nil, nil
 }
 
-func parseErrorHandler(rawMessage v1.RawMessage) 
(v1alpha1.AbstractErrorHandler, error) {
+func parseErrorHandler(rawMessage v1.RawMessage) (v1alpha1.ErrorHandler, 
error) {
        var properties map[v1alpha1.ErrorHandlerType]v1.RawMessage
        err := json.Unmarshal(rawMessage, &properties)
        if err != nil {
@@ -68,7 +68,7 @@ func parseErrorHandler(rawMessage v1.RawMessage) 
(v1alpha1.AbstractErrorHandler,
        }
 
        for errHandlType, errHandlValue := range properties {
-               var dst v1alpha1.AbstractErrorHandler
+               var dst v1alpha1.ErrorHandler
                switch errHandlType {
                case v1alpha1.ErrorHandlerTypeNone:
                        dst = new(v1alpha1.ErrorHandlerNone)
@@ -78,6 +78,8 @@ func parseErrorHandler(rawMessage v1.RawMessage) 
(v1alpha1.AbstractErrorHandler,
                        dst = new(v1alpha1.ErrorHandlerDeadLetterChannel)
                case v1alpha1.ErrorHandlerTypeRef:
                        dst = new(v1alpha1.ErrorHandlerRef)
+               case v1alpha1.ErrorHandlerTypeBean:
+                       dst = new(v1alpha1.ErrorHandlerBean)
                default:
                        return nil, errors.Errorf("Unknown error type %s, 
supported error types are: none, log, dead-letter-channel", errHandlType)
                }
@@ -93,7 +95,7 @@ func parseErrorHandler(rawMessage v1.RawMessage) 
(v1alpha1.AbstractErrorHandler,
        return nil, errors.New("You must provide any supported error handler 
(none, log, dead-letter-channel)")
 }
 
-func setIntegrationErrorHandler(it *v1.IntegrationSpec, errorHandlerURI 
string, errorHandlerSpec v1alpha1.AbstractErrorHandler) error {
+func setIntegrationErrorHandler(it *v1.IntegrationSpec, errorHandlerURI 
string, errorHandlerSpec v1alpha1.ErrorHandler) error {
        it.ErrorHandler = v1.ErrorHandlerSpec{
                Type: string(errorHandlerSpec.Type()),
        }
diff --git a/pkg/controller/kameletbinding/error_handler_test.go 
b/pkg/controller/kameletbinding/error_handler_test.go
index 1600707..40864b9 100644
--- a/pkg/controller/kameletbinding/error_handler_test.go
+++ b/pkg/controller/kameletbinding/error_handler_test.go
@@ -75,3 +75,19 @@ func TestParseErrorHandlerDLCWithParametersDoesSucceed(t 
*testing.T) {
        assert.Equal(t, "someUri", *dlcErrorHandler.Endpoint().URI)
        assert.NotNil(t, dlcErrorHandler.Params())
 }
+
+func TestParseErrorHandlerBeanWithParametersDoesSucceed(t *testing.T) {
+       beanErrorHandler, err := parseErrorHandler(
+               []byte(`{
+                       "bean": {
+                               "type": "com.acme.MyType", 
+                               "parameters": 
+                                       [{"param1": "value1"}]
+                       }
+               }`),
+       )
+       assert.Nil(t, err)
+       assert.Equal(t, v1alpha1.ErrorHandlerTypeBean, beanErrorHandler.Type())
+       assert.Equal(t, "com.acme.MyType", *beanErrorHandler.Bean())
+       assert.NotNil(t, beanErrorHandler.Params())
+}
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 2108e19..697a0b7 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -106,16 +106,16 @@ var assets = func() http.FileSystem {
                "/crd/bases/camel.apache.org_integrations.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             "camel.apache.org_integrations.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 23405,
+                       uncompressedSize: 24066,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x3c\x5d\x73\xdb\xba\x95\xef\xfa\x15\x67\xec\x87\xdc\xcc\x48\x54\x93\xb4\xb3\x3b\xde\x27\xd7\x89\x77\xb5\xf1\xb5\x33\x96\xd3\x3b\x77\x3a\x7d\x80\xc8\x43\x0a\x35\x08\x70\x01\xd0\xb2\xda\xe9\x7f\xdf\x39\x07\x24\x45\x4a\xa4\xac\xc8\xb9\xf7\x76\xbb\xe2\x4b\x62\x12\x38\x38\xdf\x5f\x00\x74\x0e\x93\xef\xf7\x8c\xce\xe1\x46\xc6\xa8\x1d\x26\xe0\x0d\xf8\x25\xc2\x65\x21\xe2\x25\xc2\xdc\xa4\x7e\x25\x2c\xc2\xb5\x29\x75\x22\xbc\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x3c\x5d\x73\xe3\xb8\x91\xef\xfa\x15\x5d\xf6\xc3\xec\x56\x49\x54\x66\x26\xa9\xbb\xf2\x3d\x79\x3d\x33\x17\xdd\x78\x6d\x97\xe5\xc9\xd6\x56\x2a\x0f\x10\xd9\x12\x11\x83\x00\x0f\x00\x25\x2b\xa9\xfc\xf7\xab\x6e\x90\x14\x29\x91\xb4\xc6\x9e\xdd\xcd\x25\xe2\xcb\x8c\x49\xa0\xd1\xdf\x5f\x00\x74\x0e\x93\x6f\xf7\x8c\xce\xe1\x5a\xc6\xa8\x1d\x26\xe0\x0d\xf8\x14\xe1\x32\x17\x71\x8a\x30\x37\x4b\xbf\x11\x16\xe1\x93\x29\x74\x22\xbc\x
 [...]
                },
                "/crd/bases/camel.apache.org_kameletbindings.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             
"camel.apache.org_kameletbindings.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 55181,
+                       uncompressedSize: 56150,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\xf1\x6f\xdb\x38\xf2\xef\xef\xf9\x2b\x06\xc9\x01\x6d\x01\x4b\x8e\xe3\xb4\xbb\xeb\xf7\x43\x91\x26\xdb\x7b\x7e\xed\xa6\x45\x92\xde\xe1\x5e\xdb\x03\x68\x69\x6c\xf3\x22\x91\x3a\x92\x8a\xe3\xef\xb6\xff\xfb\x17\x24\x25\x59\x76\x2c\x99\x72\xec\x6e\x0a\x88\xc0\x62\x6b\x8b\x1a\xce\x0c\x87\xc3\x99\x21\x3f\xce\x11\x78\xbb\x6b\x07\x47\xf0\x9e\x06\xc8\x24\x86\xa0\x38\xa8\x29\xc2\x59\x42\x82\x29\xc2\x35\x1f\xab\x19\x11\x08\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\xf1\x6f\xdb\x38\xf2\xef\xef\xf9\x2b\x06\xc9\x01\x6d\x81\x48\x8e\x93\xb4\xbb\xeb\xf7\x43\x91\x26\xdb\xfb\xfa\xb5\x9b\x06\x49\x7a\x87\x7b\x6d\x0f\xa0\xa5\xb1\xcd\x8b\x44\xea\x48\x2a\x8e\xdf\xb6\xff\xfb\x17\x24\x25\x59\x76\x2c\x89\x72\xec\x6e\x0b\x88\x40\xd1\xd8\xa6\x86\x33\xc3\x99\xe1\x70\xc8\x8f\x7d\x00\xde\xf6\xda\xde\x01\xbc\xa7\x01\x32\x89\x21\x28\x0e\x6a\x8a\x70\x96\x90\x60\x8a\x70\xc3\xc7\x6a\x46\x04\xc2\x
 [...]
                },
                "/crd/bases/camel.apache.org_kamelets.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             "camel.apache.org_kamelets.yaml",
@@ -238,13 +238,6 @@ var assets = func() http.FileSystem {
 
                        compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x6f\xab\x46\x14\xdd\xcf\xaf\x38\x32\x9b\xf7\x24\x1b\xb7\x5d\x55\xee\x8a\x97\xd8\x2d\x6a\x64\x4b\xc6\x69\x94\xe5\x78\xb8\xc0\xad\x61\x2e\x9d\x19\x42\xdc\x5f\x5f\x0d\xb6\x9b\x44\x55\xab\x2e\x32\x2b\x10\x97\xf3\x71\xcf\x99\x04\x8b\xcf\x3b\x2a\xc1\x03\x1b\xb2\x9e\x4a\x04\x41\x68\x08\x59\xaf\x4d\x43\x28\xa4\x0a\xa3\x76\x84\x8d\x0c\xb6\xd4\x81\xc5\xe2\x4b\x56\x6c\xbe\x62\xb0\x25\x39\x88\x25\x88\x43\x27\x8e\x54\x
 [...]
                },
-               "/rbac/operator-role-binding-podmonitors.yaml": 
&vfsgen۰CompressedFileInfo{
-                       name:             
"operator-role-binding-podmonitors.yaml",
-                       modTime:          time.Time{},
-                       uncompressedSize: 1229,
-
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x8f\xdb\x36\x10\xbd\xf3\x57\x3c\x58\x97\x04\x58\xcb\x6d\x4f\x85\x7b\x72\x36\xbb\xad\xd0\xc0\x06\x2c\xa7\x41\x8e\x34\x35\x96\xa6\x2b\x71\xd8\x21\xb5\x8a\xfb\xeb\x0b\xca\x76\x77\x83\xa2\x45\x0f\xe1\x4d\xd0\xf0\x7d\xcc\x7b\x2c\xb0\xfc\x76\xc7\x14\xf8\xc0\x8e\x7c\xa4\x06\x49\x90\x3a\xc2\x26\x58\xd7\x11\x6a\x39\xa5\xc9\x2a\xe1\x51\x46\xdf\xd8\xc4\xe2\xf1\x66\x53\x3f\xbe\xc5\xe8\x1b\x52\x88\x27\x88\x62\x10\x25\x
 [...]
-               },
                "/rbac/operator-role-binding-service-binding.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             
"operator-role-binding-service-binding.yaml",
                        modTime:          time.Time{},
@@ -252,6 +245,13 @@ var assets = func() http.FileSystem {
 
                        compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xcf\x6f\xf2\x46\x10\xbd\xef\x5f\xf1\x84\x2f\xdf\x27\x81\x69\x7b\xaa\xe8\xc9\x5f\x02\xad\xd5\x08\x24\x4c\x1a\xe5\xb8\x5e\x0f\xf6\x14\x7b\xc7\xdd\x5d\xc7\xa1\x7f\x7d\xb5\x06\x9a\x44\x55\x2b\x55\xca\xde\x10\x33\xef\xc7\xbc\xe7\x04\x8b\xcf\x7b\x2a\xc1\x03\x1b\xb2\x9e\x2a\x04\x41\x68\x08\x59\xaf\x4d\x43\x28\xe4\x18\x46\xed\x08\x1b\x19\x6c\xa5\x03\x8b\xc5\x97\xac\xd8\x7c\xc5\x60\x2b\x72\x10\x4b\x10\x87\x4e\x1c\xa9\x
 [...]
                },
+               "/rbac/operator-role-binding-servicemonitors.yaml": 
&vfsgen۰CompressedFileInfo{
+                       name:             
"operator-role-binding-servicemonitors.yaml",
+                       modTime:          time.Time{},
+                       uncompressedSize: 1237,
+
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x8f\xdb\x36\x10\xbd\xf3\x57\x3c\x58\x97\x04\x58\xcb\x6d\x4f\x85\x7b\x52\x36\xeb\x56\x68\x60\x03\x96\xd3\x20\x47\x9a\x1a\x4b\x53\x4b\x1c\x75\x48\xad\xe2\xfe\xfa\x82\xb2\xdd\xdd\xa0\x68\x81\x02\xe1\xcd\xf0\xcc\xfb\x98\xf7\x94\x61\xf9\xed\x9e\xc9\xf0\x81\x1d\xf9\x40\x35\xa2\x20\xb6\x84\x62\xb0\xae\x25\x54\x72\x8a\x93\x55\xc2\x46\x46\x5f\xdb\xc8\xe2\xf1\xa6\xa8\x36\x6f\x31\xfa\x9a\x14\xe2\x09\xa2\xe8\x45\xc9\x
 [...]
+               },
                "/rbac/operator-role-binding-strimzi.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             "operator-role-binding-strimzi.yaml",
                        modTime:          time.Time{},
@@ -301,13 +301,6 @@ var assets = func() http.FileSystem {
 
                        compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x53\xc1\x8e\xdb\x46\x0c\xbd\xeb\x2b\x1e\xac\x4b\x02\xac\xe5\xb6\xa7\xc2\x3d\xb9\xc9\x6e\x6b\x34\xb0\x81\x95\xd3\x20\x47\x7a\x44\x4b\xc4\x8e\x86\xea\xcc\x68\x95\xed\xd7\x17\x33\xb6\x13\x6f\xdd\x6d\x2e\x01\xa2\x8b\x68\xf2\x89\x7c\x8f\x8f\x2e\x31\xff\x76\x4f\x51\xe2\x9d\x18\x76\x81\x1b\x44\x45\xec\x18\xab\x81\x4c\xc7\xa8\xf5\x10\x27\xf2\x8c\x3b\x1d\x5d\x43\x51\xd4\xe1\xd5\xaa\xbe\x7b\x8d\xd1\x35\xec\xa1\x8e\xa1\x1e\x
 [...]
                },
-               "/rbac/operator-role-podmonitors.yaml": 
&vfsgen۰CompressedFileInfo{
-                       name:             "operator-role-podmonitors.yaml",
-                       modTime:          time.Time{},
-                       uncompressedSize: 1242,
-
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\x4d\x8f\xdb\x36\x10\xbd\xf3\x57\x3c\x58\x97\x04\x58\xcb\x6d\x4f\x85\x7b\x72\x37\xbb\xad\xd0\xc0\x06\x56\x4e\x83\x1c\x69\x6a\x2c\x0d\x96\xe2\xb0\x43\x6a\x95\xed\xaf\x2f\x24\xcb\xcd\x1a\xb9\x86\x17\x8f\xc9\xe1\xfb\xe0\x1b\x15\x58\xff\xb8\x65\x0a\x7c\x64\x47\x21\x51\x83\x2c\xc8\x1d\x61\x17\xad\xeb\x08\xb5\x9c\xf3\x68\x95\xf0\x28\x43\x68\x6c\x66\x09\x78\xb7\xab\x1f\xdf\x63\x08\x0d\x29\x24\x10\x44\xd1\x8b\x92\x29\x
 [...]
-               },
                "/rbac/operator-role-service-binding.yaml": 
&vfsgen۰CompressedFileInfo{
                        name:             "operator-role-service-binding.yaml",
                        modTime:          time.Time{},
@@ -315,6 +308,13 @@ var assets = func() http.FileSystem {
 
                        compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xc1\x6e\xdc\x36\x10\xbd\xf3\x2b\x1e\x56\x97\x04\xb0\xe4\xb6\xa7\x62\x7b\xda\x3a\x76\x2b\x34\xd8\x05\xac\x4d\x83\x1c\xb9\xd4\xac\x34\x30\xc5\x51\x87\x94\x15\xf7\xeb\x0b\x6a\xb5\x89\x8d\x5e\xa3\x0b\x47\xe4\xcc\x9b\xf7\xf8\x86\x05\xca\x1f\xf7\x99\x02\x1f\xd9\x51\x88\xd4\x22\x09\x52\x4f\xd8\x8d\xd6\xf5\x84\x46\xce\x69\xb6\x4a\x78\x90\x29\xb4\x36\xb1\x04\xbc\xdb\x35\x0f\xef\x31\x85\x96\x14\x12\x08\xa2\x18\x44\xc9\x
 [...]
                },
+               "/rbac/operator-role-servicemonitors.yaml": 
&vfsgen۰CompressedFileInfo{
+                       name:             "operator-role-servicemonitors.yaml",
+                       modTime:          time.Time{},
+                       uncompressedSize: 1250,
+
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x53\xc1\x8e\xdb\x36\x10\xbd\xf3\x2b\x1e\xac\x4b\x02\xac\xe5\xb6\xa7\xc2\x3d\xb9\x9b\xdd\x56\x68\x60\x03\x2b\xa7\x41\x8e\x34\x35\x96\x06\x4b\x71\xd4\x21\xb5\x8a\xfb\xf5\x85\x68\xb9\xd9\x45\xae\xe1\xc5\x63\x72\x66\xde\x7b\xf3\x46\x05\xd6\x3f\xee\x98\x02\x1f\xd9\x51\x88\xd4\x20\x09\x52\x47\xd8\x0d\xd6\x75\x84\x5a\xce\x69\xb2\x4a\x78\x94\x31\x34\x36\xb1\x04\xbc\xdb\xd5\x8f\xef\x31\x86\x86\x14\x12\x08\xa2\xe8\x45\xc9\x
 [...]
+               },
                "/rbac/operator-role-strimzi.yaml": &vfsgen۰CompressedFileInfo{
                        name:             "operator-role-strimzi.yaml",
                        modTime:          time.Time{},
@@ -467,9 +467,9 @@ var assets = func() http.FileSystem {
                "/traits.yaml": &vfsgen۰CompressedFileInfo{
                        name:             "traits.yaml",
                        modTime:          time.Time{},
-                       uncompressedSize: 36744,
+                       uncompressedSize: 37171,
 
-                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\x6d\x73\x1c\xb7\xd1\xe0\x77\xfd\x0a\x14\x9f\xab\xe2\x4b\xed\x0e\x29\xa7\x9c\xf8\xf6\x4e\x97\xa2\x25\x25\xa1\x6d\x49\x3c\x51\x71\xea\x4a\xa7\xca\x62\x67\x7a\x77\x21\x62\x80\x09\x80\x59\x6a\x73\x75\xff\xfd\x0a\xdd\x00\x06\x33\x3b\x24\x97\xb2\xe9\x32\xaf\x9e\xe4\x83\x45\x72\xa6\xd1\x68\x34\xfa\xbd\x7b\x9c\xe1\xc2\xd9\xd9\xb3\x29\x53\xbc\x86\x19\xe3\xcb\xa5\x50\xc2\x6d\x9f\x31\xd6\x48\xee\x96\xda\xd4\x33\xb6\xe4\x
 [...]
+                       compressedContent: 
[]byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\xed\x72\x1c\xb7\x11\xe0\x7f\x3d\x05\x8a\xb9\x2a\x7e\xd4\xee\x90\x72\xca\xb1\xb3\x77\xba\x14\x2d\x29\x09\x6d\x4b\xe2\x89\x8a\x53\x57\x3a\x57\x16\x3b\xd3\xbb\x0b\x11\x03\x4c\x00\x0c\xa9\xcd\xd5\xbd\xfb\x15\xba\x01\x0c\x66\x77\xb8\x1c\xca\xa6\xcb\xbc\xba\xe4\x87\x45\x72\xa6\xd1\x68\x34\xfa\xbb\x7b\x9c\xe1\xc2\xd9\xd9\xb3\x29\x53\xbc\x86\x19\xe3\xcb\xa5\x50\xc2\x6d\x9e\x31\xd6\x48\xee\x96\xda\xd4\x33\xb6\xe4\xd2\x
 [...]
                },
        }
        fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
@@ -524,8 +524,8 @@ var assets = func() http.FileSystem {
                fs["/rbac/operator-role-binding-knative.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-binding-leases.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-binding-openshift.yaml"].(os.FileInfo),
-               
fs["/rbac/operator-role-binding-podmonitors.yaml"].(os.FileInfo),
                
fs["/rbac/operator-role-binding-service-binding.yaml"].(os.FileInfo),
+               
fs["/rbac/operator-role-binding-servicemonitors.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-binding-strimzi.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-binding.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-events.yaml"].(os.FileInfo),
@@ -533,8 +533,8 @@ var assets = func() http.FileSystem {
                fs["/rbac/operator-role-kubernetes.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-leases.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-openshift.yaml"].(os.FileInfo),
-               fs["/rbac/operator-role-podmonitors.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-service-binding.yaml"].(os.FileInfo),
+               fs["/rbac/operator-role-servicemonitors.yaml"].(os.FileInfo),
                fs["/rbac/operator-role-strimzi.yaml"].(os.FileInfo),
                fs["/rbac/user-cluster-role.yaml"].(os.FileInfo),
                
fs["/rbac/user-global-kamelet-viewer-role-binding.yaml"].(os.FileInfo),
diff --git a/pkg/trait/error_handler.go b/pkg/trait/error_handler.go
index 7945372..c2aee73 100644
--- a/pkg/trait/error_handler.go
+++ b/pkg/trait/error_handler.go
@@ -68,7 +68,7 @@ func (t *errorHandlerTrait) Apply(e *Environment) error {
 }
 
 func addErrorHandlerAsSource(e *Environment) error {
-       errorHandlerStatement, err := 
parseErrorHandler(e.Integration.Spec.ErrorHandler)
+       errorHandlerStatement, err := parseErrorHandler(e)
        if err != nil {
                return err
        }
@@ -91,21 +91,22 @@ func addErrorHandlerAsSource(e *Environment) error {
                Type:     v1.SourceTypeErrorHandler,
        }
 
-       replaced := false
-       for idx, existing := range e.Integration.Status.GeneratedSources {
-               if existing.Name == errorHandlerSource.Name {
-                       replaced = true
-                       e.Integration.Status.GeneratedSources[idx] = 
errorHandlerSource
-               }
-       }
-       if !replaced {
-               e.Integration.Status.GeneratedSources = 
append(e.Integration.Status.GeneratedSources, errorHandlerSource)
-       }
+       e.Integration.Status.AddOrReplaceGeneratedSources(errorHandlerSource)
 
        return nil
 }
 
-func parseErrorHandler(errorHandlerSpec v1.ErrorHandlerSpec) (string, error) {
+func addErrorHandlerBeanConfiguration(e *Environment, fqn string) error {
+       // camel.beans.defaultErrorHandler = 
#class:the-full-qualified-class-name
+       e.Integration.Status.AddConfigurationsIfMissing(v1.ConfigurationSpec{
+               Type:  "property",
+               Value: fmt.Sprintf("camel.beans.defaultErrorHandler=#class:%s", 
fqn),
+       })
+       return nil
+}
+
+func parseErrorHandler(e *Environment) (string, error) {
+       errorHandlerSpec := e.Integration.Spec.ErrorHandler
        switch errorHandlerSpec.Type {
        case "none":
                return `errorHandler(noErrorHandler());`, nil
@@ -126,6 +127,10 @@ func parseErrorHandler(errorHandlerSpec 
v1.ErrorHandlerSpec) (string, error) {
        case "ref":
                // TODO using URI temporarily, fix it properly
                return fmt.Sprintf(`errorHandler("%v");`, 
errorHandlerSpec.URI), nil
+       case "bean":
+               // TODO using URI temporarily, fix it properly
+               addErrorHandlerBeanConfiguration(e, errorHandlerSpec.URI)
+               return fmt.Sprintf(`errorHandler("%v");`, 
"defaultErrorHandler"), nil
        }
 
        return "", fmt.Errorf("Cannot recognize any error handler of type %s", 
errorHandlerSpec.Type)

Reply via email to