tao12345666333 commented on code in PR #967:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/967#discussion_r855293350


##########
pkg/ingress/controller.go:
##########
@@ -259,6 +263,17 @@ func (c *Controller) initWhenStartLeading() {
                apisixRouteInformer = 
apisixFactory.Apisix().V2beta3().ApisixRoutes().Informer()
        case config.ApisixRouteV2:
                apisixRouteInformer = 
apisixFactory.Apisix().V2().ApisixRoutes().Informer()
+       default:
+               panic(fmt.Errorf("unsupported ApisixRoute version %s", 
c.cfg.Kubernetes.ApisixTlsVersion))
+       }
+
+       switch c.cfg.Kubernetes.ApisixTlsVersion {
+       case config.ApisixRouteV2beta3:
+               apisixTlsInformer = 
apisixFactory.Apisix().V2beta3().ApisixTlses().Informer()
+       case config.ApisixRouteV2:

Review Comment:
   ```suggestion
        case config.ApisixTlsV2:
   ```



##########
Makefile:
##########
@@ -84,6 +84,14 @@ ifeq ("$(wildcard $(GINKGO))", "")
        exit 1
 endif
 
+
+### push-ingress-images:  Build and push Ingress image used in e2e test suites 
to kind or custom registry.
+.PHONY: push-ingress-images
+push-ingress-images:
+       docker build -t apache/apisix-ingress-controller:$(IMAGE_TAG) 
--build-arg ENABLE_PROXY=$(ENABLE_PROXY) .

Review Comment:
   we can reuse `build-image` rule, right?



##########
pkg/ingress/compare.go:
##########
@@ -107,14 +107,14 @@ func (c *Controller) CompareResources(ctx 
context.Context) error {
                        // todo ApisixUpstream and ApisixPluginConfig
                        // ApisixUpstream and ApisixPluginConfig should be 
synced with ApisixRoute resource
 
-                       // ApisixSSL
+                       // ApisixSSL TODO: Support v2?

Review Comment:
   Will v2 support be put in the next PR? Or is it done in this PR?



##########
tools.go:
##########
@@ -1,3 +1,4 @@
+//go:build tools

Review Comment:
   Have you upgraded golang to v1.17+ locally?



##########
pkg/kube/apisix_tls.go:
##########
@@ -0,0 +1,167 @@
+// 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 kube
+
+import (
+       "fmt"
+
+       "github.com/apache/apisix-ingress-controller/pkg/config"
+       configv2 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2"
+       configv2beta3 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3"
+       listersv2 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2"
+       listersv2beta3 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta3"
+)
+
+// ApisixTlsLister is an encapsulation for the lister of ApisixTls,
+// it aims at to be compatible with different ApisixTls versions.
+type ApisixTlsLister interface {
+       // V2beta3 gets the ApisixTls in apisix.apache.org/v2beta3.
+       V2beta3(string, string) (ApisixTls, error)
+       // V2 gets the ApisixTls in apisix.apache.org/v2.
+       V2(string, string) (ApisixTls, error)
+}
+
+// ApisixTlsInformer is an encapsulation for the informer of ApisixTls,
+// it aims at to be compatible with different ApisixTls versions.
+type ApisixTlsInformer interface {
+       Run(chan struct{})
+}
+
+// ApisixTls is an encapsulation for ApisixTls resource with different
+// versions, for now, they are apisix.apache.org/v1 and 
apisix.apache.org/v2alpha1
+type ApisixTls interface {
+       // GroupVersion returns the api group version of the
+       // real ApisixTls.
+       GroupVersion() string
+       // V2beta3 returns the ApisixTls in apisix.apache.org/v2beta3, the real
+       // ApisixTls must be in this group version, otherwise will panic.
+       V2beta3() *configv2beta3.ApisixTls
+       // V2 returns the ApisixTls in apisix.apache.org/v2, the real
+       // ApisixTls must be in this group version, otherwise will panic.
+       V2() *configv2.ApisixTls
+       // ResourceVersion returns the the resource version field inside
+       // the real ApisixTls.
+       ResourceVersion() string
+}
+
+// ApisixTlsEvent contains the ApisixTls key (namespace/name)
+// and the group version message.
+type ApisixTlsEvent struct {
+       Key          string
+       OldObject    ApisixTls
+       GroupVersion string
+}
+
+type apisixTls struct {
+       groupVersion string
+       v2beta3      *configv2beta3.ApisixTls
+       v2           *configv2.ApisixTls
+}
+
+func (ar *apisixTls) V2beta3() *configv2beta3.ApisixTls {
+       if ar.groupVersion != config.ApisixTlsV2beta3 {
+               panic("not a apisix.apache.org/v2beta3 route")

Review Comment:
   ```suggestion
                panic("not a apisix.apache.org/v2beta3 Tls")
   ```



##########
pkg/kube/apisix_tls.go:
##########
@@ -0,0 +1,167 @@
+// 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 kube
+
+import (
+       "fmt"
+
+       "github.com/apache/apisix-ingress-controller/pkg/config"
+       configv2 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2"
+       configv2beta3 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3"
+       listersv2 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2"
+       listersv2beta3 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta3"
+)
+
+// ApisixTlsLister is an encapsulation for the lister of ApisixTls,
+// it aims at to be compatible with different ApisixTls versions.
+type ApisixTlsLister interface {
+       // V2beta3 gets the ApisixTls in apisix.apache.org/v2beta3.
+       V2beta3(string, string) (ApisixTls, error)
+       // V2 gets the ApisixTls in apisix.apache.org/v2.
+       V2(string, string) (ApisixTls, error)
+}
+
+// ApisixTlsInformer is an encapsulation for the informer of ApisixTls,
+// it aims at to be compatible with different ApisixTls versions.
+type ApisixTlsInformer interface {
+       Run(chan struct{})
+}
+
+// ApisixTls is an encapsulation for ApisixTls resource with different
+// versions, for now, they are apisix.apache.org/v1 and 
apisix.apache.org/v2alpha1
+type ApisixTls interface {
+       // GroupVersion returns the api group version of the
+       // real ApisixTls.
+       GroupVersion() string
+       // V2beta3 returns the ApisixTls in apisix.apache.org/v2beta3, the real
+       // ApisixTls must be in this group version, otherwise will panic.
+       V2beta3() *configv2beta3.ApisixTls
+       // V2 returns the ApisixTls in apisix.apache.org/v2, the real
+       // ApisixTls must be in this group version, otherwise will panic.
+       V2() *configv2.ApisixTls
+       // ResourceVersion returns the the resource version field inside
+       // the real ApisixTls.
+       ResourceVersion() string
+}
+
+// ApisixTlsEvent contains the ApisixTls key (namespace/name)
+// and the group version message.
+type ApisixTlsEvent struct {
+       Key          string
+       OldObject    ApisixTls
+       GroupVersion string
+}
+
+type apisixTls struct {
+       groupVersion string
+       v2beta3      *configv2beta3.ApisixTls
+       v2           *configv2.ApisixTls
+}
+
+func (ar *apisixTls) V2beta3() *configv2beta3.ApisixTls {

Review Comment:
   If the meaning of `ar` is `APISIX resource` , then we can go ahead and use 
it. 
   Otherwise a clearer name should be used, right?



##########
pkg/kube/apisix_tls.go:
##########
@@ -0,0 +1,167 @@
+// 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 kube
+
+import (
+       "fmt"
+
+       "github.com/apache/apisix-ingress-controller/pkg/config"
+       configv2 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2"
+       configv2beta3 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3"
+       listersv2 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2"
+       listersv2beta3 
"github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta3"
+)
+
+// ApisixTlsLister is an encapsulation for the lister of ApisixTls,
+// it aims at to be compatible with different ApisixTls versions.
+type ApisixTlsLister interface {
+       // V2beta3 gets the ApisixTls in apisix.apache.org/v2beta3.
+       V2beta3(string, string) (ApisixTls, error)
+       // V2 gets the ApisixTls in apisix.apache.org/v2.
+       V2(string, string) (ApisixTls, error)
+}
+
+// ApisixTlsInformer is an encapsulation for the informer of ApisixTls,
+// it aims at to be compatible with different ApisixTls versions.
+type ApisixTlsInformer interface {
+       Run(chan struct{})
+}
+
+// ApisixTls is an encapsulation for ApisixTls resource with different
+// versions, for now, they are apisix.apache.org/v1 and 
apisix.apache.org/v2alpha1
+type ApisixTls interface {
+       // GroupVersion returns the api group version of the
+       // real ApisixTls.
+       GroupVersion() string
+       // V2beta3 returns the ApisixTls in apisix.apache.org/v2beta3, the real
+       // ApisixTls must be in this group version, otherwise will panic.
+       V2beta3() *configv2beta3.ApisixTls
+       // V2 returns the ApisixTls in apisix.apache.org/v2, the real
+       // ApisixTls must be in this group version, otherwise will panic.
+       V2() *configv2.ApisixTls
+       // ResourceVersion returns the the resource version field inside
+       // the real ApisixTls.
+       ResourceVersion() string
+}
+
+// ApisixTlsEvent contains the ApisixTls key (namespace/name)
+// and the group version message.
+type ApisixTlsEvent struct {
+       Key          string
+       OldObject    ApisixTls
+       GroupVersion string
+}
+
+type apisixTls struct {
+       groupVersion string
+       v2beta3      *configv2beta3.ApisixTls
+       v2           *configv2.ApisixTls
+}
+
+func (ar *apisixTls) V2beta3() *configv2beta3.ApisixTls {
+       if ar.groupVersion != config.ApisixTlsV2beta3 {
+               panic("not a apisix.apache.org/v2beta3 route")
+       }
+       return ar.v2beta3
+}
+func (ar *apisixTls) V2() *configv2.ApisixTls {
+       if ar.groupVersion != config.ApisixTlsV2 {
+               panic("not a apisix.apache.org/v2 route")

Review Comment:
   ```suggestion
                panic("not a apisix.apache.org/v2 Tls")
   ```



##########
pkg/ingress/controller.go:
##########
@@ -259,6 +263,17 @@ func (c *Controller) initWhenStartLeading() {
                apisixRouteInformer = 
apisixFactory.Apisix().V2beta3().ApisixRoutes().Informer()
        case config.ApisixRouteV2:
                apisixRouteInformer = 
apisixFactory.Apisix().V2().ApisixRoutes().Informer()
+       default:
+               panic(fmt.Errorf("unsupported ApisixRoute version %s", 
c.cfg.Kubernetes.ApisixTlsVersion))
+       }
+
+       switch c.cfg.Kubernetes.ApisixTlsVersion {
+       case config.ApisixRouteV2beta3:

Review Comment:
   ```suggestion
        case config.ApisixTlsV2beta3:
   ```



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

Reply via email to