tokers commented on a change in pull request #147:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/147#discussion_r552630285



##########
File path: pkg/apisix/resource.go
##########
@@ -0,0 +1,208 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package apisix
+
+import (
+       "encoding/json"
+       "errors"
+       "fmt"
+       "net"
+       "strconv"
+       "strings"
+
+       v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
+)
+
+// listResponse is the unified LIST response mapping of APISIX.
+type listResponse struct {
+       Count string `json:"count"`
+       Node  node   `json:"node"`
+}
+
+type createResponse struct {
+       Action string `json:"action"`
+       Item   item   `json:"node"`
+}
+
+type node struct {
+       Key   string `json:"key"`
+       Items items  `json:"nodes"`
+}
+
+type items []item
+
+// items implements json.Unmarshaler interface.
+// lua-cjson doesn't distinguish empty array and table,
+// and by default empty array will be encoded as '{}'.
+// We have to maintain the compatibility.
+func (items *items) UnmarshalJSON(p []byte) error {
+       if p[0] == '{' {
+               if len(p) != 2 {
+                       return errors.New("unexpected non-empty object")
+               }
+               return nil
+       }
+       var data []item
+       if err := json.Unmarshal(p, &data); err != nil {
+               return err
+       }
+       *items = data
+       return nil
+}
+
+type item struct {
+       Key   string          `json:"key"`
+       Value json.RawMessage `json:"value"`
+}
+
+type routeItem struct {
+       UpstreamId *string                `json:"upstream_id"`
+       ServiceId  *string                `json:"service_id"`
+       Host       *string                `json:"host"`
+       URI        *string                `json:"uri"`
+       Desc       *string                `json:"desc"`
+       Methods    []*string              `json:"methods"`
+       Plugins    map[string]interface{} `json:"plugins"`
+}
+
+// route decodes item.Value and converts it to v1.Route.
+func (i *item) route(group string) (*v1.Route, error) {

Review comment:
       Even if the Lua admin api is in use, after the ingress controller is 
capable to filter namespaces, the multi cluster can be supported by deploying 
multiple ingress controller instances in different namespaces (with their 
corresponding APISIX instances) and watches their own namespace. That's more 
concise, from design's point of view.




----------------------------------------------------------------
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]


Reply via email to