@@ -103,48 +103,52 @@ func (r *secretReconciler) buildConfigSecret(ctx context.Context, rb *eventingv1
103103 "Failed to list triggers: %w" , err )
104104 }
105105
106- // TODO triggers must have resolved the URI, check status.
107-
108106 cfg := & config.Config {}
109107 for _ , t := range triggers {
110- if ! t .ReferencesBroker (rb ) {
108+ // Generate secret even if the trigger is not ready, as long as one of the URIs for target
109+ // or DLS exist.
110+ if ! t .ReferencesBroker (rb ) || (t .Status .TargetURI == nil && t .Status .DeadLetterSinkURI == nil ) {
111111 continue
112112 }
113113
114- target := ""
115- if t .Spec .Target .URI != nil {
116- target = t .Spec .Target .URI .String ()
117- // } else {
118- // TODO resolve target to URL
114+ targetURI := ""
115+ if t .Status .TargetURI != nil {
116+ targetURI = t .Status .TargetURI .String ()
117+ } else {
118+ // Configure empty URL so that all requests go to DLS when the target is
119+ // not ready.
120+ targetURI = "http://"
119121 }
120122
121- // TODO convert DeliveryOptions
122123 do := & config.DeliveryOptions {}
123124 if t .Spec .Delivery != nil {
124125 do .Retry = t .Spec .Delivery .Retry
125126 do .BackoffDelay = t .Spec .Delivery .BackoffDelay
126127
127128 if t .Spec .Delivery .BackoffPolicy != nil {
129+ var bop config.BackoffPolicyType
128130 switch * t .Spec .Delivery .BackoffPolicy {
129131 case duckv1 .BackoffPolicyLinear :
130- * do . BackoffPolicy = config .BackoffPolicyLinear
132+ bop = config .BackoffPolicyLinear
131133
132134 case duckv1 .BackoffPolicyExponential :
133- * do . BackoffPolicy = config .BackoffPolicyExponential
135+ bop = config .BackoffPolicyLinear
134136 }
137+ do .BackoffPolicy = & bop
135138 }
136139
137- // TODO resolve reference to URI
138- uri := t .Spec .Delivery .DeadLetterSink .URI .String ()
139- do .DeadLetterURL = & uri
140+ if t .Status .DeadLetterSinkURI != nil {
141+ uri := t .Status .DeadLetterSinkURI .String ()
142+ do .DeadLetterURL = & uri
143+ }
140144 }
141145
142146 trg := config.Trigger {
143147 Name : t .Name ,
144148 Filters : t .Spec .Filters ,
145149 Targets : []config.Target {
146150 {
147- URL : target ,
151+ URL : targetURI ,
148152 DeliveryOptions : do ,
149153 },
150154 },
0 commit comments