tokers commented on a change in pull request #408:
URL:
https://github.com/apache/apisix-ingress-controller/pull/408#discussion_r622025153
##########
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:
that's for more rigorous processing. You know that's never happening
because you coded it. Onc a newbie tries to add some new features and they are
not familiar with the code base, they may make themselves in trouble, and the
explicit `panic` can help them capture easily in the development phase.
--
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:
[email protected]