gxthrj commented on a change in pull request #408: URL: https://github.com/apache/apisix-ingress-controller/pull/408#discussion_r621780238
########## File path: pkg/ingress/status.go ########## @@ -50,3 +52,49 @@ func recordRouteStatus(ar *configv2alpha1.ApisixRoute, reason, message string, s _, _ = kube.GetApisixClient().ApisixV2alpha1().ApisixRoutes(ar.Namespace). UpdateStatus(context.TODO(), ar, metav1.UpdateOptions{}) } + +// recordStatus record resources status +func recordStatus(at interface{}, reason string, err error, status v1.ConditionStatus) { + // build condition + message := fmt.Sprintf(_messageResourceSynced, _component) + if err != nil { + message = err.Error() + } + condition := metav1.Condition{ + Type: _conditionType, + Reason: reason, + Status: status, + Message: message, + } + + switch v := at.(type) { + case *configv1.ApisixTls: + // set to status + if v.Status.Conditions == nil { + conditions := make([]metav1.Condition, 0) + v.Status.Conditions = &conditions + } + meta.SetStatusCondition(v.Status.Conditions, condition) + _, _ = kube.GetApisixClient().ApisixV1().ApisixTlses(v.Namespace). + UpdateStatus(context.TODO(), v, metav1.UpdateOptions{}) + case *configv1.ApisixUpstream: + // set to status + if v.Status.Conditions == nil { + conditions := make([]metav1.Condition, 0) + v.Status.Conditions = &conditions + } + meta.SetStatusCondition(v.Status.Conditions, condition) + _, _ = kube.GetApisixClient().ApisixV1().ApisixUpstreams(v.Namespace). + UpdateStatus(context.TODO(), v, metav1.UpdateOptions{}) + case *configv2alpha1.ApisixRoute: + // set to status + if v.Status.Conditions == nil { + conditions := make([]metav1.Condition, 0) + v.Status.Conditions = &conditions + } + meta.SetStatusCondition(v.Status.Conditions, condition) + _, _ = kube.GetApisixClient().ApisixV2alpha1().ApisixRoutes(v.Namespace). + UpdateStatus(context.TODO(), v, metav1.UpdateOptions{}) Review comment: I think it is not necessary. Adding `default` will never be executed. The status is worked as logging, `panic` is Inappropriate. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org