gxthrj commented on a change in pull request #576:
URL:
https://github.com/apache/apisix-ingress-controller/pull/576#discussion_r667338388
##########
File path: pkg/kube/translation/apisix_route.go
##########
@@ -133,6 +134,150 @@ func (t *translator) translateHTTPRouteNotStrictly(ctx
*TranslateContext, ar *co
return nil
}
+func (t *translator) TranslateRouteV2beta1(ar *configv2beta1.ApisixRoute)
(*TranslateContext, error) {
+ ctx := &TranslateContext{
+ upstreamMap: make(map[string]struct{}),
+ }
+
+ if err := t.translateHTTPRouteV2beta1(ctx, ar); err != nil {
+ return nil, err
+ }
+ if err := t.translateStreamRoute(ctx, ar); err != nil {
+ return nil, err
+ }
+ return ctx, nil
+}
+
+func (t *translator) TranslateRouteV2beta1NotStrictly(ar
*configv2beta1.ApisixRoute) (*TranslateContext, error) {
+ ctx := &TranslateContext{
+ upstreamMap: make(map[string]struct{}),
+ }
+
+ if err := t.translateHTTPRouteV2beta1NotStrictly(ctx, ar); err != nil {
+ return nil, err
+ }
+ if err := t.translateStreamRouteNotStrictly(ctx, ar); err != nil {
+ return nil, err
+ }
+ return ctx, nil
+}
+
+func (t *translator) translateHTTPRouteV2beta1(ctx *TranslateContext, ar
*configv2beta1.ApisixRoute) error {
+ ruleNameMap := make(map[string]struct{})
+ for _, part := range ar.Spec.HTTP {
+ if _, ok := ruleNameMap[part.Name]; ok {
+ return errors.New("duplicated route rule name")
+ }
+ ruleNameMap[part.Name] = struct{}{}
+ backends := part.Backends
+ backend := part.Backend
+ if len(backends) > 0 {
+ // Use the first backend as the default backend in
Route,
+ // others will be configured in traffic-split plugin.
+ backend = backends[0]
+ backends = backends[1:]
+ } // else use the deprecated Backend.
+
+ svcClusterIP, svcPort, err :=
t.getServiceClusterIPAndPort(&backend, ar.Namespace)
+ if err != nil {
+ log.Errorw("failed to get service port in backend",
+ zap.Any("backend", backend),
+ zap.Any("apisix_route", ar),
+ zap.Error(err),
+ )
+ return err
+ }
+
+ pluginMap := make(apisixv1.Plugins)
+ // 2.add route plugins
Review comment:
done
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]