Skip to content

Commit

Permalink
fix: add v2beta1 logic (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
gxthrj authored Aug 4, 2021
1 parent ac25764 commit d12a900
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pkg/ingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

configv1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v1"
configv2alpha1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2alpha1"
configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1"
"github.com/apache/apisix-ingress-controller/pkg/log"
)

Expand Down Expand Up @@ -94,6 +95,21 @@ func (c *Controller) recordStatus(at interface{}, reason string, err error, stat
zap.String("namespace", v.Namespace),
)
}
case *configv2beta1.ApisixRoute:
// set to status
if v.Status.Conditions == nil {
conditions := make([]metav1.Condition, 0)
v.Status.Conditions = conditions
}
meta.SetStatusCondition(&v.Status.Conditions, condition)
if _, errRecord := client.ApisixV2beta1().ApisixRoutes(v.Namespace).
UpdateStatus(context.TODO(), v, metav1.UpdateOptions{}); errRecord != nil {
log.Errorw("failed to record status change for ApisixRoute",
zap.Error(errRecord),
zap.String("name", v.Name),
zap.String("namespace", v.Namespace),
)
}
case *configv2alpha1.ApisixConsumer:
// set to status
if v.Status.Conditions == nil {
Expand Down
4 changes: 3 additions & 1 deletion pkg/kube/apisix_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ func (ar *apisixRoute) GroupVersion() string {
func (ar *apisixRoute) ResourceVersion() string {
if ar.groupVersion == ApisixRouteV1 {
return ar.V1().ResourceVersion
} else if ar.groupVersion == ApisixRouteV2alpha1 {
return ar.V2alpha1().ResourceVersion
}
return ar.V2alpha1().ResourceVersion
return ar.V2beta1().ResourceVersion
}

type apisixRouteLister struct {
Expand Down

0 comments on commit d12a900

Please sign in to comment.