Repository: knative-sandbox/eventing-rabbitmq
Pull request #1181 (2023-07-25 21:00:58)

[release-1.9] fixing bug in name of Solender to avoid CLA troubles, is fixing …
This is an automated cherry-pick of #1147

knative-prow[bot]: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative-sandbox/eventing-rabbitmq/pull/1181#" title="Author self-approved">knative-prow-robot</a>*
**Once this PR has been reviewed and has the lgtm label**, please assign [pierdipi](https://github.com/pierdipi) for approval. For more information see [the Kubernetes Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Feventing-rabbitmq).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/knative-sandbox/eventing-rabbitmq/blob/release-1.9/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["pierdipi"]} -->

Patch:
diff --git a/pkg/reconciler/trigger/trigger.go b/pkg/reconciler/trigger/trigger.go
index 3510ccae..59d36115 100644
--- a/pkg/reconciler/trigger/trigger.go
+++ b/pkg/reconciler/trigger/trigger.go
@@ -269,12 +269,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, t *eventingv1.Trigger) p
 	logging.FromContext(ctx).Info("Reconciled rabbitmq binding", zap.Any("binding", binding))
 	t.Status.MarkDependencySucceeded()
 
-	if t.Spec.Subscriber.Ref != nil {
-		// To call URIFromDestination(dest apisv1alpha1.Destination, parent interface{}), dest.Ref must have a Namespace
-		// We will use the Namespace of Trigger as the Namespace of dest.Ref
-		t.Spec.Subscriber.Ref.Namespace = t.GetNamespace()
-	}
-
 	subscriberURI, err := r.uriResolver.URIFromDestinationV1(ctx, t.Spec.Subscriber, t)
 	if err != nil {
 		logging.FromContext(ctx).Error("Unable to get the Subscriber's URI", zap.Error(err))


Test patch:
diff --git a/pkg/reconciler/trigger/trigger_test.go b/pkg/reconciler/trigger/trigger_test.go
index 275daa03..127f97f8 100644
--- a/pkg/reconciler/trigger/trigger_test.go
+++ b/pkg/reconciler/trigger/trigger_test.go
@@ -76,6 +76,7 @@ import (
 const (
 	systemNS    = "knative-testing"
 	testNS      = "test-namespace"
+	otherNS     = "other-namespace"
 	brokerClass = "RabbitMQBroker"
 	brokerName  = "test-broker"
 	brokerUID   = "broker-test-uid"
@@ -449,6 +450,64 @@ func TestReconcile(t *testing.T) {
 						WithTriggerSubscriberResolvedSucceeded(),
 						WithTriggerStatusSubscriberURI(subscriberURI)),
 				}},
+			}, {
+				Name: fmt.Sprintf("%s: Creates everything with ref subscriber different ns", name),
+				Key:  testKey,
+				Objects: []runtime.Object{
+					ReadyBroker(config),
+					makeSubscriberAddressableAsUnstructuredWithNamespace(otherNS),
+					markReady(createQueue(config, false, "")),
+					markReady(createBinding(false, false, "")),
+					NewTrigger(triggerName, testNS, brokerName,
+						WithTriggerUID(triggerUID),
+						WithTriggerSubscriberRef(subscriberGVK, subscriberName, otherNS)),
+					createSecret(rabbitURL),
+					createRabbitMQBrokerConfig(""),
+					createRabbitMQCluster(""),
+				},
+				WantCreates: []runtime.Object{
+					createDispatcherDeployment(false, ""),
+				},
+				WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
+					Object: NewTrigger(triggerName, testNS, brokerName,
+						WithTriggerUID(triggerUID),
+						WithTriggerSubscriberRef(subscriberGVK, subscriberName, otherNS),
+						WithTriggerBrokerReady(),
+						WithTriggerDeadLetterSinkNotConfigured(),
+						WithTriggerDependencyReady(),
+						WithTriggerSubscribed(),
+						WithTriggerSubscriberResolvedSucceeded(),
+						WithTriggerStatusSubscriberURI(subscriberURI)),
+				}},
+			}, {
+				Name: fmt.Sprintf("%s: Creates everything with ref subscriber no ns provided", name),
+				Key:  testKey,
+				Objects: []runtime.Object{
+					ReadyBroker(config),
+					makeSubscriberAddressableAsUnstructured(),
+					markReady(createQueue(config, false, "")),
+					markReady(createBinding(false, false, "")),
+					NewTrigger(triggerName, testNS, brokerName,
+						WithTriggerUID(triggerUID),
+						WithTriggerSubscriberRef(subscriberGVK, subscriberName, "")),
+					createSecret(rabbitURL),
+					createRabbitMQBrokerConfig(""),
+					createRabbitMQCluster(""),
+				},
+				WantCreates: []runtime.Object{
+					createDispatcherDeployment(false, ""),
+				},
+				WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
+					Object: NewTrigger(triggerName, testNS, brokerName,
+						WithTriggerUID(triggerUID),
+						WithTriggerSubscriberRef(subscriberGVK, subscriberName, testNS),
+						WithTriggerBrokerReady(),
+						WithTriggerDeadLetterSinkNotConfigured(),
+						WithTriggerDependencyReady(),
+						WithTriggerSubscribed(),
+						WithTriggerSubscriberResolvedSucceeded(),
+						WithTriggerStatusSubscriberURI(subscriberURI)),
+				}},
 			}, {
 				Name: fmt.Sprintf("%s: Fails to resolve ref", name),
 				Key:  testKey,
@@ -1397,6 +1456,24 @@ func makeSubscriberAddressableAsUnstructured() *unstructured.Unstructured {
 	}
 }
 
+func makeSubscriberAddressableAsUnstructuredWithNamespace(ns string) *unstructured.Unstructured {
+	return &unstructured.Unstructured{
+		Object: map[string]interface{}{
+			"apiVersion": subscriberAPIVersion,
+			"kind":       subscriberKind,
+			"metadata": map[string]interface{}{
+				"namespace": ns,
+				"name":      subscriberName,
+			},
+			"status": map[string]interface{}{
+				"address": map[string]interface{}{
+					"url": subscriberURI,
+				},
+			},
+		},
+	}
+}
+
 func makeSubscriberNotAddressableAsUnstructured() *unstructured.Unstructured {
 	return &unstructured.Unstructured{
 		Object: map[string]interface{}{