Skip to content

Commit 15a1333

Browse files
committed
add test case
1 parent 10fbf27 commit 15a1333

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

internal/controller/consumer_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,10 @@ func (r *ConsumerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
100100
}
101101

102102
if err := r.Provider.Delete(ctx, consumer); err != nil {
103-
r.Log.Error(err, "failed to delete consumer", "consumer", consumer)
104103
return ctrl.Result{}, err
105104
}
106105
return ctrl.Result{}, nil
107106
}
108-
r.Log.Error(err, "failed to get consumer", "consumer", consumer)
109107
return ctrl.Result{}, err
110108
}
111109

@@ -123,16 +121,13 @@ func (r *ConsumerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
123121
}
124122

125123
if err := r.updateStatus(ctx, consumer, statusErr); err != nil {
126-
r.Log.Error(err, "failed to update consumer status", "consumer", consumer)
127124
return ctrl.Result{}, err
128125
}
129126

130127
return ctrl.Result{}, nil
131128
}
132129

133130
func (r *ConsumerReconciler) processSepc(ctx context.Context, tctx *provider.TranslateContext, consumer *v1alpha1.Consumer) error {
134-
r.Log.Info("Processing consumer", "name", consumer.Name, "namespace", consumer.Namespace)
135-
136131
for _, credential := range consumer.Spec.Credentials {
137132
if credential.SecretRef == nil {
138133
continue
@@ -204,5 +199,10 @@ func (r *ConsumerReconciler) checkGatewayRef(object client.Object) bool {
204199
r.Log.Error(err, "failed to get gateway", "gateway", consumer.Spec.GatewayRef.Name)
205200
return false
206201
}
207-
return true
202+
gatewayClass := &gatewayv1.GatewayClass{}
203+
if err := r.Client.Get(context.Background(), client.ObjectKey{Name: string(gateway.Spec.GatewayClassName)}, gatewayClass); err != nil {
204+
r.Log.Error(err, "failed to get gateway class", "gateway", gateway.GetName(), "gatewayclass", gateway.Spec.GatewayClassName)
205+
return false
206+
}
207+
return matchesController(string(gatewayClass.Spec.ControllerName))
208208
}

internal/controller/status.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@ const (
1010
ConditionTypeProgressing string = "Progressing"
1111
ConditionTypeDegraded string = "Degraded"
1212

13-
ConditionReasonSynced string = "ResourceSynced"
13+
ConditionReasonSynced string = "ResourceSynced"
14+
ConditionReasonSyncAbort string = "ResourceSyncAbort"
1415
)
1516

1617
func NewCondition(observedGeneration int64, status bool, message string) metav1.Condition {
1718
condition := metav1.ConditionTrue
19+
reason := ConditionReasonSynced
1820
if !status {
1921
condition = metav1.ConditionFalse
22+
reason = ConditionReasonSyncAbort
2023
}
2124
return metav1.Condition{
2225
Type: ConditionTypeAvailable,
23-
Reason: ConditionReasonSynced,
26+
Reason: reason,
2427
Status: condition,
2528
Message: message,
2629
ObservedGeneration: observedGeneration,

0 commit comments

Comments
 (0)