You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2021/12/28 10:19:58 UTC
[camel-k] 02/02: chore(kamelet): rename error handler DLC to Sink
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
commit db75003b2fbbb395dfada1d4b7a143d19efb7328
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Mon Dec 27 11:03:23 2021 +0100
chore(kamelet): rename error handler DLC to Sink
Closes #2815
---
.../kamelets/kameletbindings-error-handler.adoc | 14 +--
docs/modules/ROOT/partials/apis/crds-html.adoc | 130 +++++----------------
e2e/common/kamelet_binding_test.go | 2 +-
.../kamelet-binding-error-handler.yaml | 2 +-
examples/kamelets/error-handler/readme.md | 6 +-
pkg/apis/camel/v1alpha1/error_handler_types.go | 16 +--
pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go | 42 +++----
pkg/cmd/bind.go | 13 +--
pkg/cmd/bind_test.go | 4 +-
pkg/controller/kameletbinding/error_handler.go | 9 +-
.../kameletbinding/error_handler_test.go | 28 ++---
11 files changed, 99 insertions(+), 167 deletions(-)
diff --git a/docs/modules/ROOT/pages/kamelets/kameletbindings-error-handler.adoc b/docs/modules/ROOT/pages/kamelets/kameletbindings-error-handler.adoc
index 648e05b..3b5022e 100644
--- a/docs/modules/ROOT/pages/kamelets/kameletbindings-error-handler.adoc
+++ b/docs/modules/ROOT/pages/kamelets/kameletbindings-error-handler.adoc
@@ -1,7 +1,7 @@
[[kameletbindings-error-handler]]
= Kamelet Bindings Error Handler
-Kamelet Binding`s offer a mechanism to specify an error policy to adopt in case an event produced by a `source` or consumed by a `sink`. Through the definition of an `errorHandler` you will be able to apply certain logic to the failing event, such as simply logging, ignoring the event or posting the event to a `Dead Letter Channel`.
+Kamelet Binding`s offer a mechanism to specify an error policy to adopt in case an event produced by a `source` or consumed by a `sink`. Through the definition of an `errorHandler` you will be able to apply certain logic to the failing event, such as simply logging, ignoring the event or posting the event to a `Sink`.
[source,yaml]
----
@@ -23,7 +23,7 @@ spec:
[[kameletbindings-error-handler-types]]
== Error Handler Types
-We have different types of error handler: `ǹone`, `log` and `dead-letter-channel`. The `errorHandler` parameter is optional.
+We have different types of error handler: `ǹone`, `log` and `sink`. The `errorHandler` parameter is optional.
[[kameletbindings-error-handler-none]]
=== No error handler
@@ -70,10 +70,10 @@ spec:
----
<1> Parameters belonging to the `log` error handler type
-[[kameletbindings-error-handler-dlc]]
-=== Dead Letter Channel error handler
+[[kameletbindings-error-handler-sink]]
+=== Sink error handler
-The `Dead Letter Channel` is probably the most interesting error handler type as it allows you to redirect any failing event to any other component, such as a third party URI, a queue or even another `Kamelet` which will be performing certain logic with the failing event.
+The `Sink` is probably the most interesting error handler type as it allows you to redirect any failing event to any other component, such as a third party URI, a queue or even another `Kamelet` which will be performing certain logic with the failing event.
[source,yaml]
----
@@ -87,7 +87,7 @@ spec:
sink:
...
errorHandler:
- dead-letter-channel:
+ sink:
endpoint:
ref: # <1>
kind: Kamelet
@@ -102,5 +102,5 @@ spec:
----
<1> You can use `ref` or `uri`. `ref` will be interpreted by the operator according the `kind`, `apiVersion` and `name`. You can use any `Kamelet`, `KafkaTopic` channel or `Knative` destination.
<2> Properties belonging to the endpoint (in this example, to the `Kamelet` named error handler)
-<3> Parameters belonging to the `dead-letter-channel` error handler type
+<3> Parameters belonging to the `sink` error handler type
diff --git a/docs/modules/ROOT/partials/apis/crds-html.adoc b/docs/modules/ROOT/partials/apis/crds-html.adoc
index 4adc586..80b5a3c 100644
--- a/docs/modules/ROOT/partials/apis/crds-html.adoc
+++ b/docs/modules/ROOT/partials/apis/crds-html.adoc
@@ -3090,6 +3090,16 @@ string
<td>
</td>
</tr>
+<tr>
+<td>
+<code>info</code><br/>
+<em>
+map[string]string
+</em>
+</td>
+<td>
+</td>
+</tr>
</tbody>
</table>
<h3 id="camel.apache.org/v1.IntegrationSpec">IntegrationSpec
@@ -4132,7 +4142,6 @@ RegistrySpec
<a href="#camel.apache.org/v1alpha1.BeanProperties">BeanProperties</a>,
<a href="#camel.apache.org/v1alpha1.EndpointProperties">EndpointProperties</a>,
<a href="#camel.apache.org/v1alpha1.ErrorHandlerParameters">ErrorHandlerParameters</a>,
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerRef">ErrorHandlerRef</a>,
<a href="#camel.apache.org/v1alpha1.ErrorHandlerSpec">ErrorHandlerSpec</a>,
<a href="#camel.apache.org/v1.Flow">Flow</a>,
<a href="#camel.apache.org/v1.Template">Template</a>,
@@ -5278,10 +5287,6 @@ KameletBindingStatus
</div>
<h3 id="camel.apache.org/v1alpha1.BeanProperties">BeanProperties
</h3>
-<p>
-(<em>Appears on:</em>
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerBean">ErrorHandlerBean</a>)
-</p>
<div>
<p>BeanProperties represent an unstructured object properties to be set on a bean</p>
</div>
@@ -5311,7 +5316,7 @@ RawMessage
</h3>
<p>
(<em>Appears on:</em>
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerDeadLetterChannel">ErrorHandlerDeadLetterChannel</a>,
+<a href="#camel.apache.org/v1alpha1.ErrorHandlerSink">ErrorHandlerSink</a>,
<a href="#camel.apache.org/v1alpha1.KameletBindingSpec">KameletBindingSpec</a>)
</p>
<div>
@@ -5420,99 +5425,11 @@ RawMessage
<div>
<p>ErrorHandler is a generic interface that represent any type of error handler specification</p>
</div>
-<h3 id="camel.apache.org/v1alpha1.ErrorHandlerBean">ErrorHandlerBean
-</h3>
-<div>
-<p>ErrorHandlerBean represents a bean error handler type</p>
-</div>
-<table>
-<thead>
-<tr>
-<th>Field</th>
-<th>Description</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td>
-<code>ErrorHandlerNone</code><br/>
-<em>
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerNone">
-ErrorHandlerNone
-</a>
-</em>
-</td>
-<td>
-</td>
-</tr>
-<tr>
-<td>
-<code>type</code><br/>
-<em>
-string
-</em>
-</td>
-<td>
-</td>
-</tr>
-<tr>
-<td>
-<code>properties</code><br/>
-<em>
-<a href="#camel.apache.org/v1alpha1.BeanProperties">
-BeanProperties
-</a>
-</em>
-</td>
-<td>
-</td>
-</tr>
-</tbody>
-</table>
-<h3 id="camel.apache.org/v1alpha1.ErrorHandlerDeadLetterChannel">ErrorHandlerDeadLetterChannel
-</h3>
-<div>
-<p>ErrorHandlerDeadLetterChannel represents a dead letter channel error handler type</p>
-</div>
-<table>
-<thead>
-<tr>
-<th>Field</th>
-<th>Description</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td>
-<code>ErrorHandlerLog</code><br/>
-<em>
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerLog">
-ErrorHandlerLog
-</a>
-</em>
-</td>
-<td>
-</td>
-</tr>
-<tr>
-<td>
-<code>endpoint</code><br/>
-<em>
-<a href="#camel.apache.org/v1alpha1.Endpoint">
-Endpoint
-</a>
-</em>
-</td>
-<td>
-</td>
-</tr>
-</tbody>
-</table>
<h3 id="camel.apache.org/v1alpha1.ErrorHandlerLog">ErrorHandlerLog
</h3>
<p>
(<em>Appears on:</em>
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerDeadLetterChannel">ErrorHandlerDeadLetterChannel</a>)
+<a href="#camel.apache.org/v1alpha1.ErrorHandlerSink">ErrorHandlerSink</a>)
</p>
<div>
<p>ErrorHandlerLog represent a default (log) error handler type</p>
@@ -5555,7 +5472,6 @@ ErrorHandlerParameters
</h3>
<p>
(<em>Appears on:</em>
-<a href="#camel.apache.org/v1alpha1.ErrorHandlerBean">ErrorHandlerBean</a>,
<a href="#camel.apache.org/v1alpha1.ErrorHandlerLog">ErrorHandlerLog</a>)
</p>
<div>
@@ -5602,10 +5518,10 @@ RawMessage
</tr>
</tbody>
</table>
-<h3 id="camel.apache.org/v1alpha1.ErrorHandlerRef">ErrorHandlerRef
+<h3 id="camel.apache.org/v1alpha1.ErrorHandlerSink">ErrorHandlerSink
</h3>
<div>
-<p>ErrorHandlerRef represents a reference to an error handler builder available in the registry</p>
+<p>ErrorHandlerSink represents a sink error handler type which behave like a dead letter channel</p>
</div>
<table>
<thead>
@@ -5617,10 +5533,22 @@ RawMessage
<tbody>
<tr>
<td>
-<code>RawMessage</code><br/>
+<code>ErrorHandlerLog</code><br/>
<em>
-<a href="#camel.apache.org/v1.RawMessage">
-RawMessage
+<a href="#camel.apache.org/v1alpha1.ErrorHandlerLog">
+ErrorHandlerLog
+</a>
+</em>
+</td>
+<td>
+</td>
+</tr>
+<tr>
+<td>
+<code>endpoint</code><br/>
+<em>
+<a href="#camel.apache.org/v1alpha1.Endpoint">
+Endpoint
</a>
</em>
</td>
diff --git a/e2e/common/kamelet_binding_test.go b/e2e/common/kamelet_binding_test.go
index f8519d1..7d68cb7 100644
--- a/e2e/common/kamelet_binding_test.go
+++ b/e2e/common/kamelet_binding_test.go
@@ -52,7 +52,7 @@ func TestErrorHandler(t *testing.T) {
}
errorHandler := map[string]interface{}{
- "dead-letter-channel": map[string]interface{}{
+ "sink": map[string]interface{}{
"endpoint": map[string]interface{}{
"ref": map[string]string{
"kind": "Kamelet",
diff --git a/examples/kamelets/error-handler/kamelet-binding-error-handler.yaml b/examples/kamelets/error-handler/kamelet-binding-error-handler.yaml
index 3d3c3a5..6a5f4b7 100644
--- a/examples/kamelets/error-handler/kamelet-binding-error-handler.yaml
+++ b/examples/kamelets/error-handler/kamelet-binding-error-handler.yaml
@@ -31,7 +31,7 @@ spec:
apiVersion: camel.apache.org/v1alpha1
name: log-sink
errorHandler:
- dead-letter-channel:
+ sink:
endpoint:
ref:
kind: Kamelet
diff --git a/examples/kamelets/error-handler/readme.md b/examples/kamelets/error-handler/readme.md
index c9a6857..2c400dc 100644
--- a/examples/kamelets/error-handler/readme.md
+++ b/examples/kamelets/error-handler/readme.md
@@ -1,5 +1,5 @@
# Kamelets Binding Error Handler example
-This example shows how to create a simple _source_ `Kamelet` which sends periodically events (and certain failures). The events are consumed by a log _sink_ in a `KameletBinding`. With the support of the `ErrorHandler` we will be able to redirect all errors to a `Dead Letter Channel` _error-handler_ `Kamelet` whose goal is to store the events in a `Kafka` topic and provide a nice log notifying us about the error happened.
+This example shows how to create a simple _source_ `Kamelet` which sends periodically events (and certain failures). The events are consumed by a log _sink_ in a `KameletBinding`. With the support of the `ErrorHandler` we will be able to redirect all errors to a `Sink` _error-handler_ `Kamelet` whose goal is to store the events in a `Kafka` topic and provide a nice log notifying us about the error happened.
## Incremental ID Source Kamelet
First of all, you must install the _incremental-id-source_ Kamelet defined in `incremental-id-source.kamelet.yaml` file. This source will emit events every second with an autoincrement counter that will be forced to fail when the number 0 is caught. With this trick, we will simulate possible event faults.
@@ -81,11 +81,11 @@ log-sink Ready
incremental-id-source Ready
```
## Error Handler Kamelet Binding
-We can now create a `KameletBinding` which is started by the _incremental-id-source_ `Kamelet` and log events to _log-sink_ `Kamelet`. As this will sporadically fail, we can configure an _errorHandler_ with the _error-handler_ `Kamelet` as **Dead Letter Channel**. We want to configure also some redelivery policies (1 retry, with a 2000 milliseconds delay). We can declare it as in `kamelet-binding-error-handler.yaml` file:
+We can now create a `KameletBinding` which is started by the _incremental-id-source_ `Kamelet` and log events to _log-sink_ `Kamelet`. As this will sporadically fail, we can configure an _errorHandler_ with the _error-handler_ `Kamelet` as **Sink**. We want to configure also some redelivery policies (1 retry, with a 2000 milliseconds delay). We can declare it as in `kamelet-binding-error-handler.yaml` file:
```
...
errorHandler:
- dead-letter-channel:
+ sink:
endpoint:
ref:
kind: Kamelet
diff --git a/pkg/apis/camel/v1alpha1/error_handler_types.go b/pkg/apis/camel/v1alpha1/error_handler_types.go
index c7ebd8a..af038cb 100644
--- a/pkg/apis/camel/v1alpha1/error_handler_types.go
+++ b/pkg/apis/camel/v1alpha1/error_handler_types.go
@@ -125,24 +125,24 @@ func (e ErrorHandlerLog) Configuration() (map[string]interface{}, error) {
return properties, nil
}
-// ErrorHandlerDeadLetterChannel represents a dead letter channel error handler type
-type ErrorHandlerDeadLetterChannel struct {
+// ErrorHandlerSink represents a sink error handler type which behave like a dead letter channel
+type ErrorHandlerSink struct {
ErrorHandlerLog
DLCEndpoint *Endpoint `json:"endpoint,omitempty"`
}
// Type --
-func (e ErrorHandlerDeadLetterChannel) Type() ErrorHandlerType {
- return ErrorHandlerTypeDeadLetterChannel
+func (e ErrorHandlerSink) Type() ErrorHandlerType {
+ return ErrorHandlerTypeSink
}
// Endpoint --
-func (e ErrorHandlerDeadLetterChannel) Endpoint() *Endpoint {
+func (e ErrorHandlerSink) Endpoint() *Endpoint {
return e.DLCEndpoint
}
// Configuration --
-func (e ErrorHandlerDeadLetterChannel) Configuration() (map[string]interface{}, error) {
+func (e ErrorHandlerSink) Configuration() (map[string]interface{}, error) {
properties, err := e.ErrorHandlerLog.Configuration()
if err != nil {
return nil, err
@@ -161,6 +161,8 @@ const (
ErrorHandlerTypeNone ErrorHandlerType = "none"
// ErrorHandlerTypeLog --
ErrorHandlerTypeLog ErrorHandlerType = "log"
- // ErrorHandlerTypeDeadLetterChannel --
+ // ErrorHandlerTypeSink --
+ ErrorHandlerTypeSink ErrorHandlerType = "sink"
+ // ErrorHandlerTypeDeadLetterChannel Deprecated in favour of ErrorHandlerTypeSink
ErrorHandlerTypeDeadLetterChannel ErrorHandlerType = "dead-letter-channel"
)
diff --git a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
index c492985..be6e2c5 100644
--- a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
@@ -105,27 +105,6 @@ func (in *EndpointProperties) DeepCopy() *EndpointProperties {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ErrorHandlerDeadLetterChannel) DeepCopyInto(out *ErrorHandlerDeadLetterChannel) {
- *out = *in
- in.ErrorHandlerLog.DeepCopyInto(&out.ErrorHandlerLog)
- if in.DLCEndpoint != nil {
- in, out := &in.DLCEndpoint, &out.DLCEndpoint
- *out = new(Endpoint)
- (*in).DeepCopyInto(*out)
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ErrorHandlerDeadLetterChannel.
-func (in *ErrorHandlerDeadLetterChannel) DeepCopy() *ErrorHandlerDeadLetterChannel {
- if in == nil {
- return nil
- }
- out := new(ErrorHandlerDeadLetterChannel)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ErrorHandlerLog) DeepCopyInto(out *ErrorHandlerLog) {
*out = *in
out.ErrorHandlerNone = in.ErrorHandlerNone
@@ -183,6 +162,27 @@ func (in *ErrorHandlerParameters) DeepCopy() *ErrorHandlerParameters {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *ErrorHandlerSink) DeepCopyInto(out *ErrorHandlerSink) {
+ *out = *in
+ in.ErrorHandlerLog.DeepCopyInto(&out.ErrorHandlerLog)
+ if in.DLCEndpoint != nil {
+ in, out := &in.DLCEndpoint, &out.DLCEndpoint
+ *out = new(Endpoint)
+ (*in).DeepCopyInto(*out)
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ErrorHandlerSink.
+func (in *ErrorHandlerSink) DeepCopy() *ErrorHandlerSink {
+ if in == nil {
+ return nil
+ }
+ out := new(ErrorHandlerSink)
+ in.DeepCopyInto(out)
+ return out
+}
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ErrorHandlerSpec) DeepCopyInto(out *ErrorHandlerSpec) {
*out = *in
if in.RawMessage != nil {
diff --git a/pkg/cmd/bind.go b/pkg/cmd/bind.go
index 396b3b2..b81d49d 100644
--- a/pkg/cmd/bind.go
+++ b/pkg/cmd/bind.go
@@ -58,7 +58,7 @@ func newCmdBind(rootCmdOptions *RootCmdOptions) (*cobra.Command, *bindCmdOptions
}
cmd.Flags().StringArrayP("connect", "c", nil, "A ServiceBinding or Provisioned Service that the integration should bind to, specified as [[apigroup/]version:]kind:[namespace/]name")
- cmd.Flags().String("error-handler", "", `Add error handler (none|log|dlc:<endpoint>). DLC endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name", plain Camel URIs or Kamelet name.`)
+ cmd.Flags().String("error-handler", "", `Add error handler (none|log|sink:<endpoint>). Sink endpoints are expected in the format "[[apigroup/]version:]kind:[namespace/]name", plain Camel URIs or Kamelet name.`)
cmd.Flags().String("name", "", "Name for the binding")
cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
cmd.Flags().StringArrayP("property", "p", nil, `Add a binding property in the form of "source.<key>=<value>", "sink.<key>=<value>", "error-handler.<key>=<value>" or "step-<n>.<key>=<value>"`)
@@ -239,13 +239,13 @@ func (o *bindCmdOptions) parseErrorHandler() (*v1alpha1.ErrorHandlerSpec, error)
errHandlMap["none"] = nil
case "log":
errHandlMap["log"] = nil
- case "dlc":
- dlcSpec, err := o.decode(errHandlValue, errorHandlerKey)
+ case "sink":
+ sinkSpec, err := o.decode(errHandlValue, errorHandlerKey)
if err != nil {
return nil, err
}
- errHandlMap["dead-letter-channel"] = map[string]interface{}{
- "endpoint": dlcSpec,
+ errHandlMap["sink"] = map[string]interface{}{
+ "endpoint": sinkSpec,
}
default:
return nil, fmt.Errorf("invalid error handler type %s", o.ErrorHandler)
@@ -259,8 +259,7 @@ func (o *bindCmdOptions) parseErrorHandler() (*v1alpha1.ErrorHandlerSpec, error)
func parseErrorHandlerByType(value string) (string, string, error) {
errHandlSplit := strings.SplitN(value, ":", 2)
- if (errHandlSplit[0] == "dlc" || errHandlSplit[0] == "bean" || errHandlSplit[0] == "ref") &&
- len(errHandlSplit) != 2 {
+ if (errHandlSplit[0] == "sink") && len(errHandlSplit) != 2 {
return "", "", fmt.Errorf("invalid error handler syntax. Type %s needs a configuration (ie %s:value)",
errHandlSplit[0], errHandlSplit[0])
}
diff --git a/pkg/cmd/bind_test.go b/pkg/cmd/bind_test.go
index 0065fb9..34736d1 100644
--- a/pkg/cmd/bind_test.go
+++ b/pkg/cmd/bind_test.go
@@ -89,7 +89,7 @@ func TestBindOutputUnknownFormat(t *testing.T) {
func TestBindErrorHandlerDLCKamelet(t *testing.T) {
buildCmdOptions, bindCmd, _ := initializeBindCmdOptions(t)
output, err := test.ExecuteCommand(bindCmd, cmdBind, "my:src", "my:dst", "-o", "yaml",
- "--error-handler", "dlc:my-kamelet", "-p", "error-handler.my-prop=value")
+ "--error-handler", "sink:my-kamelet", "-p", "error-handler.my-prop=value")
assert.Equal(t, "yaml", buildCmdOptions.OutputFormat)
assert.Nil(t, err)
@@ -100,7 +100,7 @@ metadata:
name: my-to-my
spec:
errorHandler:
- dead-letter-channel:
+ sink:
endpoint:
properties:
my-prop: value
diff --git a/pkg/controller/kameletbinding/error_handler.go b/pkg/controller/kameletbinding/error_handler.go
index e240e52..48f1639 100644
--- a/pkg/controller/kameletbinding/error_handler.go
+++ b/pkg/controller/kameletbinding/error_handler.go
@@ -35,7 +35,7 @@ func maybeErrorHandler(errHandlConf *v1alpha1.ErrorHandlerSpec, bindingContext b
return nil, errors.Wrap(err, "could not parse error handler")
}
// We need to get the translated URI from any referenced resource (ie, kamelets)
- if errorHandlerSpec.Type() == v1alpha1.ErrorHandlerTypeDeadLetterChannel {
+ if errorHandlerSpec.Type() == v1alpha1.ErrorHandlerTypeSink {
errorHandlerBinding, err = bindings.Translate(bindingContext, bindings.EndpointContext{Type: v1alpha1.EndpointTypeErrorHandler}, *errorHandlerSpec.Endpoint())
if err != nil {
return nil, errors.Wrap(err, "could not determine error handler URI")
@@ -74,8 +74,11 @@ func parseErrorHandler(rawMessage v1.RawMessage) (v1alpha1.ErrorHandler, error)
dst = new(v1alpha1.ErrorHandlerNone)
case v1alpha1.ErrorHandlerTypeLog:
dst = new(v1alpha1.ErrorHandlerLog)
+ // Deprecated: left for compatibility for some version
case v1alpha1.ErrorHandlerTypeDeadLetterChannel:
- dst = new(v1alpha1.ErrorHandlerDeadLetterChannel)
+ dst = new(v1alpha1.ErrorHandlerSink)
+ case v1alpha1.ErrorHandlerTypeSink:
+ dst = new(v1alpha1.ErrorHandlerSink)
default:
return nil, errors.Errorf("Unknown error handler type %s", errHandlType)
}
@@ -103,7 +106,7 @@ func setErrorHandlerConfiguration(errorHandlerBinding *bindings.Binding, errorHa
for key, value := range properties {
errorHandlerBinding.ApplicationProperties[key] = fmt.Sprintf("%v", value)
}
- if errorHandler.Type() == v1alpha1.ErrorHandlerTypeDeadLetterChannel && errorHandlerBinding.URI != "" {
+ if errorHandler.Type() == v1alpha1.ErrorHandlerTypeSink && errorHandlerBinding.URI != "" {
errorHandlerBinding.ApplicationProperties[fmt.Sprintf("%s.deadLetterUri", v1alpha1.ErrorHandlerAppPropertiesPrefix)] = fmt.Sprintf("%v", errorHandlerBinding.URI)
}
return nil
diff --git a/pkg/controller/kameletbinding/error_handler_test.go b/pkg/controller/kameletbinding/error_handler_test.go
index c182ad1..b6dab39 100644
--- a/pkg/controller/kameletbinding/error_handler_test.go
+++ b/pkg/controller/kameletbinding/error_handler_test.go
@@ -63,25 +63,25 @@ func TestParseErrorHandlerLogWithParametersDoesSucceed(t *testing.T) {
assert.Equal(t, v1alpha1.ErrorHandlerRefDefaultName, parameters[v1alpha1.ErrorHandlerRefName])
}
-func TestParseErrorHandlerDLCDoesSucceed(t *testing.T) {
+func TestParseErrorHandlerSinkDoesSucceed(t *testing.T) {
fmt.Println("Test")
- dlcErrorHandler, err := parseErrorHandler(
- []byte(`{"dead-letter-channel": {"endpoint": {"uri": "someUri"}}}`),
+ sinkErrorHandler, err := parseErrorHandler(
+ []byte(`{"sink": {"endpoint": {"uri": "someUri"}}}`),
)
assert.Nil(t, err)
- assert.NotNil(t, dlcErrorHandler)
- assert.Equal(t, v1alpha1.ErrorHandlerTypeDeadLetterChannel, dlcErrorHandler.Type())
- assert.Equal(t, "someUri", *dlcErrorHandler.Endpoint().URI)
- parameters, err := dlcErrorHandler.Configuration()
+ assert.NotNil(t, sinkErrorHandler)
+ assert.Equal(t, v1alpha1.ErrorHandlerTypeSink, sinkErrorHandler.Type())
+ assert.Equal(t, "someUri", *sinkErrorHandler.Endpoint().URI)
+ parameters, err := sinkErrorHandler.Configuration()
assert.Nil(t, err)
assert.Equal(t, "#class:org.apache.camel.builder.DeadLetterChannelBuilder", parameters[v1alpha1.ErrorHandlerAppPropertiesPrefix])
assert.Equal(t, v1alpha1.ErrorHandlerRefDefaultName, parameters[v1alpha1.ErrorHandlerRefName])
}
-func TestParseErrorHandlerDLCWithParametersDoesSucceed(t *testing.T) {
- dlcErrorHandler, err := parseErrorHandler(
+func TestParseErrorHandlerSinkWithParametersDoesSucceed(t *testing.T) {
+ sinkErrorHandler, err := parseErrorHandler(
[]byte(`{
- "dead-letter-channel": {
+ "sink": {
"endpoint": {
"uri": "someUri"
},
@@ -91,10 +91,10 @@ func TestParseErrorHandlerDLCWithParametersDoesSucceed(t *testing.T) {
}`),
)
assert.Nil(t, err)
- assert.NotNil(t, dlcErrorHandler)
- assert.Equal(t, v1alpha1.ErrorHandlerTypeDeadLetterChannel, dlcErrorHandler.Type())
- assert.Equal(t, "someUri", *dlcErrorHandler.Endpoint().URI)
- parameters, err := dlcErrorHandler.Configuration()
+ assert.NotNil(t, sinkErrorHandler)
+ assert.Equal(t, v1alpha1.ErrorHandlerTypeSink, sinkErrorHandler.Type())
+ assert.Equal(t, "someUri", *sinkErrorHandler.Endpoint().URI)
+ parameters, err := sinkErrorHandler.Configuration()
assert.Nil(t, err)
assert.Equal(t, "#class:org.apache.camel.builder.DeadLetterChannelBuilder", parameters[v1alpha1.ErrorHandlerAppPropertiesPrefix])
assert.Equal(t, v1alpha1.ErrorHandlerRefDefaultName, parameters[v1alpha1.ErrorHandlerRefName])