diff --git a/cmd/ingress/ingress.go b/cmd/ingress/ingress.go index b30de0ff88..ed4b2df897 100644 --- a/cmd/ingress/ingress.go +++ b/cmd/ingress/ingress.go @@ -161,7 +161,7 @@ For example, no available LB exists in the bare metal environment.`) cmd.PersistentFlags().StringVar(&cfg.Kubernetes.IngressClass, "ingress-class", config.IngressClass, "the class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.18.0 or higher or the annotation \"kubernetes.io/ingress.class\" (deprecated)") cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ElectionID, "election-id", config.IngressAPISIXLeader, "election id used for campaign the controller leader") cmd.PersistentFlags().StringVar(&cfg.Kubernetes.IngressVersion, "ingress-version", config.IngressNetworkingV1, "the supported ingress api group version, can be \"networking/v1beta1\", \"networking/v1\" (for Kubernetes version v1.19.0 or higher) and \"extensions/v1beta1\"") - cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixRouteVersion, "apisix-route-version", config.ApisixRouteV2beta3, "the supported apisixroute api group version, can be \"apisix.apache.org/v2beta1\" or \"apisix.apache.org/v2beta2\" or \"apisix.apache.org/v2beta3\"") + cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixRouteVersion, "apisix-route-version", config.ApisixRouteV2beta3, "the supported apisixroute api group version, can be \"apisix.apache.org/v2beta2\" or \"apisix.apache.org/v2beta3\"") cmd.PersistentFlags().BoolVar(&cfg.Kubernetes.WatchEndpointSlices, "watch-endpointslices", false, "whether to watch endpointslices rather than endpoints") cmd.PersistentFlags().BoolVar(&cfg.Kubernetes.EnableGatewayAPI, "enable-gateway-api", false, "whether to enable support for Gateway API") cmd.PersistentFlags().StringVar(&cfg.APISIX.DefaultClusterBaseURL, "default-apisix-cluster-base-url", "", "the base URL of admin api / manager api for the default APISIX cluster") diff --git a/pkg/api/validation/apisix_consumer.go b/pkg/api/validation/apisix_consumer.go index fc7add2143..ce8c365d72 100644 --- a/pkg/api/validation/apisix_consumer.go +++ b/pkg/api/validation/apisix_consumer.go @@ -26,7 +26,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/apache/apisix-ingress-controller/pkg/apisix" - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" "github.com/apache/apisix-ingress-controller/pkg/log" @@ -44,8 +43,6 @@ var ApisixConsumerValidator = kwhvalidating.ValidatorFunc( var spec interface{} switch ac := object.(type) { - case *v2beta1.ApisixRoute: - spec = ac.Spec case *v2beta2.ApisixRoute: spec = ac.Spec case *v2beta3.ApisixRoute: diff --git a/pkg/api/validation/apisix_route.go b/pkg/api/validation/apisix_route.go index 0f6df7007b..d43a532bf6 100644 --- a/pkg/api/validation/apisix_route.go +++ b/pkg/api/validation/apisix_route.go @@ -28,7 +28,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/apache/apisix-ingress-controller/pkg/apisix" - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" "github.com/apache/apisix-ingress-controller/pkg/log" @@ -67,18 +66,6 @@ var ApisixRouteValidator = kwhvalidating.ValidatorFunc( } } } - case *v2beta1.ApisixRoute: - spec = ar.Spec - - for _, h := range ar.Spec.HTTP { - for _, p := range h.Plugins { - if p.Enable { - plugins = append(plugins, apisixRoutePlugin{ - p.Name, p.Config, - }) - } - } - } case *v2beta3.ApisixRoute: spec = ar.Spec diff --git a/pkg/api/validation/apisix_route_test.go b/pkg/api/validation/apisix_route_test.go index 9af3b78346..34ecd53dde 100644 --- a/pkg/api/validation/apisix_route_test.go +++ b/pkg/api/validation/apisix_route_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/apache/apisix-ingress-controller/pkg/apisix" - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" api "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" @@ -124,12 +123,7 @@ func Test_validatePlugin(t *testing.T) { fakeClient := newFakeSchemaClient() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotValid, _ := validatePlugin(fakeClient, tt.pluginName, v2beta1.ApisixRouteHTTPPluginConfig(tt.pluginConfig)) - if gotValid != tt.wantValid { - t.Errorf("validatePlugin() gotValid = %v, want %v", gotValid, tt.wantValid) - } - - gotValid, _ = validatePlugin(fakeClient, tt.pluginName, v2beta3.ApisixRouteHTTPPluginConfig(tt.pluginConfig)) + gotValid, _ := validatePlugin(fakeClient, tt.pluginName, v2beta3.ApisixRouteHTTPPluginConfig(tt.pluginConfig)) if gotValid != tt.wantValid { t.Errorf("validatePlugin() gotValid = %v, want %v", gotValid, tt.wantValid) } diff --git a/pkg/api/validation/apisix_tls.go b/pkg/api/validation/apisix_tls.go index aa86e67e3a..f7a27d62a5 100644 --- a/pkg/api/validation/apisix_tls.go +++ b/pkg/api/validation/apisix_tls.go @@ -26,7 +26,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/apache/apisix-ingress-controller/pkg/apisix" - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" "github.com/apache/apisix-ingress-controller/pkg/log" @@ -44,8 +43,6 @@ var ApisixTlsValidator = kwhvalidating.ValidatorFunc( var spec interface{} switch at := object.(type) { - case *v2beta1.ApisixRoute: - spec = at.Spec case *v2beta2.ApisixRoute: spec = at.Spec case *v2beta3.ApisixRoute: diff --git a/pkg/api/validation/apisix_upstream.go b/pkg/api/validation/apisix_upstream.go index bb774d7074..6d3f187f05 100644 --- a/pkg/api/validation/apisix_upstream.go +++ b/pkg/api/validation/apisix_upstream.go @@ -26,7 +26,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/apache/apisix-ingress-controller/pkg/apisix" - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" "github.com/apache/apisix-ingress-controller/pkg/log" @@ -44,8 +43,6 @@ var ApisixUpstreamValidator = kwhvalidating.ValidatorFunc( var spec interface{} switch au := object.(type) { - case *v2beta1.ApisixRoute: - spec = au.Spec case *v2beta2.ApisixRoute: spec = au.Spec case *v2beta3.ApisixRoute: diff --git a/pkg/config/config.go b/pkg/config/config.go index 77937d0599..3c327a98d8 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -51,8 +51,6 @@ const ( // WARNING: ingress.extensions/v1beta1 is deprecated in v1.14+, and will be unavilable // in v1.22. IngressExtensionsV1beta1 = "extensions/v1beta1" - // ApisixRouteV2beta1 represents apisixroute.apisix.apache.org/v2beta1 - ApisixRouteV2beta1 = "apisix.apache.org/v2beta1" // ApisixRouteV2beta2 represents apisixroute.apisix.apache.org/v2beta2 ApisixRouteV2beta2 = "apisix.apache.org/v2beta2" // ApisixRouteV2beta3 represents apisixroute.apisix.apache.org/v2beta3 diff --git a/pkg/ingress/apisix_route.go b/pkg/ingress/apisix_route.go index dc7f41ede6..6c0a1dddee 100644 --- a/pkg/ingress/apisix_route.go +++ b/pkg/ingress/apisix_route.go @@ -97,8 +97,6 @@ func (c *apisixRouteController) sync(ctx context.Context, ev *types.Event) error tctx *translation.TranslateContext ) switch obj.GroupVersion { - case kube.ApisixRouteV2beta1: - ar, err = c.controller.apisixRouteLister.V2beta1(namespace, name) case kube.ApisixRouteV2beta2: ar, err = c.controller.apisixRouteLister.V2beta2(namespace, name) case kube.ApisixRouteV2beta3: @@ -136,19 +134,6 @@ func (c *apisixRouteController) sync(ctx context.Context, ev *types.Event) error } switch obj.GroupVersion { - case kube.ApisixRouteV2beta1: - if ev.Type != types.EventDelete { - tctx, err = c.controller.translator.TranslateRouteV2beta1(ar.V2beta1()) - } else { - tctx, err = c.controller.translator.TranslateRouteV2beta1NotStrictly(ar.V2beta1()) - } - if err != nil { - log.Errorw("failed to translate ApisixRoute v2beta1", - zap.Error(err), - zap.Any("object", ar), - ) - return err - } case kube.ApisixRouteV2beta2: if ev.Type != types.EventDelete { tctx, err = c.controller.translator.TranslateRouteV2beta2(ar.V2beta2()) @@ -206,8 +191,6 @@ func (c *apisixRouteController) sync(ctx context.Context, ev *types.Event) error } else { var oldCtx *translation.TranslateContext switch obj.GroupVersion { - case kube.ApisixRouteV2beta1: - oldCtx, err = c.controller.translator.TranslateRouteV2beta1(obj.OldObject.V2beta1()) case kube.ApisixRouteV2beta2: oldCtx, err = c.controller.translator.TranslateRouteV2beta2(obj.OldObject.V2beta2()) case kube.ApisixRouteV2beta3: @@ -279,8 +262,6 @@ func (c *apisixRouteController) handleSyncErr(obj interface{}, errOrigin error) switch event.GroupVersion { case kube.ApisixRouteV2beta3: ar, errLocal = c.controller.apisixRouteLister.V2beta3(namespace, name) - case kube.ApisixRouteV2beta1: - ar, errLocal = c.controller.apisixRouteLister.V2beta1(namespace, name) case kube.ApisixRouteV2beta2: ar, errLocal = c.controller.apisixRouteLister.V2beta2(namespace, name) } @@ -288,9 +269,6 @@ func (c *apisixRouteController) handleSyncErr(obj interface{}, errOrigin error) if ev.Type != types.EventDelete { if errLocal == nil { switch ar.GroupVersion() { - case kube.ApisixRouteV2beta1: - c.controller.recorderEvent(ar.V2beta1(), v1.EventTypeNormal, _resourceSynced, nil) - c.controller.recordStatus(ar.V2beta1(), _resourceSynced, nil, metav1.ConditionTrue, ar.V2beta1().GetGeneration()) case kube.ApisixRouteV2beta2: c.controller.recorderEvent(ar.V2beta2(), v1.EventTypeNormal, _resourceSynced, nil) c.controller.recordStatus(ar.V2beta2(), _resourceSynced, nil, metav1.ConditionTrue, ar.V2beta2().GetGeneration()) @@ -316,9 +294,6 @@ func (c *apisixRouteController) handleSyncErr(obj interface{}, errOrigin error) ) if errLocal == nil { switch ar.GroupVersion() { - case kube.ApisixRouteV2beta1: - c.controller.recorderEvent(ar.V2beta1(), v1.EventTypeWarning, _resourceSyncAborted, errOrigin) - c.controller.recordStatus(ar.V2beta1(), _resourceSyncAborted, errOrigin, metav1.ConditionFalse, ar.V2beta1().GetGeneration()) case kube.ApisixRouteV2beta2: c.controller.recorderEvent(ar.V2beta2(), v1.EventTypeWarning, _resourceSyncAborted, errOrigin) c.controller.recordStatus(ar.V2beta2(), _resourceSyncAborted, errOrigin, metav1.ConditionFalse, ar.V2beta2().GetGeneration()) diff --git a/pkg/ingress/controller.go b/pkg/ingress/controller.go index ecb8c007c4..b7a52d27f3 100644 --- a/pkg/ingress/controller.go +++ b/pkg/ingress/controller.go @@ -219,7 +219,6 @@ func (c *Controller) initWhenStartLeading() { ) c.secretLister = kubeFactory.Core().V1().Secrets().Lister() c.apisixRouteLister = kube.NewApisixRouteLister( - apisixFactory.Apisix().V2beta1().ApisixRoutes().Lister(), apisixFactory.Apisix().V2beta2().ApisixRoutes().Lister(), apisixFactory.Apisix().V2beta3().ApisixRoutes().Lister(), ) @@ -253,8 +252,6 @@ func (c *Controller) initWhenStartLeading() { c.gatewayInformer = gatewayFactory.Gateway().V1alpha2().Gateways().Informer() switch c.cfg.Kubernetes.ApisixRouteVersion { - case config.ApisixRouteV2beta1: - apisixRouteInformer = apisixFactory.Apisix().V2beta1().ApisixRoutes().Informer() case config.ApisixRouteV2beta2: apisixRouteInformer = apisixFactory.Apisix().V2beta2().ApisixRoutes().Informer() case config.ApisixRouteV2beta3: diff --git a/pkg/ingress/status.go b/pkg/ingress/status.go index 2bbac5be85..67c00f556f 100644 --- a/pkg/ingress/status.go +++ b/pkg/ingress/status.go @@ -32,7 +32,6 @@ import ( "k8s.io/client-go/tools/cache" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" configv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" configv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" "github.com/apache/apisix-ingress-controller/pkg/log" @@ -109,23 +108,6 @@ func (c *Controller) recordStatus(at interface{}, reason string, err error, stat ) } } - case *configv2beta1.ApisixRoute: - // set to status - if v.Status.Conditions == nil { - conditions := make([]metav1.Condition, 0) - v.Status.Conditions = conditions - } - if c.verifyGeneration(&v.Status.Conditions, condition) { - 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 *configv2beta2.ApisixRoute: // set to status if v.Status.Conditions == nil { diff --git a/pkg/kube/apisix/apis/config/v2beta1/doc.go b/pkg/kube/apisix/apis/config/v2beta1/doc.go deleted file mode 100644 index 51aa7e9f5d..0000000000 --- a/pkg/kube/apisix/apis/config/v2beta1/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -// +k8s:deepcopy-gen=package -// +groupName=apisix.apache.org -package v2beta1 diff --git a/pkg/kube/apisix/apis/config/v2beta1/types.go b/pkg/kube/apisix/apis/config/v2beta1/types.go deleted file mode 100644 index 8ebf312921..0000000000 --- a/pkg/kube/apisix/apis/config/v2beta1/types.go +++ /dev/null @@ -1,199 +0,0 @@ -// 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 v2beta1 - -import ( - "encoding/json" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" - - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:subresource:status -// ApisixRoute is used to define the route rules and upstreams for Apache APISIX. -type ApisixRoute struct { - metav1.TypeMeta `json:",inline" yaml:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"` - Spec ApisixRouteSpec `json:"spec,omitempty" yaml:"spec,omitempty"` - Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"` -} - -// ApisixStatus is the status report for Apisix ingress Resources -type ApisixStatus struct { - Conditions []metav1.Condition `json:"conditions,omitempty" yaml:"conditions,omitempty"` -} - -// ApisixRouteSpec is the spec definition for ApisixRouteSpec. -type ApisixRouteSpec struct { - HTTP []ApisixRouteHTTP `json:"http,omitempty" yaml:"http,omitempty"` - Stream []ApisixRouteStream `json:"stream,omitempty" yaml:"stream,omitempty"` -} - -// UpstreamTimeout is settings for the read, send and connect to the upstream. -type UpstreamTimeout struct { - Connect metav1.Duration `json:"connect,omitempty" yaml:"connect,omitempty"` - Send metav1.Duration `json:"send,omitempty" yaml:"send,omitempty"` - Read metav1.Duration `json:"read,omitempty" yaml:"read,omitempty"` -} - -// ApisixRouteHTTP represents a single route in for HTTP traffic. -type ApisixRouteHTTP struct { - // The rule name, cannot be empty. - Name string `json:"name" yaml:"name"` - // Route priority, when multiple routes contains - // same URI path (for path matching), route with - // higher priority will take effect. - Priority int `json:"priority,omitempty" yaml:"priority,omitempty"` - Timeout *UpstreamTimeout `json:"timeout,omitempty" yaml:"timeout,omitempty"` - Match ApisixRouteHTTPMatch `json:"match,omitempty" yaml:"match,omitempty"` - // Deprecated: Backend will be removed in the future, use Backends instead. - Backend v2beta3.ApisixRouteHTTPBackend `json:"backend,omitempty" yaml:"backend,omitempty"` - // Backends represents potential backends to proxy after the route - // rule matched. When number of backends are more than one, traffic-split - // plugin in APISIX will be used to split traffic based on the backend weight. - Backends []v2beta3.ApisixRouteHTTPBackend `json:"backends,omitempty" yaml:"backends,omitempty"` - Websocket bool `json:"websocket" yaml:"websocket"` - Plugins []ApisixRouteHTTPPlugin `json:"plugins,omitempty" yaml:"plugins,omitempty"` - Authentication ApisixRouteAuthentication `json:"authentication,omitempty" yaml:"authentication,omitempty"` -} - -// ApisixRouteHTTPMatch represents the match condition for hitting this route. -type ApisixRouteHTTPMatch struct { - // URI path predicates, at least one path should be - // configured, path could be exact or prefix, for prefix path, - // append "*" after it, for instance, "/foo*". - Paths []string `json:"paths" yaml:"paths"` - // HTTP request method predicates. - Methods []string `json:"methods,omitempty" yaml:"methods,omitempty"` - // HTTP Host predicates, host can be a wildcard domain or - // an exact domain. For wildcard domain, only one generic - // level is allowed, for instance, "*.foo.com" is valid but - // "*.*.foo.com" is not. - Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"` - // Remote address predicates, items can be valid IPv4 address - // or IPv6 address or CIDR. - RemoteAddrs []string `json:"remoteAddrs,omitempty" yaml:"remoteAddrs,omitempty"` - // NginxVars represents generic match predicates, - // it uses Nginx variable systems, so any predicate - // like headers, querystring and etc can be leveraged - // here to match the route. - // For instance, it can be: - // nginxVars: - // - subject: "$remote_addr" - // op: in - // value: - // - "127.0.0.1" - // - "10.0.5.11" - NginxVars []v2beta3.ApisixRouteHTTPMatchExpr `json:"exprs,omitempty" yaml:"exprs,omitempty"` -} - -// ApisixRouteHTTPMatchExprSubject describes the route match expression subject. -type ApisixRouteHTTPMatchExprSubject struct { - // The subject scope, can be: - // ScopeQuery, ScopeHeader, ScopePath - // when subject is ScopePath, Name field - // will be ignored. - Scope string `json:"scope" yaml:"scope"` - // The name of subject. - Name string `json:"name" yaml:"name"` -} - -// ApisixRouteHTTPPlugin represents an APISIX plugin. -type ApisixRouteHTTPPlugin struct { - // The plugin name. - Name string `json:"name" yaml:"name"` - // Whether this plugin is in use, default is true. - Enable bool `json:"enable" yaml:"enable"` - // Plugin configuration. - Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"` -} - -// ApisixRouteHTTPPluginConfig is the configuration for -// any plugins. -type ApisixRouteHTTPPluginConfig map[string]interface{} - -// ApisixRouteAuthentication is the authentication-related -// configuration in ApisixRoute. -type ApisixRouteAuthentication struct { - Enable bool `json:"enable" yaml:"enable"` - Type string `json:"type" yaml:"type"` - KeyAuth ApisixRouteAuthenticationKeyAuth `json:"keyauth,omitempty" yaml:"keyauth,omitempty"` -} - -// ApisixRouteAuthenticationKeyAuth is the keyAuth-related -// configuration in ApisixRouteAuthentication. -type ApisixRouteAuthenticationKeyAuth struct { - Header string `json:"header,omitempty" yaml:"header,omitempty"` -} - -func (p ApisixRouteHTTPPluginConfig) DeepCopyInto(out *ApisixRouteHTTPPluginConfig) { - b, _ := json.Marshal(&p) - _ = json.Unmarshal(b, out) -} - -func (p *ApisixRouteHTTPPluginConfig) DeepCopy() *ApisixRouteHTTPPluginConfig { - if p == nil { - return nil - } - out := new(ApisixRouteHTTPPluginConfig) - p.DeepCopyInto(out) - return out -} - -// ApisixRouteStream is the configuration for level 4 route -type ApisixRouteStream struct { - // The rule name, cannot be empty. - Name string `json:"name" yaml:"name"` - Protocol string `json:"protocol" yaml:"protocol"` - Match ApisixRouteStreamMatch `json:"match" yaml:"match"` - Backend ApisixRouteStreamBackend `json:"backend" yaml:"backend"` -} - -// ApisixRouteStreamMatch represents the match conditions of stream route. -type ApisixRouteStreamMatch struct { - // IngressPort represents the port listening on the Ingress proxy server. - // It should be pre-defined as APISIX doesn't support dynamic listening. - IngressPort int32 `json:"ingressPort" yaml:"ingressPort"` -} - -// ApisixRouteStreamBackend represents a TCP backend (a Kubernetes Service). -type ApisixRouteStreamBackend struct { - // The name (short) of the service, note cross namespace is forbidden, - // so be sure the ApisixRoute and Service are in the same namespace. - ServiceName string `json:"serviceName" yaml:"serviceName"` - // The service port, could be the name or the port number. - ServicePort intstr.IntOrString `json:"servicePort" yaml:"servicePort"` - // The resolve granularity, can be "endpoints" or "service", - // when set to "endpoints", the pod ips will be used; other - // wise, the service ClusterIP or ExternalIP will be used, - // default is endpoints. - ResolveGranularity string `json:"resolveGranularity,omitempty" yaml:"resolveGranularity,omitempty"` - // Subset specifies a subset for the target Service. The subset should be pre-defined - // in ApisixUpstream about this service. - Subset string `json:"subset,omitempty" yaml:"subset,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ApisixRouteList contains a list of ApisixRoute. -type ApisixRouteList struct { - metav1.TypeMeta `json:",inline" yaml:",inline"` - metav1.ListMeta `json:"metadata" yaml:"metadata"` - Items []ApisixRoute `json:"items,omitempty" yaml:"items,omitempty"` -} diff --git a/pkg/kube/apisix/apis/config/v2beta1/zz_generated.deepcopy.go b/pkg/kube/apisix/apis/config/v2beta1/zz_generated.deepcopy.go deleted file mode 100644 index e927daae65..0000000000 --- a/pkg/kube/apisix/apis/config/v2beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,355 +0,0 @@ -// +build !ignore_autogenerated - -// 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. - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v2beta1 - -import ( - v2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRoute) DeepCopyInto(out *ApisixRoute) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRoute. -func (in *ApisixRoute) DeepCopy() *ApisixRoute { - if in == nil { - return nil - } - out := new(ApisixRoute) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApisixRoute) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteAuthentication) DeepCopyInto(out *ApisixRouteAuthentication) { - *out = *in - out.KeyAuth = in.KeyAuth - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteAuthentication. -func (in *ApisixRouteAuthentication) DeepCopy() *ApisixRouteAuthentication { - if in == nil { - return nil - } - out := new(ApisixRouteAuthentication) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteAuthenticationKeyAuth) DeepCopyInto(out *ApisixRouteAuthenticationKeyAuth) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteAuthenticationKeyAuth. -func (in *ApisixRouteAuthenticationKeyAuth) DeepCopy() *ApisixRouteAuthenticationKeyAuth { - if in == nil { - return nil - } - out := new(ApisixRouteAuthenticationKeyAuth) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteHTTP) DeepCopyInto(out *ApisixRouteHTTP) { - *out = *in - if in.Timeout != nil { - in, out := &in.Timeout, &out.Timeout - *out = new(UpstreamTimeout) - **out = **in - } - in.Match.DeepCopyInto(&out.Match) - in.Backend.DeepCopyInto(&out.Backend) - if in.Backends != nil { - in, out := &in.Backends, &out.Backends - *out = make([]v2beta3.ApisixRouteHTTPBackend, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Plugins != nil { - in, out := &in.Plugins, &out.Plugins - *out = make([]ApisixRouteHTTPPlugin, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - out.Authentication = in.Authentication - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteHTTP. -func (in *ApisixRouteHTTP) DeepCopy() *ApisixRouteHTTP { - if in == nil { - return nil - } - out := new(ApisixRouteHTTP) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteHTTPMatch) DeepCopyInto(out *ApisixRouteHTTPMatch) { - *out = *in - if in.Paths != nil { - in, out := &in.Paths, &out.Paths - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Methods != nil { - in, out := &in.Methods, &out.Methods - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Hosts != nil { - in, out := &in.Hosts, &out.Hosts - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.RemoteAddrs != nil { - in, out := &in.RemoteAddrs, &out.RemoteAddrs - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.NginxVars != nil { - in, out := &in.NginxVars, &out.NginxVars - *out = make([]v2beta3.ApisixRouteHTTPMatchExpr, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteHTTPMatch. -func (in *ApisixRouteHTTPMatch) DeepCopy() *ApisixRouteHTTPMatch { - if in == nil { - return nil - } - out := new(ApisixRouteHTTPMatch) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteHTTPMatchExprSubject) DeepCopyInto(out *ApisixRouteHTTPMatchExprSubject) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteHTTPMatchExprSubject. -func (in *ApisixRouteHTTPMatchExprSubject) DeepCopy() *ApisixRouteHTTPMatchExprSubject { - if in == nil { - return nil - } - out := new(ApisixRouteHTTPMatchExprSubject) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteHTTPPlugin) DeepCopyInto(out *ApisixRouteHTTPPlugin) { - *out = *in - in.Config.DeepCopyInto(&out.Config) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteHTTPPlugin. -func (in *ApisixRouteHTTPPlugin) DeepCopy() *ApisixRouteHTTPPlugin { - if in == nil { - return nil - } - out := new(ApisixRouteHTTPPlugin) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteList) DeepCopyInto(out *ApisixRouteList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ApisixRoute, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteList. -func (in *ApisixRouteList) DeepCopy() *ApisixRouteList { - if in == nil { - return nil - } - out := new(ApisixRouteList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApisixRouteList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteSpec) DeepCopyInto(out *ApisixRouteSpec) { - *out = *in - if in.HTTP != nil { - in, out := &in.HTTP, &out.HTTP - *out = make([]ApisixRouteHTTP, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Stream != nil { - in, out := &in.Stream, &out.Stream - *out = make([]ApisixRouteStream, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteSpec. -func (in *ApisixRouteSpec) DeepCopy() *ApisixRouteSpec { - if in == nil { - return nil - } - out := new(ApisixRouteSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteStream) DeepCopyInto(out *ApisixRouteStream) { - *out = *in - out.Match = in.Match - out.Backend = in.Backend - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteStream. -func (in *ApisixRouteStream) DeepCopy() *ApisixRouteStream { - if in == nil { - return nil - } - out := new(ApisixRouteStream) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteStreamBackend) DeepCopyInto(out *ApisixRouteStreamBackend) { - *out = *in - out.ServicePort = in.ServicePort - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteStreamBackend. -func (in *ApisixRouteStreamBackend) DeepCopy() *ApisixRouteStreamBackend { - if in == nil { - return nil - } - out := new(ApisixRouteStreamBackend) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixRouteStreamMatch) DeepCopyInto(out *ApisixRouteStreamMatch) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixRouteStreamMatch. -func (in *ApisixRouteStreamMatch) DeepCopy() *ApisixRouteStreamMatch { - if in == nil { - return nil - } - out := new(ApisixRouteStreamMatch) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApisixStatus) DeepCopyInto(out *ApisixStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixStatus. -func (in *ApisixStatus) DeepCopy() *ApisixStatus { - if in == nil { - return nil - } - out := new(ApisixStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *UpstreamTimeout) DeepCopyInto(out *UpstreamTimeout) { - *out = *in - out.Connect = in.Connect - out.Send = in.Send - out.Read = in.Read - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpstreamTimeout. -func (in *UpstreamTimeout) DeepCopy() *UpstreamTimeout { - if in == nil { - return nil - } - out := new(UpstreamTimeout) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/kube/apisix/apis/config/v2beta1/zz_generated.register.go b/pkg/kube/apisix/apis/config/v2beta1/zz_generated.register.go deleted file mode 100644 index 74618f9526..0000000000 --- a/pkg/kube/apisix/apis/config/v2beta1/zz_generated.register.go +++ /dev/null @@ -1,66 +0,0 @@ -// 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. - -// Code generated by register-gen. DO NOT EDIT. - -package v2beta1 - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// GroupName specifies the group name used to register the objects. -const GroupName = "apisix.apache.org" - -// GroupVersion specifies the group and the version used to register the objects. -var GroupVersion = v1.GroupVersion{Group: GroupName, Version: "v2beta1"} - -// SchemeGroupVersion is group version used to register these objects -// Deprecated: use GroupVersion instead. -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2beta1"} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - // Depreciated: use Install instead - AddToScheme = localSchemeBuilder.AddToScheme - Install = localSchemeBuilder.AddToScheme -) - -func init() { - // We only register manually written functions here. The registration of the - // generated functions takes place in the generated files. The separation - // makes the code compile even when the generated files are missing. - localSchemeBuilder.Register(addKnownTypes) -} - -// Adds the list of known types to Scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &ApisixRoute{}, - &ApisixRouteList{}, - ) - // AddToGroupVersion allows the serialization of client types like ListOptions. - v1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/pkg/kube/apisix/client/clientset/versioned/clientset.go b/pkg/kube/apisix/client/clientset/versioned/clientset.go index 3369488eb5..fbe2985b48 100644 --- a/pkg/kube/apisix/client/clientset/versioned/clientset.go +++ b/pkg/kube/apisix/client/clientset/versioned/clientset.go @@ -20,7 +20,6 @@ package versioned import ( "fmt" - apisixv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1" apisixv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2" apisixv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta3" discovery "k8s.io/client-go/discovery" @@ -32,7 +31,6 @@ type Interface interface { Discovery() discovery.DiscoveryInterface ApisixV2beta3() apisixv2beta3.ApisixV2beta3Interface ApisixV2beta2() apisixv2beta2.ApisixV2beta2Interface - ApisixV2beta1() apisixv2beta1.ApisixV2beta1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -41,7 +39,6 @@ type Clientset struct { *discovery.DiscoveryClient apisixV2beta3 *apisixv2beta3.ApisixV2beta3Client apisixV2beta2 *apisixv2beta2.ApisixV2beta2Client - apisixV2beta1 *apisixv2beta1.ApisixV2beta1Client } // ApisixV2beta3 retrieves the ApisixV2beta3Client @@ -54,11 +51,6 @@ func (c *Clientset) ApisixV2beta2() apisixv2beta2.ApisixV2beta2Interface { return c.apisixV2beta2 } -// ApisixV2beta1 retrieves the ApisixV2beta1Client -func (c *Clientset) ApisixV2beta1() apisixv2beta1.ApisixV2beta1Interface { - return c.apisixV2beta1 -} - // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -88,10 +80,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } - cs.apisixV2beta1, err = apisixv2beta1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -106,7 +94,6 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.apisixV2beta3 = apisixv2beta3.NewForConfigOrDie(c) cs.apisixV2beta2 = apisixv2beta2.NewForConfigOrDie(c) - cs.apisixV2beta1 = apisixv2beta1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -117,7 +104,6 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.apisixV2beta3 = apisixv2beta3.New(c) cs.apisixV2beta2 = apisixv2beta2.New(c) - cs.apisixV2beta1 = apisixv2beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/kube/apisix/client/clientset/versioned/fake/clientset_generated.go b/pkg/kube/apisix/client/clientset/versioned/fake/clientset_generated.go index 4047609487..cfc91ed25f 100644 --- a/pkg/kube/apisix/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/kube/apisix/client/clientset/versioned/fake/clientset_generated.go @@ -19,8 +19,6 @@ package fake import ( clientset "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned" - apisixv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1" - fakeapisixv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake" apisixv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2" fakeapisixv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake" apisixv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta3" @@ -91,8 +89,3 @@ func (c *Clientset) ApisixV2beta3() apisixv2beta3.ApisixV2beta3Interface { func (c *Clientset) ApisixV2beta2() apisixv2beta2.ApisixV2beta2Interface { return &fakeapisixv2beta2.FakeApisixV2beta2{Fake: &c.Fake} } - -// ApisixV2beta1 retrieves the ApisixV2beta1Client -func (c *Clientset) ApisixV2beta1() apisixv2beta1.ApisixV2beta1Interface { - return &fakeapisixv2beta1.FakeApisixV2beta1{Fake: &c.Fake} -} diff --git a/pkg/kube/apisix/client/clientset/versioned/fake/register.go b/pkg/kube/apisix/client/clientset/versioned/fake/register.go index 2bd209494c..fa982e0098 100644 --- a/pkg/kube/apisix/client/clientset/versioned/fake/register.go +++ b/pkg/kube/apisix/client/clientset/versioned/fake/register.go @@ -18,7 +18,6 @@ package fake import ( - apisixv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" apisixv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" apisixv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,7 +33,6 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ apisixv2beta3.AddToScheme, apisixv2beta2.AddToScheme, - apisixv2beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/kube/apisix/client/clientset/versioned/scheme/register.go b/pkg/kube/apisix/client/clientset/versioned/scheme/register.go index 44b21e627a..55d1ea70ca 100644 --- a/pkg/kube/apisix/client/clientset/versioned/scheme/register.go +++ b/pkg/kube/apisix/client/clientset/versioned/scheme/register.go @@ -18,7 +18,6 @@ package scheme import ( - apisixv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" apisixv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" apisixv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,7 +33,6 @@ var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ apisixv2beta3.AddToScheme, apisixv2beta2.AddToScheme, - apisixv2beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/apisixroute.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/apisixroute.go deleted file mode 100644 index d949c75ab4..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/apisixroute.go +++ /dev/null @@ -1,194 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package v2beta1 - -import ( - "context" - "time" - - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" - scheme "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// ApisixRoutesGetter has a method to return a ApisixRouteInterface. -// A group's client should implement this interface. -type ApisixRoutesGetter interface { - ApisixRoutes(namespace string) ApisixRouteInterface -} - -// ApisixRouteInterface has methods to work with ApisixRoute resources. -type ApisixRouteInterface interface { - Create(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.CreateOptions) (*v2beta1.ApisixRoute, error) - Update(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.UpdateOptions) (*v2beta1.ApisixRoute, error) - UpdateStatus(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.UpdateOptions) (*v2beta1.ApisixRoute, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v2beta1.ApisixRoute, error) - List(ctx context.Context, opts v1.ListOptions) (*v2beta1.ApisixRouteList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.ApisixRoute, err error) - ApisixRouteExpansion -} - -// apisixRoutes implements ApisixRouteInterface -type apisixRoutes struct { - client rest.Interface - ns string -} - -// newApisixRoutes returns a ApisixRoutes -func newApisixRoutes(c *ApisixV2beta1Client, namespace string) *apisixRoutes { - return &apisixRoutes{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the apisixRoute, and returns the corresponding apisixRoute object, and an error if there is any. -func (c *apisixRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta1.ApisixRoute, err error) { - result = &v2beta1.ApisixRoute{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ApisixRoutes that match those selectors. -func (c *apisixRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.ApisixRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v2beta1.ApisixRouteList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apisixroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested apisixRoutes. -func (c *apisixRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("apisixroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a apisixRoute and creates it. Returns the server's representation of the apisixRoute, and an error, if there is any. -func (c *apisixRoutes) Create(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.CreateOptions) (result *v2beta1.ApisixRoute, err error) { - result = &v2beta1.ApisixRoute{} - err = c.client.Post(). - Namespace(c.ns). - Resource("apisixroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apisixRoute). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a apisixRoute and updates it. Returns the server's representation of the apisixRoute, and an error, if there is any. -func (c *apisixRoutes) Update(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.UpdateOptions) (result *v2beta1.ApisixRoute, err error) { - result = &v2beta1.ApisixRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(apisixRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apisixRoute). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *apisixRoutes) UpdateStatus(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.UpdateOptions) (result *v2beta1.ApisixRoute, err error) { - result = &v2beta1.ApisixRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(apisixRoute.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apisixRoute). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the apisixRoute and deletes it. Returns an error if one occurs. -func (c *apisixRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *apisixRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("apisixroutes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched apisixRoute. -func (c *apisixRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.ApisixRoute, err error) { - result = &v2beta1.ApisixRoute{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("apisixroutes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/config_client.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/config_client.go deleted file mode 100644 index 220b12530c..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/config_client.go +++ /dev/null @@ -1,88 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package v2beta1 - -import ( - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" - "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" -) - -type ApisixV2beta1Interface interface { - RESTClient() rest.Interface - ApisixRoutesGetter -} - -// ApisixV2beta1Client is used to interact with features provided by the apisix.apache.org group. -type ApisixV2beta1Client struct { - restClient rest.Interface -} - -func (c *ApisixV2beta1Client) ApisixRoutes(namespace string) ApisixRouteInterface { - return newApisixRoutes(c, namespace) -} - -// NewForConfig creates a new ApisixV2beta1Client for the given config. -func NewForConfig(c *rest.Config) (*ApisixV2beta1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &ApisixV2beta1Client{client}, nil -} - -// NewForConfigOrDie creates a new ApisixV2beta1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *ApisixV2beta1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new ApisixV2beta1Client for the given RESTClient. -func New(c rest.Interface) *ApisixV2beta1Client { - return &ApisixV2beta1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v2beta1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *ApisixV2beta1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/doc.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/doc.go deleted file mode 100644 index 4dc6082310..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v2beta1 diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/doc.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/doc.go deleted file mode 100644 index cfa1988880..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/fake_apisixroute.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/fake_apisixroute.go deleted file mode 100644 index 3fead802a7..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/fake_apisixroute.go +++ /dev/null @@ -1,141 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeApisixRoutes implements ApisixRouteInterface -type FakeApisixRoutes struct { - Fake *FakeApisixV2beta1 - ns string -} - -var apisixroutesResource = schema.GroupVersionResource{Group: "apisix.apache.org", Version: "v2beta1", Resource: "apisixroutes"} - -var apisixroutesKind = schema.GroupVersionKind{Group: "apisix.apache.org", Version: "v2beta1", Kind: "ApisixRoute"} - -// Get takes name of the apisixRoute, and returns the corresponding apisixRoute object, and an error if there is any. -func (c *FakeApisixRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta1.ApisixRoute, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(apisixroutesResource, c.ns, name), &v2beta1.ApisixRoute{}) - - if obj == nil { - return nil, err - } - return obj.(*v2beta1.ApisixRoute), err -} - -// List takes label and field selectors, and returns the list of ApisixRoutes that match those selectors. -func (c *FakeApisixRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v2beta1.ApisixRouteList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(apisixroutesResource, apisixroutesKind, c.ns, opts), &v2beta1.ApisixRouteList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v2beta1.ApisixRouteList{ListMeta: obj.(*v2beta1.ApisixRouteList).ListMeta} - for _, item := range obj.(*v2beta1.ApisixRouteList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested apisixRoutes. -func (c *FakeApisixRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(apisixroutesResource, c.ns, opts)) - -} - -// Create takes the representation of a apisixRoute and creates it. Returns the server's representation of the apisixRoute, and an error, if there is any. -func (c *FakeApisixRoutes) Create(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.CreateOptions) (result *v2beta1.ApisixRoute, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(apisixroutesResource, c.ns, apisixRoute), &v2beta1.ApisixRoute{}) - - if obj == nil { - return nil, err - } - return obj.(*v2beta1.ApisixRoute), err -} - -// Update takes the representation of a apisixRoute and updates it. Returns the server's representation of the apisixRoute, and an error, if there is any. -func (c *FakeApisixRoutes) Update(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.UpdateOptions) (result *v2beta1.ApisixRoute, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(apisixroutesResource, c.ns, apisixRoute), &v2beta1.ApisixRoute{}) - - if obj == nil { - return nil, err - } - return obj.(*v2beta1.ApisixRoute), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeApisixRoutes) UpdateStatus(ctx context.Context, apisixRoute *v2beta1.ApisixRoute, opts v1.UpdateOptions) (*v2beta1.ApisixRoute, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(apisixroutesResource, "status", c.ns, apisixRoute), &v2beta1.ApisixRoute{}) - - if obj == nil { - return nil, err - } - return obj.(*v2beta1.ApisixRoute), err -} - -// Delete takes name of the apisixRoute and deletes it. Returns an error if one occurs. -func (c *FakeApisixRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(apisixroutesResource, c.ns, name), &v2beta1.ApisixRoute{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeApisixRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(apisixroutesResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v2beta1.ApisixRouteList{}) - return err -} - -// Patch applies the patch and returns the patched apisixRoute. -func (c *FakeApisixRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta1.ApisixRoute, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(apisixroutesResource, c.ns, name, pt, data, subresources...), &v2beta1.ApisixRoute{}) - - if obj == nil { - return nil, err - } - return obj.(*v2beta1.ApisixRoute), err -} diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/fake_config_client.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/fake_config_client.go deleted file mode 100644 index e5efef96ad..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/fake/fake_config_client.go +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1" - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" -) - -type FakeApisixV2beta1 struct { - *testing.Fake -} - -func (c *FakeApisixV2beta1) ApisixRoutes(namespace string) v2beta1.ApisixRouteInterface { - return &FakeApisixRoutes{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeApisixV2beta1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/generated_expansion.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/generated_expansion.go deleted file mode 100644 index 0c6a09444c..0000000000 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta1/generated_expansion.go +++ /dev/null @@ -1,20 +0,0 @@ -// 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. - -// Code generated by client-gen. DO NOT EDIT. - -package v2beta1 - -type ApisixRouteExpansion interface{} diff --git a/pkg/kube/apisix/client/informers/externalversions/config/interface.go b/pkg/kube/apisix/client/informers/externalversions/config/interface.go index 71ad954242..d0dde71867 100644 --- a/pkg/kube/apisix/client/informers/externalversions/config/interface.go +++ b/pkg/kube/apisix/client/informers/externalversions/config/interface.go @@ -18,7 +18,6 @@ package config import ( - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/config/v2beta1" v2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/config/v2beta2" v2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/config/v2beta3" internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/internalinterfaces" @@ -30,8 +29,6 @@ type Interface interface { V2beta3() v2beta3.Interface // V2beta2 provides access to shared informers for resources in V2beta2. V2beta2() v2beta2.Interface - // V2beta1 provides access to shared informers for resources in V2beta1. - V2beta1() v2beta1.Interface } type group struct { @@ -54,8 +51,3 @@ func (g *group) V2beta3() v2beta3.Interface { func (g *group) V2beta2() v2beta2.Interface { return v2beta2.New(g.factory, g.namespace, g.tweakListOptions) } - -// V2beta1 returns a new v2beta1.Interface. -func (g *group) V2beta1() v2beta1.Interface { - return v2beta1.New(g.factory, g.namespace, g.tweakListOptions) -} diff --git a/pkg/kube/apisix/client/informers/externalversions/config/v2beta1/apisixroute.go b/pkg/kube/apisix/client/informers/externalversions/config/v2beta1/apisixroute.go deleted file mode 100644 index 7be5683f57..0000000000 --- a/pkg/kube/apisix/client/informers/externalversions/config/v2beta1/apisixroute.go +++ /dev/null @@ -1,89 +0,0 @@ -// 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. - -// Code generated by informer-gen. DO NOT EDIT. - -package v2beta1 - -import ( - "context" - time "time" - - configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" - versioned "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned" - internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/internalinterfaces" - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// ApisixRouteInformer provides access to a shared informer and lister for -// ApisixRoutes. -type ApisixRouteInformer interface { - Informer() cache.SharedIndexInformer - Lister() v2beta1.ApisixRouteLister -} - -type apisixRouteInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewApisixRouteInformer constructs a new informer for ApisixRoute type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewApisixRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredApisixRouteInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredApisixRouteInformer constructs a new informer for ApisixRoute type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredApisixRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ApisixV2beta1().ApisixRoutes(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ApisixV2beta1().ApisixRoutes(namespace).Watch(context.TODO(), options) - }, - }, - &configv2beta1.ApisixRoute{}, - resyncPeriod, - indexers, - ) -} - -func (f *apisixRouteInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredApisixRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *apisixRouteInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&configv2beta1.ApisixRoute{}, f.defaultInformer) -} - -func (f *apisixRouteInformer) Lister() v2beta1.ApisixRouteLister { - return v2beta1.NewApisixRouteLister(f.Informer().GetIndexer()) -} diff --git a/pkg/kube/apisix/client/informers/externalversions/config/v2beta1/interface.go b/pkg/kube/apisix/client/informers/externalversions/config/v2beta1/interface.go deleted file mode 100644 index 12ddd95c81..0000000000 --- a/pkg/kube/apisix/client/informers/externalversions/config/v2beta1/interface.go +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -// Code generated by informer-gen. DO NOT EDIT. - -package v2beta1 - -import ( - internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // ApisixRoutes returns a ApisixRouteInformer. - ApisixRoutes() ApisixRouteInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// ApisixRoutes returns a ApisixRouteInformer. -func (v *version) ApisixRoutes() ApisixRouteInformer { - return &apisixRouteInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} diff --git a/pkg/kube/apisix/client/informers/externalversions/generic.go b/pkg/kube/apisix/client/informers/externalversions/generic.go index f0a90768dd..3aeb04cd53 100644 --- a/pkg/kube/apisix/client/informers/externalversions/generic.go +++ b/pkg/kube/apisix/client/informers/externalversions/generic.go @@ -20,7 +20,6 @@ package externalversions import ( "fmt" - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" v2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" v2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -53,11 +52,7 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=apisix.apache.org, Version=v2beta1 - case v2beta1.SchemeGroupVersion.WithResource("apisixroutes"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2beta1().ApisixRoutes().Informer()}, nil - - // Group=apisix.apache.org, Version=v2beta2 + // Group=apisix.apache.org, Version=v2beta2 case v2beta2.SchemeGroupVersion.WithResource("apisixroutes"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2beta2().ApisixRoutes().Informer()}, nil diff --git a/pkg/kube/apisix/client/listers/config/v2beta1/apisixroute.go b/pkg/kube/apisix/client/listers/config/v2beta1/apisixroute.go deleted file mode 100644 index aff9c07f60..0000000000 --- a/pkg/kube/apisix/client/listers/config/v2beta1/apisixroute.go +++ /dev/null @@ -1,98 +0,0 @@ -// 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. - -// Code generated by lister-gen. DO NOT EDIT. - -package v2beta1 - -import ( - v2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ApisixRouteLister helps list ApisixRoutes. -// All objects returned here must be treated as read-only. -type ApisixRouteLister interface { - // List lists all ApisixRoutes in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v2beta1.ApisixRoute, err error) - // ApisixRoutes returns an object that can list and get ApisixRoutes. - ApisixRoutes(namespace string) ApisixRouteNamespaceLister - ApisixRouteListerExpansion -} - -// apisixRouteLister implements the ApisixRouteLister interface. -type apisixRouteLister struct { - indexer cache.Indexer -} - -// NewApisixRouteLister returns a new ApisixRouteLister. -func NewApisixRouteLister(indexer cache.Indexer) ApisixRouteLister { - return &apisixRouteLister{indexer: indexer} -} - -// List lists all ApisixRoutes in the indexer. -func (s *apisixRouteLister) List(selector labels.Selector) (ret []*v2beta1.ApisixRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v2beta1.ApisixRoute)) - }) - return ret, err -} - -// ApisixRoutes returns an object that can list and get ApisixRoutes. -func (s *apisixRouteLister) ApisixRoutes(namespace string) ApisixRouteNamespaceLister { - return apisixRouteNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ApisixRouteNamespaceLister helps list and get ApisixRoutes. -// All objects returned here must be treated as read-only. -type ApisixRouteNamespaceLister interface { - // List lists all ApisixRoutes in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v2beta1.ApisixRoute, err error) - // Get retrieves the ApisixRoute from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v2beta1.ApisixRoute, error) - ApisixRouteNamespaceListerExpansion -} - -// apisixRouteNamespaceLister implements the ApisixRouteNamespaceLister -// interface. -type apisixRouteNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ApisixRoutes in the indexer for a given namespace. -func (s apisixRouteNamespaceLister) List(selector labels.Selector) (ret []*v2beta1.ApisixRoute, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v2beta1.ApisixRoute)) - }) - return ret, err -} - -// Get retrieves the ApisixRoute from the indexer for a given namespace and name. -func (s apisixRouteNamespaceLister) Get(name string) (*v2beta1.ApisixRoute, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v2beta1.Resource("apisixroute"), name) - } - return obj.(*v2beta1.ApisixRoute), nil -} diff --git a/pkg/kube/apisix/client/listers/config/v2beta1/expansion_generated.go b/pkg/kube/apisix/client/listers/config/v2beta1/expansion_generated.go deleted file mode 100644 index de3ac04522..0000000000 --- a/pkg/kube/apisix/client/listers/config/v2beta1/expansion_generated.go +++ /dev/null @@ -1,26 +0,0 @@ -// 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. - -// Code generated by lister-gen. DO NOT EDIT. - -package v2beta1 - -// ApisixRouteListerExpansion allows custom methods to be added to -// ApisixRouteLister. -type ApisixRouteListerExpansion interface{} - -// ApisixRouteNamespaceListerExpansion allows custom methods to be added to -// ApisixRouteNamespaceLister. -type ApisixRouteNamespaceListerExpansion interface{} diff --git a/pkg/kube/apisix_route.go b/pkg/kube/apisix_route.go index 54e4a78ffa..b3e5b573ea 100644 --- a/pkg/kube/apisix_route.go +++ b/pkg/kube/apisix_route.go @@ -17,17 +17,13 @@ package kube import ( "errors" - configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" configv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" configv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" - listersv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta1" listersv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta2" listersv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta3" ) const ( - // ApisixRouteV2beta1 represents the ApisixRoute in apisix.apache.org/v2beta1 group version - ApisixRouteV2beta1 = "apisix.apache.org/v2beta1" // ApisixRouteV2beta2 represents the ApisixRoute in apisix.apache.org/v2beta3 group version ApisixRouteV2beta2 = "apisix.apache.org/v2beta2" // ApisixRouteV2beta3 represents the ApisixRoute in apisix.apache.org/v2beta3 group version @@ -37,8 +33,6 @@ const ( // ApisixRouteLister is an encapsulation for the lister of ApisixRoute, // it aims at to be compatible with different ApisixRoute versions. type ApisixRouteLister interface { - // V2beta1 gets the ApisixRoute in apisix.apache.org/v2beta1. - V2beta1(string, string) (ApisixRoute, error) // V2beta2 gets the ApisixRoute in apisix.apache.org/v2beta3. V2beta2(string, string) (ApisixRoute, error) // V2beta3 gets the ApisixRoute in apisix.apache.org/v2beta3. @@ -57,9 +51,6 @@ type ApisixRoute interface { // GroupVersion returns the api group version of the // real ApisixRoute. GroupVersion() string - // V2beta1 returns the ApisixRoute in apisix.apache.org/v2beta1, the real - // ApisixRoute must be in this group version, otherwise will panic. - V2beta1() *configv2beta1.ApisixRoute // V2beta2 returns the ApisixRoute in apisix.apache.org/v2beta3, the real // ApisixRoute must be in this group version, otherwise will panic. V2beta2() *configv2beta2.ApisixRoute @@ -81,17 +72,10 @@ type ApisixRouteEvent struct { type apisixRoute struct { groupVersion string - v2beta1 *configv2beta1.ApisixRoute v2beta2 *configv2beta2.ApisixRoute v2beta3 *configv2beta3.ApisixRoute } -func (ar *apisixRoute) V2beta1() *configv2beta1.ApisixRoute { - if ar.groupVersion != ApisixRouteV2beta1 { - panic("not a apisix.apache.org/v2beta1 route") - } - return ar.v2beta1 -} func (ar *apisixRoute) V2beta2() *configv2beta2.ApisixRoute { if ar.groupVersion != ApisixRouteV2beta2 { panic("not a apisix.apache.org/v2beta3 route") @@ -111,31 +95,17 @@ func (ar *apisixRoute) GroupVersion() string { } func (ar *apisixRoute) ResourceVersion() string { - if ar.groupVersion == ApisixRouteV2beta1 { - return ar.V2beta1().ResourceVersion - } else if ar.groupVersion == ApisixRouteV2beta2 { + if ar.groupVersion == ApisixRouteV2beta2 { return ar.V2beta2().ResourceVersion } return ar.V2beta3().ResourceVersion } type apisixRouteLister struct { - v2beta1Lister listersv2beta1.ApisixRouteLister v2beta2Lister listersv2beta2.ApisixRouteLister v2beta3Lister listersv2beta3.ApisixRouteLister } -func (l *apisixRouteLister) V2beta1(namespace, name string) (ApisixRoute, error) { - ar, err := l.v2beta1Lister.ApisixRoutes(namespace).Get(name) - if err != nil { - return nil, err - } - return &apisixRoute{ - groupVersion: ApisixRouteV2beta1, - v2beta1: ar, - }, nil -} - func (l *apisixRouteLister) V2beta2(namespace, name string) (ApisixRoute, error) { ar, err := l.v2beta2Lister.ApisixRoutes(namespace).Get(name) if err != nil { @@ -162,11 +132,6 @@ func (l *apisixRouteLister) V2beta3(namespace, name string) (ApisixRoute, error) // type of obj. func MustNewApisixRoute(obj interface{}) ApisixRoute { switch ar := obj.(type) { - case *configv2beta1.ApisixRoute: - return &apisixRoute{ - groupVersion: ApisixRouteV2beta1, - v2beta1: ar, - } case *configv2beta2.ApisixRoute: return &apisixRoute{ groupVersion: ApisixRouteV2beta2, @@ -187,11 +152,6 @@ func MustNewApisixRoute(obj interface{}) ApisixRoute { // type assertion fails. func NewApisixRoute(obj interface{}) (ApisixRoute, error) { switch ar := obj.(type) { - case *configv2beta1.ApisixRoute: - return &apisixRoute{ - groupVersion: ApisixRouteV2beta1, - v2beta1: ar, - }, nil case *configv2beta2.ApisixRoute: return &apisixRoute{ groupVersion: ApisixRouteV2beta2, @@ -207,9 +167,8 @@ func NewApisixRoute(obj interface{}) (ApisixRoute, error) { } } -func NewApisixRouteLister(v2beta1 listersv2beta1.ApisixRouteLister, v2beta2 listersv2beta2.ApisixRouteLister, v2beta3 listersv2beta3.ApisixRouteLister) ApisixRouteLister { +func NewApisixRouteLister(v2beta2 listersv2beta2.ApisixRouteLister, v2beta3 listersv2beta3.ApisixRouteLister) ApisixRouteLister { return &apisixRouteLister{ - v2beta1Lister: v2beta1, v2beta2Lister: v2beta2, v2beta3Lister: v2beta3, } diff --git a/pkg/kube/translation/apisix_route.go b/pkg/kube/translation/apisix_route.go index 78fb222231..7b3f437565 100644 --- a/pkg/kube/translation/apisix_route.go +++ b/pkg/kube/translation/apisix_route.go @@ -21,7 +21,6 @@ import ( "go.uber.org/zap" "github.com/apache/apisix-ingress-controller/pkg/id" - configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" configv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" configv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" _const "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/const" @@ -29,144 +28,6 @@ import ( apisixv1 "github.com/apache/apisix-ingress-controller/pkg/types/apisix/v1" ) -func (t *translator) TranslateRouteV2beta1(ar *configv2beta1.ApisixRoute) (*TranslateContext, error) { - ctx := defaultEmptyTranslateContext() - - 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 := defaultEmptyTranslateContext() - - 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) - // add route plugins - for _, plugin := range part.Plugins { - if !plugin.Enable { - continue - } - if plugin.Config != nil { - pluginMap[plugin.Name] = plugin.Config - } else { - pluginMap[plugin.Name] = make(map[string]interface{}) - } - } - - // add KeyAuth and basicAuth plugin - if part.Authentication.Enable { - switch part.Authentication.Type { - case "keyAuth": - pluginMap["key-auth"] = part.Authentication.KeyAuth - case "basicAuth": - pluginMap["basic-auth"] = make(map[string]interface{}) - default: - pluginMap["basic-auth"] = make(map[string]interface{}) - } - } - - var exprs [][]apisixv1.StringOrSlice - if part.Match.NginxVars != nil { - exprs, err = t.translateRouteMatchExprs(part.Match.NginxVars) - if err != nil { - log.Errorw("ApisixRoute with bad nginxVars", - zap.Error(err), - zap.Any("ApisixRoute", ar), - ) - return err - } - } - if err := validateRemoteAddrs(part.Match.RemoteAddrs); err != nil { - log.Errorw("ApisixRoute with invalid remote addrs", - zap.Error(err), - zap.Strings("remote_addrs", part.Match.RemoteAddrs), - zap.Any("ApisixRoute", ar), - ) - return err - } - - upstreamName := apisixv1.ComposeUpstreamName(ar.Namespace, backend.ServiceName, backend.Subset, svcPort) - route := apisixv1.NewDefaultRoute() - route.Name = apisixv1.ComposeRouteName(ar.Namespace, ar.Name, part.Name) - route.ID = id.GenID(route.Name) - route.Priority = part.Priority - route.RemoteAddrs = part.Match.RemoteAddrs - route.Vars = exprs - route.Hosts = part.Match.Hosts - route.Uris = part.Match.Paths - route.Methods = part.Match.Methods - route.UpstreamId = id.GenID(upstreamName) - route.EnableWebsocket = part.Websocket - route.Plugins = pluginMap - - if len(backends) > 0 { - weight := _defaultWeight - if backend.Weight != nil { - weight = *backend.Weight - } - backendPoints := make([]configv2beta3.ApisixRouteHTTPBackend, 0) - backendPoints = append(backendPoints, backends...) - plugin, err := t.translateTrafficSplitPlugin(ctx, ar.Namespace, weight, backendPoints) - if err != nil { - log.Errorw("failed to translate traffic-split plugin", - zap.Error(err), - zap.Any("ApisixRoute", ar), - ) - return err - } - route.Plugins["traffic-split"] = plugin - } - ctx.addRoute(route) - if !ctx.checkUpstreamExist(upstreamName) { - ups, err := t.translateUpstream(ar.Namespace, backend.ServiceName, backend.Subset, backend.ResolveGranularity, svcClusterIP, svcPort) - if err != nil { - return err - } - ctx.addUpstream(ups) - } - } - return nil -} - func (t *translator) TranslateRouteV2beta2(ar *configv2beta2.ApisixRoute) (*TranslateContext, error) { ctx := defaultEmptyTranslateContext() @@ -556,66 +417,6 @@ func (t *translator) translateRouteMatchExprs(nginxVars []configv2beta3.ApisixRo return vars, nil } -func (t *translator) translateStreamRoute(ctx *TranslateContext, ar *configv2beta1.ApisixRoute) error { - ruleNameMap := make(map[string]struct{}) - for _, part := range ar.Spec.Stream { - if _, ok := ruleNameMap[part.Name]; ok { - return errors.New("duplicated route rule name") - } - ruleNameMap[part.Name] = struct{}{} - backend := part.Backend - svcClusterIP, svcPort, err := t.getStreamServiceClusterIPAndPort(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 - } - sr := apisixv1.NewDefaultStreamRoute() - name := apisixv1.ComposeStreamRouteName(ar.Namespace, ar.Name, part.Name) - sr.ID = id.GenID(name) - sr.ServerPort = part.Match.IngressPort - ups, err := t.translateUpstream(ar.Namespace, backend.ServiceName, backend.Subset, backend.ResolveGranularity, svcClusterIP, svcPort) - if err != nil { - return err - } - sr.UpstreamId = ups.ID - ctx.addStreamRoute(sr) - if !ctx.checkUpstreamExist(ups.Name) { - ctx.addUpstream(ups) - } - } - return nil -} - -// translateHTTPRouteV2beta1NotStrictly translates http route with a loose way, only generate ID and Name for delete Event. -func (t *translator) translateHTTPRouteV2beta1NotStrictly(ctx *TranslateContext, ar *configv2beta1.ApisixRoute) error { - for _, part := range ar.Spec.HTTP { - 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] - } // else use the deprecated Backend. - upstreamName := apisixv1.ComposeUpstreamName(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal) - route := apisixv1.NewDefaultRoute() - route.Name = apisixv1.ComposeRouteName(ar.Namespace, ar.Name, part.Name) - route.ID = id.GenID(route.Name) - ctx.addRoute(route) - if !ctx.checkUpstreamExist(upstreamName) { - ups, err := t.translateUpstreamNotStrictly(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal) - if err != nil { - return err - } - ctx.addUpstream(ups) - } - } - return nil -} - // translateHTTPRouteV2beta2NotStrictly translates http route with a loose way, only generate ID and Name for delete Event. func (t *translator) translateHTTPRouteV2beta2NotStrictly(ctx *TranslateContext, ar *configv2beta2.ApisixRoute) error { for _, part := range ar.Spec.HTTP { @@ -692,27 +493,6 @@ func (t *translator) translateHTTPRouteV2beta3NotStrictly(ctx *TranslateContext, return nil } -// translateStreamRouteNotStrictly translates tcp route with a loose way, only generate ID and Name for delete Event. -func (t *translator) translateStreamRouteNotStrictly(ctx *TranslateContext, ar *configv2beta1.ApisixRoute) error { - for _, part := range ar.Spec.Stream { - backend := &part.Backend - sr := apisixv1.NewDefaultStreamRoute() - name := apisixv1.ComposeStreamRouteName(ar.Namespace, ar.Name, part.Name) - sr.ID = id.GenID(name) - sr.ServerPort = part.Match.IngressPort - ups, err := t.translateUpstreamNotStrictly(ar.Namespace, backend.ServiceName, backend.Subset, backend.ServicePort.IntVal) - if err != nil { - return err - } - sr.UpstreamId = ups.ID - ctx.addStreamRoute(sr) - if !ctx.checkUpstreamExist(ups.Name) { - ctx.addUpstream(ups) - } - } - return nil -} - func (t *translator) translateStreamRouteV2beta2(ctx *TranslateContext, ar *configv2beta2.ApisixRoute) error { ruleNameMap := make(map[string]struct{}) for _, part := range ar.Spec.Stream { diff --git a/pkg/kube/translation/translator.go b/pkg/kube/translation/translator.go index 538e7a63d7..a3d3582da1 100644 --- a/pkg/kube/translation/translator.go +++ b/pkg/kube/translation/translator.go @@ -22,7 +22,6 @@ import ( listerscorev1 "k8s.io/client-go/listers/core/v1" "github.com/apache/apisix-ingress-controller/pkg/kube" - configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" configv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" configv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" listersv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta3" @@ -65,12 +64,6 @@ type Translator interface { // TranslateIngress composes a couple of APISIX Routes and upstreams according // to the given Ingress resource. TranslateIngress(kube.Ingress) (*TranslateContext, error) - // TranslateRouteV2beta1 translates the configv2beta1.ApisixRoute object into several Route - // and Upstream resources. - TranslateRouteV2beta1(*configv2beta1.ApisixRoute) (*TranslateContext, error) - // TranslateRouteV2beta1NotStrictly translates the configv2beta1.ApisixRoute object into several Route, - // and Upstream resources not strictly, only used for delete event. - TranslateRouteV2beta1NotStrictly(*configv2beta1.ApisixRoute) (*TranslateContext, error) // TranslateRouteV2beta2 translates the configv2beta2.ApisixRoute object into several Route, // and Upstream resources. TranslateRouteV2beta2(*configv2beta2.ApisixRoute) (*TranslateContext, error) diff --git a/pkg/kube/translation/util.go b/pkg/kube/translation/util.go index 535cb6f045..8e64ae13bb 100644 --- a/pkg/kube/translation/util.go +++ b/pkg/kube/translation/util.go @@ -22,7 +22,6 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/apache/apisix-ingress-controller/pkg/id" - configv2beta1 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta1" configv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" configv2beta3 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta3" "github.com/apache/apisix-ingress-controller/pkg/log" @@ -73,46 +72,6 @@ loop: return svc.Spec.ClusterIP, svcPort, nil } -// getStreamServiceClusterIPAndPort is for v2beta1 streamRoute -func (t *translator) getStreamServiceClusterIPAndPort(backend configv2beta1.ApisixRouteStreamBackend, ns string) (string, int32, error) { - svc, err := t.ServiceLister.Services(ns).Get(backend.ServiceName) - if err != nil { - return "", 0, err - } - svcPort := int32(-1) - if backend.ResolveGranularity == "service" && svc.Spec.ClusterIP == "" { - log.Errorw("ApisixRoute refers to a headless service but want to use the service level resolve granularity", - zap.String("ApisixRoute namespace", ns), - zap.Any("service", svc), - ) - return "", 0, errors.New("conflict headless service and backend resolve granularity") - } -loop: - for _, port := range svc.Spec.Ports { - switch backend.ServicePort.Type { - case intstr.Int: - if backend.ServicePort.IntVal == port.Port { - svcPort = port.Port - break loop - } - case intstr.String: - if backend.ServicePort.StrVal == port.Name { - svcPort = port.Port - break loop - } - } - } - if svcPort == -1 { - log.Errorw("ApisixRoute refers to non-existent Service port", - zap.String("ApisixRoute namespace", ns), - zap.String("port", backend.ServicePort.String()), - ) - return "", 0, err - } - - return svc.Spec.ClusterIP, svcPort, nil -} - // getStreamServiceClusterIPAndPort is for v2beta2 streamRoute func (t *translator) getStreamServiceClusterIPAndPortV2beta2(backend configv2beta2.ApisixRouteStreamBackend, ns string) (string, int32, error) { svc, err := t.ServiceLister.Services(ns).Get(backend.ServiceName) diff --git a/policy/base.rego b/policy/base.rego index 816ebde770..c4655a5efb 100644 --- a/policy/base.rego +++ b/policy/base.rego @@ -34,7 +34,7 @@ deny[msg] { # and apisix.apache.org/v2beta1 - use apisix.apache.org/v2beta3 instead _deny = msg { input.kind == "ApisixRoute" - apis := ["apisix.apache.org/v1", "apisix.apache.org/v2alpha1", "apisix.apache.org/v2beta1"] + apis := ["apisix.apache.org/v1", "apisix.apache.org/v2alpha1", "apisix.apache.org/v2beta1", "apisix.apache.org/v2beta2"] input.apiVersion == apis[_] msg := sprintf("%s/%s: API %s has been deprecated, use apisix.apache.org/v2beta3 instead.", [input.kind, input.metadata.name, input.apiVersion]) } diff --git a/samples/deploy/crd/v1/ApisixRoute.yaml b/samples/deploy/crd/v1/ApisixRoute.yaml index 2a8d30b6d7..07576d02d1 100644 --- a/samples/deploy/crd/v1/ApisixRoute.yaml +++ b/samples/deploy/crd/v1/ApisixRoute.yaml @@ -29,311 +29,6 @@ spec: shortNames: - ar versions: - - name: v2beta1 - served: true - storage: false - deprecated: true - subresources: - status: {} - additionalPrinterColumns: - - jsonPath: .spec.http[].match.hosts - name: Hosts - type: string - priority: 0 - - jsonPath: .spec.http[].match.paths - name: URIs - type: string - priority: 0 - - jsonPath: .spec.http[].backend.serviceName - name: Target Service(HTTP) - type: string - priority: 1 - - jsonPath: .spec.tcp[].match.ingressPort - name: Ingress Server Port(TCP) - type: integer - priority: 1 - - jsonPath: .spec.tcp[].match.backend.serviceName - name: Target Service(TCP) - type: string - priority: 1 - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - priority: 0 - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - anyOf: - - required: ["http"] - - required: ["tcp"] - - required: ["stream"] - properties: - http: - type: array - minItems: 1 - items: - type: object - oneOf: - - required: ["name", "match", "backend"] - - required: ["name", "match", "backends"] - properties: - name: - type: string - minLength: 1 - priority: - type: integer - timeout: - type: object - properties: - connect: - type: string - send: - type: string - read: - type: string - match: - type: object - required: - - paths - properties: - paths: - type: array - minItems: 1 - items: - type: string - pattern: "^/[a-zA-Z0-9\\-._~%!$&'()+,;=:@/]*\\*?$" - hosts: - type: array - minItems: 1 - items: - type: string - pattern: "^\\*?[0-9a-zA-Z-._]+$" - methods: - type: array - minItems: 1 - items: - type: string - enum: ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"] - remoteAddrs: - type: array - minItems: 1 - items: - type: string - exprs: - type: array - minItems: 1 - items: - type: object - properties: - subject: - type: object - properties: - scope: - type: string - enum: ["Cookie", "Header", "Path", "Query"] - name: - type: string - minLength: 1 - required: - - scope - op: - type: string - enum: - - Equal - - NotEqual - - GreaterThan - - LessThan - - In - - NotIn - - RegexMatch - - RegexNotMatch - - RegexMatchCaseInsensitive - - RegexNotMatchCaseInsensitive - value: - type: string - set: - type: array - items: - type: string - oneOf: - - required: ["subject", "op", "value"] - - required: ["subject", "op", "set"] - websocket: - type: boolean - backend: - type: object - properties: - serviceName: - type: string - minLength: 1 - servicePort: - type: integer - minimum: 1 - maximum: 65535 - resolveGranularity: - type: string - enum: ["endpoint", "service"] - weight: - type: integer - minimum: 0 - subset: - type: string - required: - - serviceName - - servicePort - backends: - type: array - minItems: 1 - items: - type: object - properties: - serviceName: - type: string - minLength: 1 - servicePort: - type: integer - minimum: 1 - maximum: 65535 - resolveGranularity: - type: string - enum: ["endpoint", "service"] - weight: - type: integer - minimum: 0 - subset: - type: string - required: - - serviceName - - servicePort - plugins: - type: array - items: - type: object - properties: - name: - type: string - minLength: 1 - enable: - type: boolean - config: - type: object - x-kubernetes-preserve-unknown-fields: true # we have to enable it since plugin config - required: - - name - - enable - authentication: - type: object - properties: - enable: - type: boolean - type: - type: string - enum: ["basicAuth", "keyAuth"] - keyAuth: - type: object - properties: - header: - type: string - required: - - enable - tcp: - type: array - minItems: 1 - items: - type: object - required: ["name", "match", "backend"] - properties: - name: - type: string - minLength: 1 - match: - type: object - properties: - ingressPort: - type: integer - minimum: 1 - maximum: 65535 - required: - - ingressPort - backend: - type: object - properties: - serviceName: - type: string - minLength: 1 - servicePort: - type: integer - minimum: 1 - maximum: 65535 - resolveGranularity: - type: string - enum: ["endpoint", "service"] - subset: - type: string - required: - - serviceName - - servicePort - stream: - type: array - minItems: 1 - items: - type: object - required: [ "name", "match", "backend", "protocol" ] - properties: - "protocol": - type: string - enum: [ "TCP", "UDP" ] - name: - type: string - minLength: 1 - match: - type: object - properties: - ingressPort: - type: integer - minimum: 1 - maximum: 65535 - required: - - ingressPort - backend: - type: object - properties: - serviceName: - type: string - minLength: 1 - servicePort: - type: integer - minimum: 1 - maximum: 65535 - resolveGranularity: - type: string - enum: [ "endpoint", "service" ] - subset: - type: string - required: - - serviceName - - servicePort - status: - type: object - properties: - conditions: - type: array - items: - type: object - properties: - "type": - type: string - reason: - type: string - status: - type: string - message: - type: string - observedGeneration: - type: integer - name: v2beta2 served: true storage: false diff --git a/utils/update-codegen.sh b/utils/update-codegen.sh index 1a5137dc01..606acb2df2 100755 --- a/utils/update-codegen.sh +++ b/utils/update-codegen.sh @@ -31,7 +31,7 @@ rm -rf "$GENERATED_ROOT" bash "${SCRIPT_ROOT}"/generate-groups.sh "deepcopy,client,informer,lister" \ ${PKG_NAME}/pkg/kube/apisix/client ${PKG_NAME}/pkg/kube/apisix/apis \ - config:v2beta3,v2beta2,v2beta1 ${PKG_NAME} \ + config:v2beta3,v2beta2 ${PKG_NAME} \ --output-base "$GENERATED_ROOT" \ --go-header-file "${SCRIPT_ROOT}"/boilerplate.go.txt \ "$@" @@ -45,7 +45,7 @@ bash "${SCRIPT_ROOT}"/generate-groups.sh "deepcopy" \ bash "${SCRIPT_ROOT}"/generate-groups.sh "register" \ ${PKG_NAME}/pkg/kube/apisix/apis ${PKG_NAME}/pkg/kube/apisix/apis \ - config:v2beta3,v2beta2,v2beta1,v1 ${PKG_NAME} \ + config:v2beta3,v2beta2,v1 ${PKG_NAME} \ --output-base "$GENERATED_ROOT" \ --go-header-file "${SCRIPT_ROOT}"/boilerplate.go.txt \ "$@" diff --git a/utils/verify-codegen.sh b/utils/verify-codegen.sh index a710529165..9d5cdab5e8 100755 --- a/utils/verify-codegen.sh +++ b/utils/verify-codegen.sh @@ -50,7 +50,7 @@ ret=0 bash "${SCRIPT_ROOT}"/generate-groups.sh "deepcopy,client,informer,lister" \ ${PKG_NAME}/pkg/kube/apisix/client ${PKG_NAME}/pkg/kube/apisix/apis \ - config:v2beta3,v2beta2,v2beta1 ${PKG_NAME} \ + config:v2beta3,v2beta2 ${PKG_NAME} \ --output-base "$GENERATED_ROOT" \ --go-header-file "${SCRIPT_ROOT}"/boilerplate.go.txt \ --verify-only || ret=$? @@ -68,7 +68,7 @@ fi if [[ $ret -eq 0 ]]; then bash "${SCRIPT_ROOT}"/generate-groups.sh "register" \ ${PKG_NAME}/pkg/kube/apisix/apis ${PKG_NAME}/pkg/kube/apisix/apis \ - config:v2beta3,v2beta2,v2beta1,v1 ${PKG_NAME} \ + config:v2beta3,v2beta2,v1 ${PKG_NAME} \ --output-base "$GENERATED_ROOT" \ --go-header-file "${SCRIPT_ROOT}"/boilerplate.go.txt \ --verify-only|| ret=$?