diff --git a/pkg/apis/eventing/register.go b/pkg/apis/eventing/register.go index 7aa995c784c..ead3498bd28 100644 --- a/pkg/apis/eventing/register.go +++ b/pkg/apis/eventing/register.go @@ -55,6 +55,10 @@ const ( // EventTypesAnnotationKey is the annotation key to specify // if a Source has event types defines in its CRD. EventTypesAnnotationKey = "registry.knative.dev/eventTypes" + + // BrokerChannelAddressStatusAnnotationKey is the broker status + // annotation key used to specify the address of its channel. + BrokerChannelAddressStatusAnnotationKey = "knative.dev/channelAddress" ) var ( diff --git a/pkg/apis/eventing/v1beta1/broker_conversion_test.go b/pkg/apis/eventing/v1beta1/broker_conversion_test.go index 9837b44a946..90bc6928fe2 100644 --- a/pkg/apis/eventing/v1beta1/broker_conversion_test.go +++ b/pkg/apis/eventing/v1beta1/broker_conversion_test.go @@ -25,6 +25,7 @@ import ( "k8s.io/utils/pointer" eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1" eventingduckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" + "knative.dev/eventing/pkg/apis/eventing" v1 "knative.dev/eventing/pkg/apis/eventing/v1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" @@ -112,7 +113,7 @@ func TestBrokerConversionRoundTripV1beta1(t *testing.T) { Status: "True", }}, Annotations: map[string]string{ - "channelAddress": "http://foo.bar.svc.cluster.local/", + eventing.BrokerChannelAddressStatusAnnotationKey: "http://foo.bar.svc.cluster.local/", }, }, Address: duckv1.Addressable{ @@ -200,7 +201,7 @@ func TestBrokerConversionRoundTripV1(t *testing.T) { Status: "True", }}, Annotations: map[string]string{ - "channelAddress": "http://foo.bar.svc.cluster.local/", + eventing.BrokerChannelAddressStatusAnnotationKey: "http://foo.bar.svc.cluster.local/", }, }, Address: duckv1.Addressable{ diff --git a/pkg/mtbroker/ingress/ingress_handler.go b/pkg/mtbroker/ingress/ingress_handler.go index c2246906f78..7fb0d73d4df 100644 --- a/pkg/mtbroker/ingress/ingress_handler.go +++ b/pkg/mtbroker/ingress/ingress_handler.go @@ -32,6 +32,7 @@ import ( "go.uber.org/zap" "k8s.io/apimachinery/pkg/types" + "knative.dev/eventing/pkg/apis/eventing" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" eventinglisters "knative.dev/eventing/pkg/client/listers/eventing/v1" "knative.dev/eventing/pkg/health" @@ -87,7 +88,7 @@ func (h *Handler) getChannelAddress(name, namespace string) (string, error) { if broker.Status.Annotations == nil { return "", fmt.Errorf("Broker status annotations uninitialized") } - address, present := broker.Status.Annotations["channelAddress"] + address, present := broker.Status.Annotations[eventing.BrokerChannelAddressStatusAnnotationKey] if !present { return "", fmt.Errorf("Channel address not found in broker status annotations") } diff --git a/pkg/mtbroker/ingress/ingress_handler_test.go b/pkg/mtbroker/ingress/ingress_handler_test.go index 8f72c7547da..0ba7899e018 100644 --- a/pkg/mtbroker/ingress/ingress_handler_test.go +++ b/pkg/mtbroker/ingress/ingress_handler_test.go @@ -33,6 +33,7 @@ import ( "go.uber.org/zap" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "knative.dev/eventing/pkg/apis/eventing" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" broker "knative.dev/eventing/pkg/mtbroker" reconcilertestingv1 "knative.dev/eventing/pkg/reconciler/testing/v1" @@ -208,7 +209,7 @@ func TestHandler_ServeHTTP(t *testing.T) { if b.Status.Annotations == nil { b.Status.Annotations = make(map[string]string, 1) } - b.Status.Annotations["channelAddress"] = s.URL + b.Status.Annotations[eventing.BrokerChannelAddressStatusAnnotationKey] = s.URL annotatedBrokers = append(annotatedBrokers, b) } listers := reconcilertestingv1.NewListers(annotatedBrokers) diff --git a/pkg/reconciler/mtbroker/broker.go b/pkg/reconciler/mtbroker/broker.go index dc633ae0eaf..4d356a55a72 100644 --- a/pkg/reconciler/mtbroker/broker.go +++ b/pkg/reconciler/mtbroker/broker.go @@ -165,7 +165,7 @@ func (r *Reconciler) reconcileKind(ctx context.Context, b *eventingv1.Broker) (* if b.Status.Annotations == nil { b.Status.Annotations = make(map[string]string, 1) } - b.Status.Annotations["channelAddress"] = triggerChan.Status.Address.URL.String() + b.Status.Annotations[eventing.BrokerChannelAddressStatusAnnotationKey] = triggerChan.Status.Address.URL.String() channelStatus := &duckv1.ChannelableStatus{AddressStatus: pkgduckv1.AddressStatus{Address: &pkgduckv1.Addressable{URL: triggerChan.Status.Address.URL}}} b.Status.PropagateTriggerChannelReadiness(channelStatus) diff --git a/pkg/reconciler/testing/v1/broker.go b/pkg/reconciler/testing/v1/broker.go index 46fa1412301..e9ee8bf287d 100644 --- a/pkg/reconciler/testing/v1/broker.go +++ b/pkg/reconciler/testing/v1/broker.go @@ -19,6 +19,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/apis/eventing" v1 "knative.dev/eventing/pkg/apis/eventing/v1" "knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1/broker" "knative.dev/pkg/apis" @@ -180,6 +181,6 @@ func WithChannelAddressAnnotation(address string) BrokerOption { if b.Status.Annotations == nil { b.Status.Annotations = make(map[string]string, 1) } - b.Status.Annotations["channelAddress"] = address + b.Status.Annotations[eventing.BrokerChannelAddressStatusAnnotationKey] = address } }