diff --git a/Makefile b/Makefile index d3eef9445c..6565a6febc 100644 --- a/Makefile +++ b/Makefile @@ -314,6 +314,11 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar $(CONTROLLER_GEN): $(LOCALBIN) $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION)) +.PHONY: update-codegen +update-codegen: + @echo "Updating codegen" + ./scripts/update-codegen.sh + .PHONY: envtest envtest: $(ENVTEST) ## Download setup-envtest locally if necessary. $(ENVTEST): $(LOCALBIN) diff --git a/api/adc/zz_generated.deepcopy.go b/api/adc/zz_generated.deepcopy.go index 83857a0a09..f31ef940eb 100644 --- a/api/adc/zz_generated.deepcopy.go +++ b/api/adc/zz_generated.deepcopy.go @@ -1,19 +1,21 @@ //go: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 +// 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 +// 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. +// 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 controller-gen. DO NOT EDIT. diff --git a/api/v1alpha1/backendtrafficpolicy_types.go b/api/v1alpha1/backendtrafficpolicy_types.go index 44d5239d8d..bd306c1d08 100644 --- a/api/v1alpha1/backendtrafficpolicy_types.go +++ b/api/v1alpha1/backendtrafficpolicy_types.go @@ -21,6 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status // BackendTrafficPolicy defines configuration for traffic handling policies applied to backend services. @@ -124,7 +125,3 @@ type BackendTrafficPolicyList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []BackendTrafficPolicy `json:"items"` } - -func init() { - SchemeBuilder.Register(&BackendTrafficPolicy{}, &BackendTrafficPolicyList{}) -} diff --git a/api/v1alpha1/consumer_types.go b/api/v1alpha1/consumer_types.go index 83914ad335..8ba0b2b148 100644 --- a/api/v1alpha1/consumer_types.go +++ b/api/v1alpha1/consumer_types.go @@ -22,6 +22,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status // Consumer defines configuration for a consumer. @@ -89,7 +90,3 @@ type ConsumerList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []Consumer `json:"items"` } - -func init() { - SchemeBuilder.Register(&Consumer{}, &ConsumerList{}) -} diff --git a/api/v1alpha1/groupversion_info.go b/api/v1alpha1/doc.go similarity index 57% rename from api/v1alpha1/groupversion_info.go rename to api/v1alpha1/doc.go index bcb0ada8ee..664d596ff1 100644 --- a/api/v1alpha1/groupversion_info.go +++ b/api/v1alpha1/doc.go @@ -15,23 +15,9 @@ // specific language governing permissions and limitations // under the License. -// Package v1alpha1 contains API Schema definitions for the apisix.apache.org v1alpha1 API group. -// +kubebuilder:object:generate=true -// +groupName=apisix.apache.org -package v1alpha1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) +// Code generated by register-gen. DO NOT EDIT. -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "apisix.apache.org", Version: "v1alpha1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} +// +k8s:deepcopy-gen=package +// +groupName=apisix.apache.org - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) +package v1alpha1 diff --git a/api/v1alpha1/gatewayproxy_types.go b/api/v1alpha1/gatewayproxy_types.go index 1811790346..bdd7caa4de 100644 --- a/api/v1alpha1/gatewayproxy_types.go +++ b/api/v1alpha1/gatewayproxy_types.go @@ -168,7 +168,3 @@ type GatewayProxyPlugin struct { // Config defines the plugin's configuration details. Config apiextensionsv1.JSON `json:"config,omitempty"` } - -func init() { - SchemeBuilder.Register(&GatewayProxy{}, &GatewayProxyList{}) -} diff --git a/api/v1alpha1/httproutepolicy_types.go b/api/v1alpha1/httproutepolicy_types.go index 0a1d2e6e1f..d8c2b85815 100644 --- a/api/v1alpha1/httproutepolicy_types.go +++ b/api/v1alpha1/httproutepolicy_types.go @@ -58,7 +58,3 @@ type HTTPRoutePolicyList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []HTTPRoutePolicy `json:"items"` } - -func init() { - SchemeBuilder.Register(&HTTPRoutePolicy{}, &HTTPRoutePolicyList{}) -} diff --git a/api/v1alpha1/pluginconfig_types.go b/api/v1alpha1/pluginconfig_types.go index 600cb9a4fc..b73d008eda 100644 --- a/api/v1alpha1/pluginconfig_types.go +++ b/api/v1alpha1/pluginconfig_types.go @@ -58,7 +58,3 @@ type Plugin struct { // Config is plugin configuration details. Config apiextensionsv1.JSON `json:"config,omitempty" yaml:"config,omitempty"` } - -func init() { - SchemeBuilder.Register(&PluginConfig{}, &PluginConfigList{}) -} diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index cc03a5496a..7b9a21d65b 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1,19 +1,21 @@ //go: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 +// 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 +// 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. +// 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 controller-gen. DO NOT EDIT. diff --git a/api/v1alpha1/zz_generated.register.go b/api/v1alpha1/zz_generated.register.go new file mode 100644 index 0000000000..d5c884a588 --- /dev/null +++ b/api/v1alpha1/zz_generated.register.go @@ -0,0 +1,79 @@ +//go:build !ignore_autogenerated +// +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 register-gen. DO NOT EDIT. + +package v1alpha1 + +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: "v1alpha1"} + +// SchemeGroupVersion is group version used to register these objects +// Deprecated: use GroupVersion instead. +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// 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 + // Deprecated: 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, + &BackendTrafficPolicy{}, + &BackendTrafficPolicyList{}, + &Consumer{}, + &ConsumerList{}, + &GatewayProxy{}, + &GatewayProxyList{}, + &HTTPRoutePolicy{}, + &HTTPRoutePolicyList{}, + &PluginConfig{}, + &PluginConfigList{}, + ) + // AddToGroupVersion allows the serialization of client types like ListOptions. + v1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/api/v2/apisixconsumer_types.go b/api/v2/apisixconsumer_types.go index 89163c5bc8..b6ae505ca1 100644 --- a/api/v2/apisixconsumer_types.go +++ b/api/v2/apisixconsumer_types.go @@ -22,40 +22,27 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// ApisixConsumerSpec defines the desired state of ApisixConsumer. -type ApisixConsumerSpec struct { - // IngressClassName is the name of an IngressClass cluster resource. - // The controller uses this field to decide whether the resource should be managed. - IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` - - // AuthParameter defines the authentication credentials and configuration for this consumer. - AuthParameter ApisixConsumerAuthParameter `json:"authParameter" yaml:"authParameter"` -} - -// ApisixConsumerStatus defines the observed state of ApisixConsumer. -type ApisixConsumerStatus = ApisixStatus - +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:shortName=ac - -// ApisixConsumer defines configuration of a consumer and their authentication details. +// ApisixConsumer is the Schema for the apisixconsumers API. type ApisixConsumer struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // ApisixConsumerSpec defines the consumer authentication configuration. - Spec ApisixConsumerSpec `json:"spec,omitempty"` - Status ApisixConsumerStatus `json:"status,omitempty"` + Spec ApisixConsumerSpec `json:"spec,omitempty"` + Status ApisixStatus `json:"status,omitempty"` } -// +kubebuilder:object:root=true +// ApisixConsumerSpec defines the desired state of ApisixConsumer. +type ApisixConsumerSpec struct { + // IngressClassName is the name of an IngressClass cluster resource. + // The controller uses this field to decide whether the resource should be managed. + IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` -// ApisixConsumerList contains a list of ApisixConsumer. -type ApisixConsumerList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ApisixConsumer `json:"items"` + // AuthParameter defines the authentication credentials and configuration for this consumer. + AuthParameter ApisixConsumerAuthParameter `json:"authParameter" yaml:"authParameter"` } type ApisixConsumerAuthParameter struct { @@ -194,6 +181,11 @@ type ApisixConsumerLDAPAuthValue struct { UserDN string `json:"user_dn" yaml:"user_dn"` } -func init() { - SchemeBuilder.Register(&ApisixConsumer{}, &ApisixConsumerList{}) +// +kubebuilder:object:root=true + +// ApisixConsumerList contains a list of ApisixConsumer. +type ApisixConsumerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ApisixConsumer `json:"items"` } diff --git a/api/v2/apisixglobalrule_types.go b/api/v2/apisixglobalrule_types.go index 8af35cacfc..cdb834febb 100644 --- a/api/v2/apisixglobalrule_types.go +++ b/api/v2/apisixglobalrule_types.go @@ -21,31 +21,27 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// ApisixGlobalRuleSpec defines configuration for global plugins. -type ApisixGlobalRuleSpec struct { - // IngressClassName is the name of an IngressClass cluster resource. - // The controller uses this field to decide whether the resource should be managed. - IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` - // Plugins contain a list of global plugins. - // +kubebuilder:validation:Required - Plugins []ApisixRoutePlugin `json:"plugins" yaml:"plugins"` -} - -// ApisixGlobalRuleStatus defines the observed state of ApisixGlobalRule. -type ApisixGlobalRuleStatus = ApisixStatus - +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:shortName=agr - -// ApisixGlobalRule defines configuration for global plugins. +// ApisixGlobalRule is the Schema for the apisixglobalrules API. type ApisixGlobalRule struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // ApisixGlobalRuleSpec defines the global plugin configuration. - Spec ApisixGlobalRuleSpec `json:"spec,omitempty"` - Status ApisixGlobalRuleStatus `json:"status,omitempty"` + Spec ApisixGlobalRuleSpec `json:"spec,omitempty"` + Status ApisixStatus `json:"status,omitempty"` +} + +// ApisixGlobalRuleSpec defines the desired state of ApisixGlobalRule. +type ApisixGlobalRuleSpec struct { + // IngressClassName is the name of an IngressClass cluster resource. + // The controller uses this field to decide whether the resource should be managed. + IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` + // Plugins contain a list of global plugins. + // +kubebuilder:validation:Required + Plugins []ApisixRoutePlugin `json:"plugins" yaml:"plugins"` } // +kubebuilder:object:root=true @@ -56,7 +52,3 @@ type ApisixGlobalRuleList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []ApisixGlobalRule `json:"items"` } - -func init() { - SchemeBuilder.Register(&ApisixGlobalRule{}, &ApisixGlobalRuleList{}) -} diff --git a/api/v2/apisixpluginconfig_types.go b/api/v2/apisixpluginconfig_types.go index d31b836437..e003f7fb7a 100644 --- a/api/v2/apisixpluginconfig_types.go +++ b/api/v2/apisixpluginconfig_types.go @@ -21,6 +21,19 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:shortName=apc +// ApisixPluginConfig is the Schema for the apisixpluginconfigs API. +type ApisixPluginConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ApisixPluginConfigSpec `json:"spec,omitempty"` + Status ApisixStatus `json:"status,omitempty"` +} + // ApisixPluginConfigSpec defines the desired state of ApisixPluginConfigSpec. type ApisixPluginConfigSpec struct { // IngressClassName is the name of an IngressClass cluster resource. @@ -32,23 +45,6 @@ type ApisixPluginConfigSpec struct { Plugins []ApisixRoutePlugin `json:"plugins" yaml:"plugins"` } -// ApisixPluginConfigStatus defines the observed state of ApisixPluginConfig. -type ApisixPluginConfigStatus = ApisixStatus - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=apc - -// ApisixPluginConfig defines a reusable set of plugin configuration that can be referenced by routes. -type ApisixPluginConfig struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // ApisixPluginConfigSpec defines the plugin config configuration. - Spec ApisixPluginConfigSpec `json:"spec,omitempty"` - Status ApisixPluginConfigStatus `json:"status,omitempty"` -} - // +kubebuilder:object:root=true // ApisixPluginConfigList contains a list of ApisixPluginConfig. @@ -57,7 +53,3 @@ type ApisixPluginConfigList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []ApisixPluginConfig `json:"items"` } - -func init() { - SchemeBuilder.Register(&ApisixPluginConfig{}, &ApisixPluginConfigList{}) -} diff --git a/api/v2/apisixroute_types.go b/api/v2/apisixroute_types.go index 5f7ef7b156..1a8f780667 100644 --- a/api/v2/apisixroute_types.go +++ b/api/v2/apisixroute_types.go @@ -28,23 +28,7 @@ import ( "github.com/apache/apisix-ingress-controller/api/adc" ) -// ApisixRouteSpec is the spec definition for ApisixRoute. -// It defines routing rules for both HTTP and stream traffic. -type ApisixRouteSpec struct { - // IngressClassName is the name of the IngressClass this route belongs to. - // It allows multiple controllers to watch and reconcile different routes. - IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` - // HTTP defines a list of HTTP route rules. - // Each rule specifies conditions to match HTTP requests and how to forward them. - HTTP []ApisixRouteHTTP `json:"http,omitempty" yaml:"http,omitempty"` - // Stream defines a list of stream route rules. - // Each rule specifies conditions to match TCP/UDP traffic and how to forward them. - Stream []ApisixRouteStream `json:"stream,omitempty" yaml:"stream,omitempty"` -} - -// ApisixRouteStatus defines the observed state of ApisixRoute. -type ApisixRouteStatus = ApisixStatus - +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:shortName=ar @@ -54,15 +38,20 @@ type ApisixRouteStatus = ApisixStatus // +kubebuilder:printcolumn:name="Ingress Port (TCP)",type="integer",JSONPath=".spec.tcp[].match.ingressPort",description="TCP Ingress Port",priority=1 // +kubebuilder:printcolumn:name="Target Service (TCP)",type="string",JSONPath=".spec.tcp[].match.backend.serviceName",description="Backend Service for TCP",priority=1 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Creation time",priority=0 - -// ApisixRoute is defines configuration for HTTP and stream routes. +// ApisixRoute is the Schema for the apisixroutes API. type ApisixRoute struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // ApisixRouteSpec defines HTTP and stream route configuration. - Spec ApisixRouteSpec `json:"spec,omitempty"` - Status ApisixRouteStatus `json:"status,omitempty"` + Spec ApisixRouteSpec `json:"spec,omitempty"` + Status ApisixStatus `json:"status,omitempty"` +} + +// ApisixRouteSpec is the spec definition for ApisixRouteSpec. +type ApisixRouteSpec struct { + IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` + HTTP []ApisixRouteHTTP `json:"http,omitempty" yaml:"http,omitempty"` + Stream []ApisixRouteStream `json:"stream,omitempty" yaml:"stream,omitempty"` } // +kubebuilder:object:root=true @@ -402,7 +391,3 @@ type ApisixRouteHTTPMatchExprSubject struct { // Name is the name of the header or query parameter. Name string `json:"name" yaml:"name"` } - -func init() { - SchemeBuilder.Register(&ApisixRoute{}, &ApisixRouteList{}) -} diff --git a/api/v2/apisixtls_types.go b/api/v2/apisixtls_types.go index 31c80ff771..7f6263e388 100644 --- a/api/v2/apisixtls_types.go +++ b/api/v2/apisixtls_types.go @@ -21,7 +21,26 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// ApisixTlsSpec defines configurations for TLS and mutual TLS. +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:shortName=atls,path=apisixtlses +// +kubebuilder:printcolumn:name="SNIs",type=string,JSONPath=`.spec.hosts` +// +kubebuilder:printcolumn:name="Secret Name",type=string,JSONPath=`.spec.secret.name` +// +kubebuilder:printcolumn:name="Secret Namespace",type=string,JSONPath=`.spec.secret.namespace` +// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` +// +kubebuilder:printcolumn:name="Client CA Secret Name",type=string,JSONPath=`.spec.client.ca.name` +// +kubebuilder:printcolumn:name="Client CA Secret Namespace",type=string,JSONPath=`.spec.client.ca.namespace` +// ApisixTls is the Schema for the apisixtls API. +type ApisixTls struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ApisixTlsSpec `json:"spec,omitempty"` + Status ApisixStatus `json:"status,omitempty"` +} + +// ApisixTlsSpec defines the desired state of ApisixTls. type ApisixTlsSpec struct { // IngressClassName specifies which IngressClass this resource is associated with. // The APISIX controller only processes this resource if the class matches its own. @@ -42,38 +61,6 @@ type ApisixTlsSpec struct { Client *ApisixMutualTlsClientConfig `json:"client,omitempty" yaml:"client,omitempty"` } -// ApisixTlsStatus defines the observed state of ApisixTls. -type ApisixTlsStatus = ApisixStatus - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=atls,path=apisixtlses -// +kubebuilder:printcolumn:name="SNIs",type=string,JSONPath=`.spec.hosts` -// +kubebuilder:printcolumn:name="Secret Name",type=string,JSONPath=`.spec.secret.name` -// +kubebuilder:printcolumn:name="Secret Namespace",type=string,JSONPath=`.spec.secret.namespace` -// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` -// +kubebuilder:printcolumn:name="Client CA Secret Name",type=string,JSONPath=`.spec.client.ca.name` -// +kubebuilder:printcolumn:name="Client CA Secret Namespace",type=string,JSONPath=`.spec.client.ca.namespace` - -// ApisixTls defines configuration for TLS and mutual TLS (mTLS). -type ApisixTls struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // ApisixTlsSpec defines the TLS configuration. - Spec ApisixTlsSpec `json:"spec,omitempty"` - Status ApisixTlsStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// ApisixTlsList contains a list of ApisixTls. -type ApisixTlsList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ApisixTls `json:"items"` -} - // +kubebuilder:validation:Pattern="^\\*?[0-9a-zA-Z-.]+$" type HostType string @@ -100,6 +87,11 @@ type ApisixMutualTlsClientConfig struct { SkipMTLSUriRegex []string `json:"skip_mtls_uri_regex,omitempty" yaml:"skip_mtls_uri_regex,omitempty"` } -func init() { - SchemeBuilder.Register(&ApisixTls{}, &ApisixTlsList{}) +// +kubebuilder:object:root=true + +// ApisixTlsList contains a list of ApisixTls. +type ApisixTlsList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ApisixTls `json:"items"` } diff --git a/api/v2/apisixupstream_types.go b/api/v2/apisixupstream_types.go index 38b41c626f..88343546dd 100644 --- a/api/v2/apisixupstream_types.go +++ b/api/v2/apisixupstream_types.go @@ -23,9 +23,20 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// ApisixUpstreamSpec describes the desired configuration of an ApisixUpstream resource. -// It defines how traffic should be routed to backend services, including upstream node -// definitions and custom configuration. +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:shortName=au +// ApisixUpstream is the Schema for the apisixupstreams API. +type ApisixUpstream struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ApisixUpstreamSpec `json:"spec,omitempty"` + Status ApisixStatus `json:"status,omitempty"` +} + +// ApisixUpstreamSpec describes the specification of ApisixUpstream. type ApisixUpstreamSpec struct { // IngressClassName is the name of an IngressClass cluster resource. // Controller implementations use this field to determine whether they @@ -49,34 +60,7 @@ type ApisixUpstreamSpec struct { PortLevelSettings []PortLevelSettings `json:"portLevelSettings,omitempty" yaml:"portLevelSettings,omitempty"` } -// ApisixUpstreamStatus defines the observed state of ApisixUpstream. -type ApisixUpstreamStatus = ApisixStatus - -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=au - -// ApisixUpstream defines configuration for upstream services. -type ApisixUpstream struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // ApisixUpstreamSpec defines the upstream configuration. - Spec ApisixUpstreamSpec `json:"spec,omitempty"` - Status ApisixUpstreamStatus `json:"status,omitempty"` -} - -// +kubebuilder:object:root=true - -// ApisixUpstreamList contains a list of ApisixUpstream. -type ApisixUpstreamList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ApisixUpstream `json:"items"` -} - -// ApisixUpstreamExternalNode defines configuration for an external upstream node. -// This allows referencing services outside the cluster. +// ApisixUpstreamExternalNode is the external node conf type ApisixUpstreamExternalNode struct { // Name is the hostname or IP address of the external node. Name string `json:"name,omitempty" yaml:"name"` @@ -306,6 +290,11 @@ type PassiveHealthCheckUnhealthy struct { Timeouts int `json:"timeout,omitempty" yaml:"timeout,omitempty"` } -func init() { - SchemeBuilder.Register(&ApisixUpstream{}, &ApisixUpstreamList{}) +// +kubebuilder:object:root=true + +// ApisixUpstreamList contains a list of ApisixUpstream. +type ApisixUpstreamList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ApisixUpstream `json:"items"` } diff --git a/api/v2/doc.go b/api/v2/doc.go new file mode 100644 index 0000000000..e40505d0ef --- /dev/null +++ b/api/v2/doc.go @@ -0,0 +1,23 @@ +// 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. + +// +k8s:deepcopy-gen=package +// +groupName=apisix.apache.org + +package v2 diff --git a/api/v2/groupversion_info.go b/api/v2/groupversion_info.go deleted file mode 100644 index 31b98d412a..0000000000 --- a/api/v2/groupversion_info.go +++ /dev/null @@ -1,47 +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 v2 contains API Schema definitions for the apisix.apache.org v2 API group. -// +kubebuilder:object:generate=true -// +groupName=apisix.apache.org -package v2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: "apisix.apache.org", Version: "v2"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme. - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) - -func Is(obj client.Object) bool { - switch obj.(type) { - case *ApisixConsumer, *ApisixGlobalRule, *ApisixPluginConfig, *ApisixRoute, *ApisixTls, *ApisixUpstream: - return obj.GetObjectKind().GroupVersionKind().GroupVersion() == GroupVersion - default: - return false - } -} diff --git a/api/v2/shared_types.go b/api/v2/shared_types.go index 8ea57efae9..2f3cad329c 100644 --- a/api/v2/shared_types.go +++ b/api/v2/shared_types.go @@ -25,16 +25,16 @@ import ( type ( // ApisixRouteConditionType is a type of condition for a route. - ApisixRouteConditionType = gatewayv1.RouteConditionType + ApisixRouteConditionType = string // ApisixRouteConditionReason is a reason for a route condition. - ApisixRouteConditionReason = gatewayv1.RouteConditionReason + ApisixRouteConditionReason = string ) const ( - ConditionTypeAccepted ApisixRouteConditionType = gatewayv1.RouteConditionAccepted - ConditionReasonAccepted ApisixRouteConditionReason = gatewayv1.RouteReasonAccepted - ConditionReasonInvalidSpec ApisixRouteConditionReason = "InvalidSpec" - ConditionReasonSyncFailed ApisixRouteConditionReason = "SyncFailed" + ConditionTypeAccepted string = string(gatewayv1.RouteConditionAccepted) + ConditionReasonAccepted string = string(gatewayv1.RouteReasonAccepted) + ConditionReasonInvalidSpec string = "InvalidSpec" + ConditionReasonSyncFailed string = "SyncFailed" ) const ( diff --git a/api/v2/zz_generated.deepcopy.go b/api/v2/zz_generated.deepcopy.go index de92bb0eee..ab2a0b7a50 100644 --- a/api/v2/zz_generated.deepcopy.go +++ b/api/v2/zz_generated.deepcopy.go @@ -1,19 +1,21 @@ //go: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 +// 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 +// 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. +// 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 controller-gen. DO NOT EDIT. diff --git a/api/v2/zz_generated.register.go b/api/v2/zz_generated.register.go new file mode 100644 index 0000000000..15888f6243 --- /dev/null +++ b/api/v2/zz_generated.register.go @@ -0,0 +1,81 @@ +//go:build !ignore_autogenerated +// +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 register-gen. DO NOT EDIT. + +package v2 + +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: "v2"} + +// SchemeGroupVersion is group version used to register these objects +// Deprecated: use GroupVersion instead. +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v2"} + +// 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 + // Deprecated: 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, + &ApisixConsumer{}, + &ApisixConsumerList{}, + &ApisixGlobalRule{}, + &ApisixGlobalRuleList{}, + &ApisixPluginConfig{}, + &ApisixPluginConfigList{}, + &ApisixRoute{}, + &ApisixRouteList{}, + &ApisixTls{}, + &ApisixTlsList{}, + &ApisixUpstream{}, + &ApisixUpstreamList{}, + ) + // AddToGroupVersion allows the serialization of client types like ListOptions. + v1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/config/crd/bases/apisix.apache.org_apisixconsumers.yaml b/config/crd/bases/apisix.apache.org_apisixconsumers.yaml index ed40241bef..78afe13f3a 100644 --- a/config/crd/bases/apisix.apache.org_apisixconsumers.yaml +++ b/config/crd/bases/apisix.apache.org_apisixconsumers.yaml @@ -19,8 +19,7 @@ spec: - name: v2 schema: openAPIV3Schema: - description: ApisixConsumer defines configuration of a consumer and their - authentication details. + description: ApisixConsumer is the Schema for the apisixconsumers API. properties: apiVersion: description: |- @@ -40,7 +39,7 @@ spec: metadata: type: object spec: - description: ApisixConsumerSpec defines the consumer authentication configuration. + description: ApisixConsumerSpec defines the desired state of ApisixConsumer. properties: authParameter: description: AuthParameter defines the authentication credentials diff --git a/config/crd/bases/apisix.apache.org_apisixglobalrules.yaml b/config/crd/bases/apisix.apache.org_apisixglobalrules.yaml index ee6d275eba..cfc22b1cbb 100644 --- a/config/crd/bases/apisix.apache.org_apisixglobalrules.yaml +++ b/config/crd/bases/apisix.apache.org_apisixglobalrules.yaml @@ -19,7 +19,7 @@ spec: - name: v2 schema: openAPIV3Schema: - description: ApisixGlobalRule defines configuration for global plugins. + description: ApisixGlobalRule is the Schema for the apisixglobalrules API. properties: apiVersion: description: |- @@ -39,7 +39,7 @@ spec: metadata: type: object spec: - description: ApisixGlobalRuleSpec defines the global plugin configuration. + description: ApisixGlobalRuleSpec defines the desired state of ApisixGlobalRule. properties: ingressClassName: description: |- diff --git a/config/crd/bases/apisix.apache.org_apisixpluginconfigs.yaml b/config/crd/bases/apisix.apache.org_apisixpluginconfigs.yaml index acc427f893..03600ffef5 100644 --- a/config/crd/bases/apisix.apache.org_apisixpluginconfigs.yaml +++ b/config/crd/bases/apisix.apache.org_apisixpluginconfigs.yaml @@ -19,8 +19,8 @@ spec: - name: v2 schema: openAPIV3Schema: - description: ApisixPluginConfig defines a reusable set of plugin configuration - that can be referenced by routes. + description: ApisixPluginConfig is the Schema for the apisixpluginconfigs + API. properties: apiVersion: description: |- @@ -40,7 +40,7 @@ spec: metadata: type: object spec: - description: ApisixPluginConfigSpec defines the plugin config configuration. + description: ApisixPluginConfigSpec defines the desired state of ApisixPluginConfigSpec. properties: ingressClassName: description: |- diff --git a/config/crd/bases/apisix.apache.org_apisixroutes.yaml b/config/crd/bases/apisix.apache.org_apisixroutes.yaml index c1c30d7d68..49ef7d658f 100644 --- a/config/crd/bases/apisix.apache.org_apisixroutes.yaml +++ b/config/crd/bases/apisix.apache.org_apisixroutes.yaml @@ -47,7 +47,7 @@ spec: name: v2 schema: openAPIV3Schema: - description: ApisixRoute is defines configuration for HTTP and stream routes. + description: ApisixRoute is the Schema for the apisixroutes API. properties: apiVersion: description: |- @@ -67,12 +67,9 @@ spec: metadata: type: object spec: - description: ApisixRouteSpec defines HTTP and stream route configuration. + description: ApisixRouteSpec is the spec definition for ApisixRouteSpec. properties: http: - description: |- - HTTP defines a list of HTTP route rules. - Each rule specifies conditions to match HTTP requests and how to forward them. items: description: ApisixRouteHTTP represents a single HTTP route configuration. properties: @@ -347,14 +344,8 @@ spec: type: object type: array ingressClassName: - description: |- - IngressClassName is the name of the IngressClass this route belongs to. - It allows multiple controllers to watch and reconcile different routes. type: string stream: - description: |- - Stream defines a list of stream route rules. - Each rule specifies conditions to match TCP/UDP traffic and how to forward them. items: description: ApisixRouteStream defines the configuration for a Layer 4 (TCP/UDP) route. diff --git a/config/crd/bases/apisix.apache.org_apisixtlses.yaml b/config/crd/bases/apisix.apache.org_apisixtlses.yaml index 65f06eeb7f..cede7f8dc2 100644 --- a/config/crd/bases/apisix.apache.org_apisixtlses.yaml +++ b/config/crd/bases/apisix.apache.org_apisixtlses.yaml @@ -38,7 +38,7 @@ spec: name: v2 schema: openAPIV3Schema: - description: ApisixTls defines configuration for TLS and mutual TLS (mTLS). + description: ApisixTls is the Schema for the apisixtls API. properties: apiVersion: description: |- @@ -58,7 +58,7 @@ spec: metadata: type: object spec: - description: ApisixTlsSpec defines the TLS configuration. + description: ApisixTlsSpec defines the desired state of ApisixTls. properties: client: description: Client defines mutual TLS (mTLS) settings, such as the diff --git a/config/crd/bases/apisix.apache.org_apisixupstreams.yaml b/config/crd/bases/apisix.apache.org_apisixupstreams.yaml index c07b08e5eb..ef3c78f6bc 100644 --- a/config/crd/bases/apisix.apache.org_apisixupstreams.yaml +++ b/config/crd/bases/apisix.apache.org_apisixupstreams.yaml @@ -19,7 +19,7 @@ spec: - name: v2 schema: openAPIV3Schema: - description: ApisixUpstream defines configuration for upstream services. + description: ApisixUpstream is the Schema for the apisixupstreams API. properties: apiVersion: description: |- @@ -39,7 +39,7 @@ spec: metadata: type: object spec: - description: ApisixUpstreamSpec defines the upstream configuration. + description: ApisixUpstreamSpec describes the specification of ApisixUpstream. properties: discovery: description: |- @@ -69,9 +69,7 @@ spec: When this field is set, the upstream will route traffic directly to these nodes without DNS resolution or service discovery. items: - description: |- - ApisixUpstreamExternalNode defines configuration for an external upstream node. - This allows referencing services outside the cluster. + description: ApisixUpstreamExternalNode is the external node conf properties: name: description: Name is the hostname or IP address of the external diff --git a/go.mod b/go.mod index 38f6dae7a7..0e14cebeb8 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/gavv/httpexpect/v2 v2.16.0 github.com/go-logr/logr v1.4.2 github.com/go-logr/zapr v1.3.0 + github.com/google/go-cmp v0.6.0 github.com/google/uuid v1.6.0 github.com/gruntwork-io/terratest v0.50.0 github.com/hashicorp/go-memdb v1.3.4 @@ -28,6 +29,7 @@ require ( k8s.io/apiextensions-apiserver v0.31.1 k8s.io/apimachinery v0.31.1 k8s.io/client-go v0.31.1 + k8s.io/code-generator v0.31.1 k8s.io/kubectl v0.30.3 k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 sigs.k8s.io/controller-runtime v0.19.0 @@ -107,11 +109,10 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/cel-go v0.20.1 // indirect - github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect github.com/gorilla/websocket v1.5.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/gruntwork-io/go-commons v0.8.0 // indirect @@ -142,7 +143,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/moby/spdystream v0.4.0 // indirect + github.com/moby/spdystream v0.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -180,30 +181,33 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.6.0 // indirect golang.org/x/crypto v0.36.0 // indirect - golang.org/x/mod v0.20.0 // indirect + golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.38.0 // indirect golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/term v0.30.0 // indirect golang.org/x/text v0.23.0 // indirect - golang.org/x/time v0.8.0 // indirect - golang.org/x/tools v0.24.0 // indirect + golang.org/x/time v0.9.0 // indirect + golang.org/x/tools v0.26.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/grpc v1.67.1 // indirect - google.golang.org/protobuf v1.35.1 // indirect + google.golang.org/protobuf v1.36.5 // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/apiserver v0.31.1 // indirect k8s.io/component-base v0.31.1 // indirect + k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect + k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect moul.io/http2curl/v2 v2.3.0 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect ) diff --git a/go.sum b/go.sum index 9ba0327403..dc87923176 100644 --- a/go.sum +++ b/go.sum @@ -178,8 +178,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/cel-go v0.20.1 h1:nDx9r8S3L4pE61eDdt8igGj8rf5kjYR3ILxWIpWNi84= github.com/google/cel-go v0.20.1/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -190,8 +190,8 @@ github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -296,8 +296,8 @@ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTS github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/spdystream v0.4.0 h1:Vy79D6mHeJJjiPdFEL2yku1kl0chZpJfZcPpb16BRl8= -github.com/moby/spdystream v0.4.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= +github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU= +github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -456,8 +456,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -510,8 +510,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= -golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= -golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= +golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -519,8 +519,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -535,8 +535,8 @@ google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -570,12 +570,16 @@ k8s.io/apiserver v0.31.1 h1:Sars5ejQDCRBY5f7R3QFHdqN3s61nhkpaX8/k1iEw1c= k8s.io/apiserver v0.31.1/go.mod h1:lzDhpeToamVZJmmFlaLwdYZwd7zB+WYRYIboqA1kGxM= k8s.io/client-go v0.31.1 h1:f0ugtWSbWpxHR7sjVpQwuvw9a3ZKLXX0u0itkFXufb0= k8s.io/client-go v0.31.1/go.mod h1:sKI8871MJN2OyeqRlmA4W4KM9KBdBUpDLu/43eGemCg= +k8s.io/code-generator v0.31.1 h1:GvkRZEP2g2UnB2QKT2Dgc/kYxIkDxCHENv2Q1itioVs= +k8s.io/code-generator v0.31.1/go.mod h1:oL2ky46L48osNqqZAeOcWWy0S5BXj50vVdwOtTefqIs= k8s.io/component-base v0.31.1 h1:UpOepcrX3rQ3ab5NB6g5iP0tvsgJWzxTyAo20sgYSy8= k8s.io/component-base v0.31.1/go.mod h1:WGeaw7t/kTsqpVTaCoVEtillbqAhF2/JgvO0LDOMa0w= +k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7 h1:cErOOTkQ3JW19o4lo91fFurouhP8NcoBvb7CkvhZZpk= +k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f h1:0LQagt0gDpKqvIkAMPaRGcXawNMouPECM1+F9BVxEaM= -k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f/go.mod h1:S9tOR0FxgyusSNR+MboCuiDpVWkAifZvaYI1Q2ubgro= +k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= +k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/kubectl v0.30.3 h1:YIBBvMdTW0xcDpmrOBzcpUVsn+zOgjMYIu7kAq+yqiI= k8s.io/kubectl v0.30.3/go.mod h1:IcR0I9RN2+zzTRUa1BzZCm4oM0NLOawE6RzlDvd1Fpo= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= @@ -589,9 +593,12 @@ sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= sigs.k8s.io/gateway-api v1.2.0 h1:LrToiFwtqKTKZcZtoQPTuo3FxhrrhTgzQG0Te+YGSo8= sigs.k8s.io/gateway-api v1.2.0/go.mod h1:EpNfEXNjiYfUJypf0eZ0P5iXA9ekSGWaS1WgPaM42X0= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt index 63f7276486..b248758bc1 100644 --- a/hack/boilerplate.go.txt +++ b/hack/boilerplate.go.txt @@ -1,14 +1,16 @@ -// 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 +// 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 +// 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. +// 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. diff --git a/internal/provider/adc/adc.go b/internal/provider/adc/adc.go index f4f220f458..04e35b66d7 100644 --- a/internal/provider/adc/adc.go +++ b/internal/provider/adc/adc.go @@ -217,7 +217,7 @@ func (d *adcClient) Update(ctx context.Context, tctx *provider.TranslateContext, // This mode is full synchronization, // which only needs to be saved in cache // and triggered by a timer for synchronization - if d.BackendMode == BackendModeAPISIXStandalone || d.BackendMode == BackendModeAPISIX || apiv2.Is(obj) { + if d.BackendMode == BackendModeAPISIXStandalone || d.BackendMode == BackendModeAPISIX { return nil } diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 0000000000..3afe6537a9 --- /dev/null +++ b/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,134 @@ +// 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 versioned + +import ( + "fmt" + "net/http" + + apisixv1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v1alpha1" + apisixv2 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v2" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + ApisixV1alpha1() apisixv1alpha1.ApisixV1alpha1Interface + ApisixV2() apisixv2.ApisixV2Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + apisixV1alpha1 *apisixv1alpha1.ApisixV1alpha1Client + apisixV2 *apisixv2.ApisixV2Client +} + +// ApisixV1alpha1 retrieves the ApisixV1alpha1Client +func (c *Clientset) ApisixV1alpha1() apisixv1alpha1.ApisixV1alpha1Interface { + return c.apisixV1alpha1 +} + +// ApisixV2 retrieves the ApisixV2Client +func (c *Clientset) ApisixV2() apisixv2.ApisixV2Interface { + return c.apisixV2 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.apisixV1alpha1, err = apisixv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + cs.apisixV2, err = apisixv2.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.apisixV1alpha1 = apisixv1alpha1.New(c) + cs.apisixV2 = apisixv2.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000000..e05265ba8e --- /dev/null +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,97 @@ +// 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 ( + clientset "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + apisixv1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v1alpha1" + fakeapisixv1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v1alpha1/fake" + apisixv2 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v2" + fakeapisixv2 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v2/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +// +// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves +// server side apply testing. NewClientset is only available when apply configurations are generated (e.g. +// via --with-applyconfig). +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// ApisixV1alpha1 retrieves the ApisixV1alpha1Client +func (c *Clientset) ApisixV1alpha1() apisixv1alpha1.ApisixV1alpha1Interface { + return &fakeapisixv1alpha1.FakeApisixV1alpha1{Fake: &c.Fake} +} + +// ApisixV2 retrieves the ApisixV2Client +func (c *Clientset) ApisixV2() apisixv2.ApisixV2Interface { + return &fakeapisixv2.FakeApisixV2{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 0000000000..0301a747bf --- /dev/null +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,21 @@ +// 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 fake clientset. +package fake diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 0000000000..c518b41beb --- /dev/null +++ b/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,59 @@ +// 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 ( + apisixv1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + apisixv2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + apisixv1alpha1.AddToScheme, + apisixv2.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/pkg/client/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000000..b380f64fc8 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,21 @@ +// 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 contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 0000000000..023d440404 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,59 @@ +// 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 scheme + +import ( + apisixv1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + apisixv2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + apisixv1alpha1.AddToScheme, + apisixv2.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/api_client.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/api_client.go new file mode 100644 index 0000000000..81b65daabd --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/api_client.go @@ -0,0 +1,113 @@ +// 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 v1alpha1 + +import ( + "net/http" + + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type ApisixV1alpha1Interface interface { + RESTClient() rest.Interface + BackendTrafficPoliciesGetter + ConsumersGetter +} + +// ApisixV1alpha1Client is used to interact with features provided by the apisix.apache.org group. +type ApisixV1alpha1Client struct { + restClient rest.Interface +} + +func (c *ApisixV1alpha1Client) BackendTrafficPolicies(namespace string) BackendTrafficPolicyInterface { + return newBackendTrafficPolicies(c, namespace) +} + +func (c *ApisixV1alpha1Client) Consumers(namespace string) ConsumerInterface { + return newConsumers(c, namespace) +} + +// NewForConfig creates a new ApisixV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*ApisixV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new ApisixV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ApisixV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &ApisixV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new ApisixV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ApisixV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ApisixV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ApisixV1alpha1Client { + return &ApisixV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.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 *ApisixV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/backendtrafficpolicy.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/backendtrafficpolicy.go new file mode 100644 index 0000000000..a213237dce --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/backendtrafficpolicy.go @@ -0,0 +1,70 @@ +// 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 v1alpha1 + +import ( + "context" + + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// BackendTrafficPoliciesGetter has a method to return a BackendTrafficPolicyInterface. +// A group's client should implement this interface. +type BackendTrafficPoliciesGetter interface { + BackendTrafficPolicies(namespace string) BackendTrafficPolicyInterface +} + +// BackendTrafficPolicyInterface has methods to work with BackendTrafficPolicy resources. +type BackendTrafficPolicyInterface interface { + Create(ctx context.Context, backendTrafficPolicy *v1alpha1.BackendTrafficPolicy, opts v1.CreateOptions) (*v1alpha1.BackendTrafficPolicy, error) + Update(ctx context.Context, backendTrafficPolicy *v1alpha1.BackendTrafficPolicy, opts v1.UpdateOptions) (*v1alpha1.BackendTrafficPolicy, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, backendTrafficPolicy *v1alpha1.BackendTrafficPolicy, opts v1.UpdateOptions) (*v1alpha1.BackendTrafficPolicy, 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) (*v1alpha1.BackendTrafficPolicy, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.BackendTrafficPolicyList, 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 *v1alpha1.BackendTrafficPolicy, err error) + BackendTrafficPolicyExpansion +} + +// backendTrafficPolicies implements BackendTrafficPolicyInterface +type backendTrafficPolicies struct { + *gentype.ClientWithList[*v1alpha1.BackendTrafficPolicy, *v1alpha1.BackendTrafficPolicyList] +} + +// newBackendTrafficPolicies returns a BackendTrafficPolicies +func newBackendTrafficPolicies(c *ApisixV1alpha1Client, namespace string) *backendTrafficPolicies { + return &backendTrafficPolicies{ + gentype.NewClientWithList[*v1alpha1.BackendTrafficPolicy, *v1alpha1.BackendTrafficPolicyList]( + "backendtrafficpolicies", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.BackendTrafficPolicy { return &v1alpha1.BackendTrafficPolicy{} }, + func() *v1alpha1.BackendTrafficPolicyList { return &v1alpha1.BackendTrafficPolicyList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/consumer.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/consumer.go new file mode 100644 index 0000000000..f8d9539857 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/consumer.go @@ -0,0 +1,70 @@ +// 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 v1alpha1 + +import ( + "context" + + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ConsumersGetter has a method to return a ConsumerInterface. +// A group's client should implement this interface. +type ConsumersGetter interface { + Consumers(namespace string) ConsumerInterface +} + +// ConsumerInterface has methods to work with Consumer resources. +type ConsumerInterface interface { + Create(ctx context.Context, consumer *v1alpha1.Consumer, opts v1.CreateOptions) (*v1alpha1.Consumer, error) + Update(ctx context.Context, consumer *v1alpha1.Consumer, opts v1.UpdateOptions) (*v1alpha1.Consumer, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, consumer *v1alpha1.Consumer, opts v1.UpdateOptions) (*v1alpha1.Consumer, 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) (*v1alpha1.Consumer, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ConsumerList, 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 *v1alpha1.Consumer, err error) + ConsumerExpansion +} + +// consumers implements ConsumerInterface +type consumers struct { + *gentype.ClientWithList[*v1alpha1.Consumer, *v1alpha1.ConsumerList] +} + +// newConsumers returns a Consumers +func newConsumers(c *ApisixV1alpha1Client, namespace string) *consumers { + return &consumers{ + gentype.NewClientWithList[*v1alpha1.Consumer, *v1alpha1.ConsumerList]( + "consumers", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.Consumer { return &v1alpha1.Consumer{} }, + func() *v1alpha1.ConsumerList { return &v1alpha1.ConsumerList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/doc.go new file mode 100644 index 0000000000..dea80d7c48 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/doc.go @@ -0,0 +1,21 @@ +// 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 v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..ce9b49b2e3 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/doc.go @@ -0,0 +1,21 @@ +// 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/client/clientset/versioned/typed/api/v1alpha1/fake/fake_api_client.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_api_client.go new file mode 100644 index 0000000000..56e1a1a902 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_api_client.go @@ -0,0 +1,45 @@ +// 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 ( + v1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeApisixV1alpha1 struct { + *testing.Fake +} + +func (c *FakeApisixV1alpha1) BackendTrafficPolicies(namespace string) v1alpha1.BackendTrafficPolicyInterface { + return &FakeBackendTrafficPolicies{c, namespace} +} + +func (c *FakeApisixV1alpha1) Consumers(namespace string) v1alpha1.ConsumerInterface { + return &FakeConsumers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeApisixV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_backendtrafficpolicy.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_backendtrafficpolicy.go new file mode 100644 index 0000000000..f742f1743e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_backendtrafficpolicy.go @@ -0,0 +1,148 @@ +// 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" + + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeBackendTrafficPolicies implements BackendTrafficPolicyInterface +type FakeBackendTrafficPolicies struct { + Fake *FakeApisixV1alpha1 + ns string +} + +var backendtrafficpoliciesResource = v1alpha1.SchemeGroupVersion.WithResource("backendtrafficpolicies") + +var backendtrafficpoliciesKind = v1alpha1.SchemeGroupVersion.WithKind("BackendTrafficPolicy") + +// Get takes name of the backendTrafficPolicy, and returns the corresponding backendTrafficPolicy object, and an error if there is any. +func (c *FakeBackendTrafficPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.BackendTrafficPolicy, err error) { + emptyResult := &v1alpha1.BackendTrafficPolicy{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(backendtrafficpoliciesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.BackendTrafficPolicy), err +} + +// List takes label and field selectors, and returns the list of BackendTrafficPolicies that match those selectors. +func (c *FakeBackendTrafficPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.BackendTrafficPolicyList, err error) { + emptyResult := &v1alpha1.BackendTrafficPolicyList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(backendtrafficpoliciesResource, backendtrafficpoliciesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.BackendTrafficPolicyList{ListMeta: obj.(*v1alpha1.BackendTrafficPolicyList).ListMeta} + for _, item := range obj.(*v1alpha1.BackendTrafficPolicyList).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 backendTrafficPolicies. +func (c *FakeBackendTrafficPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(backendtrafficpoliciesResource, c.ns, opts)) + +} + +// Create takes the representation of a backendTrafficPolicy and creates it. Returns the server's representation of the backendTrafficPolicy, and an error, if there is any. +func (c *FakeBackendTrafficPolicies) Create(ctx context.Context, backendTrafficPolicy *v1alpha1.BackendTrafficPolicy, opts v1.CreateOptions) (result *v1alpha1.BackendTrafficPolicy, err error) { + emptyResult := &v1alpha1.BackendTrafficPolicy{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(backendtrafficpoliciesResource, c.ns, backendTrafficPolicy, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.BackendTrafficPolicy), err +} + +// Update takes the representation of a backendTrafficPolicy and updates it. Returns the server's representation of the backendTrafficPolicy, and an error, if there is any. +func (c *FakeBackendTrafficPolicies) Update(ctx context.Context, backendTrafficPolicy *v1alpha1.BackendTrafficPolicy, opts v1.UpdateOptions) (result *v1alpha1.BackendTrafficPolicy, err error) { + emptyResult := &v1alpha1.BackendTrafficPolicy{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(backendtrafficpoliciesResource, c.ns, backendTrafficPolicy, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.BackendTrafficPolicy), 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 *FakeBackendTrafficPolicies) UpdateStatus(ctx context.Context, backendTrafficPolicy *v1alpha1.BackendTrafficPolicy, opts v1.UpdateOptions) (result *v1alpha1.BackendTrafficPolicy, err error) { + emptyResult := &v1alpha1.BackendTrafficPolicy{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(backendtrafficpoliciesResource, "status", c.ns, backendTrafficPolicy, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.BackendTrafficPolicy), err +} + +// Delete takes name of the backendTrafficPolicy and deletes it. Returns an error if one occurs. +func (c *FakeBackendTrafficPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(backendtrafficpoliciesResource, c.ns, name, opts), &v1alpha1.BackendTrafficPolicy{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeBackendTrafficPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(backendtrafficpoliciesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.BackendTrafficPolicyList{}) + return err +} + +// Patch applies the patch and returns the patched backendTrafficPolicy. +func (c *FakeBackendTrafficPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.BackendTrafficPolicy, err error) { + emptyResult := &v1alpha1.BackendTrafficPolicy{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(backendtrafficpoliciesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.BackendTrafficPolicy), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_consumer.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_consumer.go new file mode 100644 index 0000000000..cde1023710 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/fake/fake_consumer.go @@ -0,0 +1,148 @@ +// 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" + + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeConsumers implements ConsumerInterface +type FakeConsumers struct { + Fake *FakeApisixV1alpha1 + ns string +} + +var consumersResource = v1alpha1.SchemeGroupVersion.WithResource("consumers") + +var consumersKind = v1alpha1.SchemeGroupVersion.WithKind("Consumer") + +// Get takes name of the consumer, and returns the corresponding consumer object, and an error if there is any. +func (c *FakeConsumers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Consumer, err error) { + emptyResult := &v1alpha1.Consumer{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(consumersResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Consumer), err +} + +// List takes label and field selectors, and returns the list of Consumers that match those selectors. +func (c *FakeConsumers) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ConsumerList, err error) { + emptyResult := &v1alpha1.ConsumerList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(consumersResource, consumersKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ConsumerList{ListMeta: obj.(*v1alpha1.ConsumerList).ListMeta} + for _, item := range obj.(*v1alpha1.ConsumerList).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 consumers. +func (c *FakeConsumers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(consumersResource, c.ns, opts)) + +} + +// Create takes the representation of a consumer and creates it. Returns the server's representation of the consumer, and an error, if there is any. +func (c *FakeConsumers) Create(ctx context.Context, consumer *v1alpha1.Consumer, opts v1.CreateOptions) (result *v1alpha1.Consumer, err error) { + emptyResult := &v1alpha1.Consumer{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(consumersResource, c.ns, consumer, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Consumer), err +} + +// Update takes the representation of a consumer and updates it. Returns the server's representation of the consumer, and an error, if there is any. +func (c *FakeConsumers) Update(ctx context.Context, consumer *v1alpha1.Consumer, opts v1.UpdateOptions) (result *v1alpha1.Consumer, err error) { + emptyResult := &v1alpha1.Consumer{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(consumersResource, c.ns, consumer, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Consumer), 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 *FakeConsumers) UpdateStatus(ctx context.Context, consumer *v1alpha1.Consumer, opts v1.UpdateOptions) (result *v1alpha1.Consumer, err error) { + emptyResult := &v1alpha1.Consumer{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(consumersResource, "status", c.ns, consumer, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Consumer), err +} + +// Delete takes name of the consumer and deletes it. Returns an error if one occurs. +func (c *FakeConsumers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(consumersResource, c.ns, name, opts), &v1alpha1.Consumer{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeConsumers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(consumersResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ConsumerList{}) + return err +} + +// Patch applies the patch and returns the patched consumer. +func (c *FakeConsumers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Consumer, err error) { + emptyResult := &v1alpha1.Consumer{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(consumersResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Consumer), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/api/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..3281d50666 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v1alpha1/generated_expansion.go @@ -0,0 +1,24 @@ +// 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 v1alpha1 + +type BackendTrafficPolicyExpansion interface{} + +type ConsumerExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/api/v2/api_client.go b/pkg/client/clientset/versioned/typed/api/v2/api_client.go new file mode 100644 index 0000000000..5808a9e4ba --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/api_client.go @@ -0,0 +1,133 @@ +// 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 v2 + +import ( + "net/http" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type ApisixV2Interface interface { + RESTClient() rest.Interface + ApisixConsumersGetter + ApisixGlobalRulesGetter + ApisixPluginConfigsGetter + ApisixRoutesGetter + ApisixTlsesGetter + ApisixUpstreamsGetter +} + +// ApisixV2Client is used to interact with features provided by the apisix.apache.org group. +type ApisixV2Client struct { + restClient rest.Interface +} + +func (c *ApisixV2Client) ApisixConsumers(namespace string) ApisixConsumerInterface { + return newApisixConsumers(c, namespace) +} + +func (c *ApisixV2Client) ApisixGlobalRules(namespace string) ApisixGlobalRuleInterface { + return newApisixGlobalRules(c, namespace) +} + +func (c *ApisixV2Client) ApisixPluginConfigs(namespace string) ApisixPluginConfigInterface { + return newApisixPluginConfigs(c, namespace) +} + +func (c *ApisixV2Client) ApisixRoutes(namespace string) ApisixRouteInterface { + return newApisixRoutes(c, namespace) +} + +func (c *ApisixV2Client) ApisixTlses(namespace string) ApisixTlsInterface { + return newApisixTlses(c, namespace) +} + +func (c *ApisixV2Client) ApisixUpstreams(namespace string) ApisixUpstreamInterface { + return newApisixUpstreams(c, namespace) +} + +// NewForConfig creates a new ApisixV2Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*ApisixV2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new ApisixV2Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ApisixV2Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &ApisixV2Client{client}, nil +} + +// NewForConfigOrDie creates a new ApisixV2Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ApisixV2Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ApisixV2Client for the given RESTClient. +func New(c rest.Interface) *ApisixV2Client { + return &ApisixV2Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v2.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 *ApisixV2Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/apisixconsumer.go b/pkg/client/clientset/versioned/typed/api/v2/apisixconsumer.go new file mode 100644 index 0000000000..0eece4bb47 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/apisixconsumer.go @@ -0,0 +1,70 @@ +// 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 v2 + +import ( + "context" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ApisixConsumersGetter has a method to return a ApisixConsumerInterface. +// A group's client should implement this interface. +type ApisixConsumersGetter interface { + ApisixConsumers(namespace string) ApisixConsumerInterface +} + +// ApisixConsumerInterface has methods to work with ApisixConsumer resources. +type ApisixConsumerInterface interface { + Create(ctx context.Context, apisixConsumer *v2.ApisixConsumer, opts v1.CreateOptions) (*v2.ApisixConsumer, error) + Update(ctx context.Context, apisixConsumer *v2.ApisixConsumer, opts v1.UpdateOptions) (*v2.ApisixConsumer, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, apisixConsumer *v2.ApisixConsumer, opts v1.UpdateOptions) (*v2.ApisixConsumer, 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) (*v2.ApisixConsumer, error) + List(ctx context.Context, opts v1.ListOptions) (*v2.ApisixConsumerList, 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 *v2.ApisixConsumer, err error) + ApisixConsumerExpansion +} + +// apisixConsumers implements ApisixConsumerInterface +type apisixConsumers struct { + *gentype.ClientWithList[*v2.ApisixConsumer, *v2.ApisixConsumerList] +} + +// newApisixConsumers returns a ApisixConsumers +func newApisixConsumers(c *ApisixV2Client, namespace string) *apisixConsumers { + return &apisixConsumers{ + gentype.NewClientWithList[*v2.ApisixConsumer, *v2.ApisixConsumerList]( + "apisixconsumers", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixConsumer { return &v2.ApisixConsumer{} }, + func() *v2.ApisixConsumerList { return &v2.ApisixConsumerList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/apisixglobalrule.go b/pkg/client/clientset/versioned/typed/api/v2/apisixglobalrule.go new file mode 100644 index 0000000000..2e27d1ae7a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/apisixglobalrule.go @@ -0,0 +1,70 @@ +// 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 v2 + +import ( + "context" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ApisixGlobalRulesGetter has a method to return a ApisixGlobalRuleInterface. +// A group's client should implement this interface. +type ApisixGlobalRulesGetter interface { + ApisixGlobalRules(namespace string) ApisixGlobalRuleInterface +} + +// ApisixGlobalRuleInterface has methods to work with ApisixGlobalRule resources. +type ApisixGlobalRuleInterface interface { + Create(ctx context.Context, apisixGlobalRule *v2.ApisixGlobalRule, opts v1.CreateOptions) (*v2.ApisixGlobalRule, error) + Update(ctx context.Context, apisixGlobalRule *v2.ApisixGlobalRule, opts v1.UpdateOptions) (*v2.ApisixGlobalRule, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, apisixGlobalRule *v2.ApisixGlobalRule, opts v1.UpdateOptions) (*v2.ApisixGlobalRule, 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) (*v2.ApisixGlobalRule, error) + List(ctx context.Context, opts v1.ListOptions) (*v2.ApisixGlobalRuleList, 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 *v2.ApisixGlobalRule, err error) + ApisixGlobalRuleExpansion +} + +// apisixGlobalRules implements ApisixGlobalRuleInterface +type apisixGlobalRules struct { + *gentype.ClientWithList[*v2.ApisixGlobalRule, *v2.ApisixGlobalRuleList] +} + +// newApisixGlobalRules returns a ApisixGlobalRules +func newApisixGlobalRules(c *ApisixV2Client, namespace string) *apisixGlobalRules { + return &apisixGlobalRules{ + gentype.NewClientWithList[*v2.ApisixGlobalRule, *v2.ApisixGlobalRuleList]( + "apisixglobalrules", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixGlobalRule { return &v2.ApisixGlobalRule{} }, + func() *v2.ApisixGlobalRuleList { return &v2.ApisixGlobalRuleList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/apisixpluginconfig.go b/pkg/client/clientset/versioned/typed/api/v2/apisixpluginconfig.go new file mode 100644 index 0000000000..f68e40a85a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/apisixpluginconfig.go @@ -0,0 +1,70 @@ +// 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 v2 + +import ( + "context" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ApisixPluginConfigsGetter has a method to return a ApisixPluginConfigInterface. +// A group's client should implement this interface. +type ApisixPluginConfigsGetter interface { + ApisixPluginConfigs(namespace string) ApisixPluginConfigInterface +} + +// ApisixPluginConfigInterface has methods to work with ApisixPluginConfig resources. +type ApisixPluginConfigInterface interface { + Create(ctx context.Context, apisixPluginConfig *v2.ApisixPluginConfig, opts v1.CreateOptions) (*v2.ApisixPluginConfig, error) + Update(ctx context.Context, apisixPluginConfig *v2.ApisixPluginConfig, opts v1.UpdateOptions) (*v2.ApisixPluginConfig, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, apisixPluginConfig *v2.ApisixPluginConfig, opts v1.UpdateOptions) (*v2.ApisixPluginConfig, 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) (*v2.ApisixPluginConfig, error) + List(ctx context.Context, opts v1.ListOptions) (*v2.ApisixPluginConfigList, 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 *v2.ApisixPluginConfig, err error) + ApisixPluginConfigExpansion +} + +// apisixPluginConfigs implements ApisixPluginConfigInterface +type apisixPluginConfigs struct { + *gentype.ClientWithList[*v2.ApisixPluginConfig, *v2.ApisixPluginConfigList] +} + +// newApisixPluginConfigs returns a ApisixPluginConfigs +func newApisixPluginConfigs(c *ApisixV2Client, namespace string) *apisixPluginConfigs { + return &apisixPluginConfigs{ + gentype.NewClientWithList[*v2.ApisixPluginConfig, *v2.ApisixPluginConfigList]( + "apisixpluginconfigs", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixPluginConfig { return &v2.ApisixPluginConfig{} }, + func() *v2.ApisixPluginConfigList { return &v2.ApisixPluginConfigList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/apisixroute.go b/pkg/client/clientset/versioned/typed/api/v2/apisixroute.go new file mode 100644 index 0000000000..381e29fbb7 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/apisixroute.go @@ -0,0 +1,70 @@ +// 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 v2 + +import ( + "context" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// 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 *v2.ApisixRoute, opts v1.CreateOptions) (*v2.ApisixRoute, error) + Update(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (*v2.ApisixRoute, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (*v2.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) (*v2.ApisixRoute, error) + List(ctx context.Context, opts v1.ListOptions) (*v2.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 *v2.ApisixRoute, err error) + ApisixRouteExpansion +} + +// apisixRoutes implements ApisixRouteInterface +type apisixRoutes struct { + *gentype.ClientWithList[*v2.ApisixRoute, *v2.ApisixRouteList] +} + +// newApisixRoutes returns a ApisixRoutes +func newApisixRoutes(c *ApisixV2Client, namespace string) *apisixRoutes { + return &apisixRoutes{ + gentype.NewClientWithList[*v2.ApisixRoute, *v2.ApisixRouteList]( + "apisixroutes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixRoute { return &v2.ApisixRoute{} }, + func() *v2.ApisixRouteList { return &v2.ApisixRouteList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/apisixtls.go b/pkg/client/clientset/versioned/typed/api/v2/apisixtls.go new file mode 100644 index 0000000000..083be76c78 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/apisixtls.go @@ -0,0 +1,70 @@ +// 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 v2 + +import ( + "context" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ApisixTlsesGetter has a method to return a ApisixTlsInterface. +// A group's client should implement this interface. +type ApisixTlsesGetter interface { + ApisixTlses(namespace string) ApisixTlsInterface +} + +// ApisixTlsInterface has methods to work with ApisixTls resources. +type ApisixTlsInterface interface { + Create(ctx context.Context, apisixTls *v2.ApisixTls, opts v1.CreateOptions) (*v2.ApisixTls, error) + Update(ctx context.Context, apisixTls *v2.ApisixTls, opts v1.UpdateOptions) (*v2.ApisixTls, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, apisixTls *v2.ApisixTls, opts v1.UpdateOptions) (*v2.ApisixTls, 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) (*v2.ApisixTls, error) + List(ctx context.Context, opts v1.ListOptions) (*v2.ApisixTlsList, 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 *v2.ApisixTls, err error) + ApisixTlsExpansion +} + +// apisixTlses implements ApisixTlsInterface +type apisixTlses struct { + *gentype.ClientWithList[*v2.ApisixTls, *v2.ApisixTlsList] +} + +// newApisixTlses returns a ApisixTlses +func newApisixTlses(c *ApisixV2Client, namespace string) *apisixTlses { + return &apisixTlses{ + gentype.NewClientWithList[*v2.ApisixTls, *v2.ApisixTlsList]( + "apisixtlses", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixTls { return &v2.ApisixTls{} }, + func() *v2.ApisixTlsList { return &v2.ApisixTlsList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/apisixupstream.go b/pkg/client/clientset/versioned/typed/api/v2/apisixupstream.go new file mode 100644 index 0000000000..4216e8025c --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/apisixupstream.go @@ -0,0 +1,70 @@ +// 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 v2 + +import ( + "context" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + scheme "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ApisixUpstreamsGetter has a method to return a ApisixUpstreamInterface. +// A group's client should implement this interface. +type ApisixUpstreamsGetter interface { + ApisixUpstreams(namespace string) ApisixUpstreamInterface +} + +// ApisixUpstreamInterface has methods to work with ApisixUpstream resources. +type ApisixUpstreamInterface interface { + Create(ctx context.Context, apisixUpstream *v2.ApisixUpstream, opts v1.CreateOptions) (*v2.ApisixUpstream, error) + Update(ctx context.Context, apisixUpstream *v2.ApisixUpstream, opts v1.UpdateOptions) (*v2.ApisixUpstream, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, apisixUpstream *v2.ApisixUpstream, opts v1.UpdateOptions) (*v2.ApisixUpstream, 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) (*v2.ApisixUpstream, error) + List(ctx context.Context, opts v1.ListOptions) (*v2.ApisixUpstreamList, 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 *v2.ApisixUpstream, err error) + ApisixUpstreamExpansion +} + +// apisixUpstreams implements ApisixUpstreamInterface +type apisixUpstreams struct { + *gentype.ClientWithList[*v2.ApisixUpstream, *v2.ApisixUpstreamList] +} + +// newApisixUpstreams returns a ApisixUpstreams +func newApisixUpstreams(c *ApisixV2Client, namespace string) *apisixUpstreams { + return &apisixUpstreams{ + gentype.NewClientWithList[*v2.ApisixUpstream, *v2.ApisixUpstreamList]( + "apisixupstreams", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixUpstream { return &v2.ApisixUpstream{} }, + func() *v2.ApisixUpstreamList { return &v2.ApisixUpstreamList{} }), + } +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/doc.go b/pkg/client/clientset/versioned/typed/api/v2/doc.go new file mode 100644 index 0000000000..3c71c7bdf9 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/doc.go @@ -0,0 +1,21 @@ +// 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 v2 diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/doc.go b/pkg/client/clientset/versioned/typed/api/v2/fake/doc.go new file mode 100644 index 0000000000..ce9b49b2e3 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/doc.go @@ -0,0 +1,21 @@ +// 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/client/clientset/versioned/typed/api/v2/fake/fake_api_client.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_api_client.go new file mode 100644 index 0000000000..1b8e2dc5df --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_api_client.go @@ -0,0 +1,61 @@ +// 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 ( + v2 "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned/typed/api/v2" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeApisixV2 struct { + *testing.Fake +} + +func (c *FakeApisixV2) ApisixConsumers(namespace string) v2.ApisixConsumerInterface { + return &FakeApisixConsumers{c, namespace} +} + +func (c *FakeApisixV2) ApisixGlobalRules(namespace string) v2.ApisixGlobalRuleInterface { + return &FakeApisixGlobalRules{c, namespace} +} + +func (c *FakeApisixV2) ApisixPluginConfigs(namespace string) v2.ApisixPluginConfigInterface { + return &FakeApisixPluginConfigs{c, namespace} +} + +func (c *FakeApisixV2) ApisixRoutes(namespace string) v2.ApisixRouteInterface { + return &FakeApisixRoutes{c, namespace} +} + +func (c *FakeApisixV2) ApisixTlses(namespace string) v2.ApisixTlsInterface { + return &FakeApisixTlses{c, namespace} +} + +func (c *FakeApisixV2) ApisixUpstreams(namespace string) v2.ApisixUpstreamInterface { + return &FakeApisixUpstreams{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeApisixV2) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixconsumer.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixconsumer.go new file mode 100644 index 0000000000..7ccc5aa54a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixconsumer.go @@ -0,0 +1,148 @@ +// 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" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeApisixConsumers implements ApisixConsumerInterface +type FakeApisixConsumers struct { + Fake *FakeApisixV2 + ns string +} + +var apisixconsumersResource = v2.SchemeGroupVersion.WithResource("apisixconsumers") + +var apisixconsumersKind = v2.SchemeGroupVersion.WithKind("ApisixConsumer") + +// Get takes name of the apisixConsumer, and returns the corresponding apisixConsumer object, and an error if there is any. +func (c *FakeApisixConsumers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixConsumer, err error) { + emptyResult := &v2.ApisixConsumer{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apisixconsumersResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixConsumer), err +} + +// List takes label and field selectors, and returns the list of ApisixConsumers that match those selectors. +func (c *FakeApisixConsumers) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixConsumerList, err error) { + emptyResult := &v2.ApisixConsumerList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apisixconsumersResource, apisixconsumersKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2.ApisixConsumerList{ListMeta: obj.(*v2.ApisixConsumerList).ListMeta} + for _, item := range obj.(*v2.ApisixConsumerList).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 apisixConsumers. +func (c *FakeApisixConsumers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apisixconsumersResource, c.ns, opts)) + +} + +// Create takes the representation of a apisixConsumer and creates it. Returns the server's representation of the apisixConsumer, and an error, if there is any. +func (c *FakeApisixConsumers) Create(ctx context.Context, apisixConsumer *v2.ApisixConsumer, opts v1.CreateOptions) (result *v2.ApisixConsumer, err error) { + emptyResult := &v2.ApisixConsumer{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apisixconsumersResource, c.ns, apisixConsumer, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixConsumer), err +} + +// Update takes the representation of a apisixConsumer and updates it. Returns the server's representation of the apisixConsumer, and an error, if there is any. +func (c *FakeApisixConsumers) Update(ctx context.Context, apisixConsumer *v2.ApisixConsumer, opts v1.UpdateOptions) (result *v2.ApisixConsumer, err error) { + emptyResult := &v2.ApisixConsumer{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apisixconsumersResource, c.ns, apisixConsumer, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixConsumer), 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 *FakeApisixConsumers) UpdateStatus(ctx context.Context, apisixConsumer *v2.ApisixConsumer, opts v1.UpdateOptions) (result *v2.ApisixConsumer, err error) { + emptyResult := &v2.ApisixConsumer{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixconsumersResource, "status", c.ns, apisixConsumer, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixConsumer), err +} + +// Delete takes name of the apisixConsumer and deletes it. Returns an error if one occurs. +func (c *FakeApisixConsumers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apisixconsumersResource, c.ns, name, opts), &v2.ApisixConsumer{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeApisixConsumers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apisixconsumersResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v2.ApisixConsumerList{}) + return err +} + +// Patch applies the patch and returns the patched apisixConsumer. +func (c *FakeApisixConsumers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixConsumer, err error) { + emptyResult := &v2.ApisixConsumer{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixconsumersResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixConsumer), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixglobalrule.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixglobalrule.go new file mode 100644 index 0000000000..f9bfefc188 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixglobalrule.go @@ -0,0 +1,148 @@ +// 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" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeApisixGlobalRules implements ApisixGlobalRuleInterface +type FakeApisixGlobalRules struct { + Fake *FakeApisixV2 + ns string +} + +var apisixglobalrulesResource = v2.SchemeGroupVersion.WithResource("apisixglobalrules") + +var apisixglobalrulesKind = v2.SchemeGroupVersion.WithKind("ApisixGlobalRule") + +// Get takes name of the apisixGlobalRule, and returns the corresponding apisixGlobalRule object, and an error if there is any. +func (c *FakeApisixGlobalRules) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixGlobalRule, err error) { + emptyResult := &v2.ApisixGlobalRule{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apisixglobalrulesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixGlobalRule), err +} + +// List takes label and field selectors, and returns the list of ApisixGlobalRules that match those selectors. +func (c *FakeApisixGlobalRules) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixGlobalRuleList, err error) { + emptyResult := &v2.ApisixGlobalRuleList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apisixglobalrulesResource, apisixglobalrulesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2.ApisixGlobalRuleList{ListMeta: obj.(*v2.ApisixGlobalRuleList).ListMeta} + for _, item := range obj.(*v2.ApisixGlobalRuleList).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 apisixGlobalRules. +func (c *FakeApisixGlobalRules) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apisixglobalrulesResource, c.ns, opts)) + +} + +// Create takes the representation of a apisixGlobalRule and creates it. Returns the server's representation of the apisixGlobalRule, and an error, if there is any. +func (c *FakeApisixGlobalRules) Create(ctx context.Context, apisixGlobalRule *v2.ApisixGlobalRule, opts v1.CreateOptions) (result *v2.ApisixGlobalRule, err error) { + emptyResult := &v2.ApisixGlobalRule{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apisixglobalrulesResource, c.ns, apisixGlobalRule, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixGlobalRule), err +} + +// Update takes the representation of a apisixGlobalRule and updates it. Returns the server's representation of the apisixGlobalRule, and an error, if there is any. +func (c *FakeApisixGlobalRules) Update(ctx context.Context, apisixGlobalRule *v2.ApisixGlobalRule, opts v1.UpdateOptions) (result *v2.ApisixGlobalRule, err error) { + emptyResult := &v2.ApisixGlobalRule{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apisixglobalrulesResource, c.ns, apisixGlobalRule, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixGlobalRule), 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 *FakeApisixGlobalRules) UpdateStatus(ctx context.Context, apisixGlobalRule *v2.ApisixGlobalRule, opts v1.UpdateOptions) (result *v2.ApisixGlobalRule, err error) { + emptyResult := &v2.ApisixGlobalRule{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixglobalrulesResource, "status", c.ns, apisixGlobalRule, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixGlobalRule), err +} + +// Delete takes name of the apisixGlobalRule and deletes it. Returns an error if one occurs. +func (c *FakeApisixGlobalRules) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apisixglobalrulesResource, c.ns, name, opts), &v2.ApisixGlobalRule{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeApisixGlobalRules) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apisixglobalrulesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v2.ApisixGlobalRuleList{}) + return err +} + +// Patch applies the patch and returns the patched apisixGlobalRule. +func (c *FakeApisixGlobalRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixGlobalRule, err error) { + emptyResult := &v2.ApisixGlobalRule{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixglobalrulesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixGlobalRule), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixpluginconfig.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixpluginconfig.go new file mode 100644 index 0000000000..c4654f0fb8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixpluginconfig.go @@ -0,0 +1,148 @@ +// 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" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeApisixPluginConfigs implements ApisixPluginConfigInterface +type FakeApisixPluginConfigs struct { + Fake *FakeApisixV2 + ns string +} + +var apisixpluginconfigsResource = v2.SchemeGroupVersion.WithResource("apisixpluginconfigs") + +var apisixpluginconfigsKind = v2.SchemeGroupVersion.WithKind("ApisixPluginConfig") + +// Get takes name of the apisixPluginConfig, and returns the corresponding apisixPluginConfig object, and an error if there is any. +func (c *FakeApisixPluginConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixPluginConfig, err error) { + emptyResult := &v2.ApisixPluginConfig{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apisixpluginconfigsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixPluginConfig), err +} + +// List takes label and field selectors, and returns the list of ApisixPluginConfigs that match those selectors. +func (c *FakeApisixPluginConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixPluginConfigList, err error) { + emptyResult := &v2.ApisixPluginConfigList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apisixpluginconfigsResource, apisixpluginconfigsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2.ApisixPluginConfigList{ListMeta: obj.(*v2.ApisixPluginConfigList).ListMeta} + for _, item := range obj.(*v2.ApisixPluginConfigList).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 apisixPluginConfigs. +func (c *FakeApisixPluginConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apisixpluginconfigsResource, c.ns, opts)) + +} + +// Create takes the representation of a apisixPluginConfig and creates it. Returns the server's representation of the apisixPluginConfig, and an error, if there is any. +func (c *FakeApisixPluginConfigs) Create(ctx context.Context, apisixPluginConfig *v2.ApisixPluginConfig, opts v1.CreateOptions) (result *v2.ApisixPluginConfig, err error) { + emptyResult := &v2.ApisixPluginConfig{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apisixpluginconfigsResource, c.ns, apisixPluginConfig, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixPluginConfig), err +} + +// Update takes the representation of a apisixPluginConfig and updates it. Returns the server's representation of the apisixPluginConfig, and an error, if there is any. +func (c *FakeApisixPluginConfigs) Update(ctx context.Context, apisixPluginConfig *v2.ApisixPluginConfig, opts v1.UpdateOptions) (result *v2.ApisixPluginConfig, err error) { + emptyResult := &v2.ApisixPluginConfig{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apisixpluginconfigsResource, c.ns, apisixPluginConfig, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixPluginConfig), 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 *FakeApisixPluginConfigs) UpdateStatus(ctx context.Context, apisixPluginConfig *v2.ApisixPluginConfig, opts v1.UpdateOptions) (result *v2.ApisixPluginConfig, err error) { + emptyResult := &v2.ApisixPluginConfig{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixpluginconfigsResource, "status", c.ns, apisixPluginConfig, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixPluginConfig), err +} + +// Delete takes name of the apisixPluginConfig and deletes it. Returns an error if one occurs. +func (c *FakeApisixPluginConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apisixpluginconfigsResource, c.ns, name, opts), &v2.ApisixPluginConfig{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeApisixPluginConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apisixpluginconfigsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v2.ApisixPluginConfigList{}) + return err +} + +// Patch applies the patch and returns the patched apisixPluginConfig. +func (c *FakeApisixPluginConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixPluginConfig, err error) { + emptyResult := &v2.ApisixPluginConfig{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixpluginconfigsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixPluginConfig), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixroute.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixroute.go new file mode 100644 index 0000000000..1355789d3b --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixroute.go @@ -0,0 +1,148 @@ +// 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" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + 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 *FakeApisixV2 + ns string +} + +var apisixroutesResource = v2.SchemeGroupVersion.WithResource("apisixroutes") + +var apisixroutesKind = v2.SchemeGroupVersion.WithKind("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 *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apisixroutesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.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 *v2.ApisixRouteList, err error) { + emptyResult := &v2.ApisixRouteList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apisixroutesResource, apisixroutesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2.ApisixRouteList{ListMeta: obj.(*v2.ApisixRouteList).ListMeta} + for _, item := range obj.(*v2.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.NewWatchActionWithOptions(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 *v2.ApisixRoute, opts v1.CreateOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apisixroutesResource, c.ns, apisixRoute, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.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 *v2.ApisixRoute, opts v1.UpdateOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apisixroutesResource, c.ns, apisixRoute, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.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 *v2.ApisixRoute, opts v1.UpdateOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixroutesResource, "status", c.ns, apisixRoute, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.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.NewDeleteActionWithOptions(apisixroutesResource, c.ns, name, opts), &v2.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.NewDeleteCollectionActionWithOptions(apisixroutesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v2.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 *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixroutesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixRoute), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixtls.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixtls.go new file mode 100644 index 0000000000..37406bcd87 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixtls.go @@ -0,0 +1,148 @@ +// 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" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeApisixTlses implements ApisixTlsInterface +type FakeApisixTlses struct { + Fake *FakeApisixV2 + ns string +} + +var apisixtlsesResource = v2.SchemeGroupVersion.WithResource("apisixtlses") + +var apisixtlsesKind = v2.SchemeGroupVersion.WithKind("ApisixTls") + +// Get takes name of the apisixTls, and returns the corresponding apisixTls object, and an error if there is any. +func (c *FakeApisixTlses) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixTls, err error) { + emptyResult := &v2.ApisixTls{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apisixtlsesResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixTls), err +} + +// List takes label and field selectors, and returns the list of ApisixTlses that match those selectors. +func (c *FakeApisixTlses) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixTlsList, err error) { + emptyResult := &v2.ApisixTlsList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apisixtlsesResource, apisixtlsesKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2.ApisixTlsList{ListMeta: obj.(*v2.ApisixTlsList).ListMeta} + for _, item := range obj.(*v2.ApisixTlsList).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 apisixTlses. +func (c *FakeApisixTlses) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apisixtlsesResource, c.ns, opts)) + +} + +// Create takes the representation of a apisixTls and creates it. Returns the server's representation of the apisixTls, and an error, if there is any. +func (c *FakeApisixTlses) Create(ctx context.Context, apisixTls *v2.ApisixTls, opts v1.CreateOptions) (result *v2.ApisixTls, err error) { + emptyResult := &v2.ApisixTls{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apisixtlsesResource, c.ns, apisixTls, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixTls), err +} + +// Update takes the representation of a apisixTls and updates it. Returns the server's representation of the apisixTls, and an error, if there is any. +func (c *FakeApisixTlses) Update(ctx context.Context, apisixTls *v2.ApisixTls, opts v1.UpdateOptions) (result *v2.ApisixTls, err error) { + emptyResult := &v2.ApisixTls{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apisixtlsesResource, c.ns, apisixTls, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixTls), 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 *FakeApisixTlses) UpdateStatus(ctx context.Context, apisixTls *v2.ApisixTls, opts v1.UpdateOptions) (result *v2.ApisixTls, err error) { + emptyResult := &v2.ApisixTls{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixtlsesResource, "status", c.ns, apisixTls, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixTls), err +} + +// Delete takes name of the apisixTls and deletes it. Returns an error if one occurs. +func (c *FakeApisixTlses) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apisixtlsesResource, c.ns, name, opts), &v2.ApisixTls{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeApisixTlses) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apisixtlsesResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v2.ApisixTlsList{}) + return err +} + +// Patch applies the patch and returns the patched apisixTls. +func (c *FakeApisixTlses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixTls, err error) { + emptyResult := &v2.ApisixTls{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixtlsesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixTls), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixupstream.go b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixupstream.go new file mode 100644 index 0000000000..d20d3a0087 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/fake/fake_apisixupstream.go @@ -0,0 +1,148 @@ +// 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" + + v2 "github.com/apache/apisix-ingress-controller/api/v2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeApisixUpstreams implements ApisixUpstreamInterface +type FakeApisixUpstreams struct { + Fake *FakeApisixV2 + ns string +} + +var apisixupstreamsResource = v2.SchemeGroupVersion.WithResource("apisixupstreams") + +var apisixupstreamsKind = v2.SchemeGroupVersion.WithKind("ApisixUpstream") + +// Get takes name of the apisixUpstream, and returns the corresponding apisixUpstream object, and an error if there is any. +func (c *FakeApisixUpstreams) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixUpstream, err error) { + emptyResult := &v2.ApisixUpstream{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(apisixupstreamsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixUpstream), err +} + +// List takes label and field selectors, and returns the list of ApisixUpstreams that match those selectors. +func (c *FakeApisixUpstreams) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixUpstreamList, err error) { + emptyResult := &v2.ApisixUpstreamList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(apisixupstreamsResource, apisixupstreamsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2.ApisixUpstreamList{ListMeta: obj.(*v2.ApisixUpstreamList).ListMeta} + for _, item := range obj.(*v2.ApisixUpstreamList).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 apisixUpstreams. +func (c *FakeApisixUpstreams) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(apisixupstreamsResource, c.ns, opts)) + +} + +// Create takes the representation of a apisixUpstream and creates it. Returns the server's representation of the apisixUpstream, and an error, if there is any. +func (c *FakeApisixUpstreams) Create(ctx context.Context, apisixUpstream *v2.ApisixUpstream, opts v1.CreateOptions) (result *v2.ApisixUpstream, err error) { + emptyResult := &v2.ApisixUpstream{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(apisixupstreamsResource, c.ns, apisixUpstream, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixUpstream), err +} + +// Update takes the representation of a apisixUpstream and updates it. Returns the server's representation of the apisixUpstream, and an error, if there is any. +func (c *FakeApisixUpstreams) Update(ctx context.Context, apisixUpstream *v2.ApisixUpstream, opts v1.UpdateOptions) (result *v2.ApisixUpstream, err error) { + emptyResult := &v2.ApisixUpstream{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(apisixupstreamsResource, c.ns, apisixUpstream, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixUpstream), 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 *FakeApisixUpstreams) UpdateStatus(ctx context.Context, apisixUpstream *v2.ApisixUpstream, opts v1.UpdateOptions) (result *v2.ApisixUpstream, err error) { + emptyResult := &v2.ApisixUpstream{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixupstreamsResource, "status", c.ns, apisixUpstream, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixUpstream), err +} + +// Delete takes name of the apisixUpstream and deletes it. Returns an error if one occurs. +func (c *FakeApisixUpstreams) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(apisixupstreamsResource, c.ns, name, opts), &v2.ApisixUpstream{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeApisixUpstreams) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(apisixupstreamsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v2.ApisixUpstreamList{}) + return err +} + +// Patch applies the patch and returns the patched apisixUpstream. +func (c *FakeApisixUpstreams) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixUpstream, err error) { + emptyResult := &v2.ApisixUpstream{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixupstreamsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v2.ApisixUpstream), err +} diff --git a/pkg/client/clientset/versioned/typed/api/v2/generated_expansion.go b/pkg/client/clientset/versioned/typed/api/v2/generated_expansion.go new file mode 100644 index 0000000000..fb9ef0345a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/api/v2/generated_expansion.go @@ -0,0 +1,32 @@ +// 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 v2 + +type ApisixConsumerExpansion interface{} + +type ApisixGlobalRuleExpansion interface{} + +type ApisixPluginConfigExpansion interface{} + +type ApisixRouteExpansion interface{} + +type ApisixTlsExpansion interface{} + +type ApisixUpstreamExpansion interface{} diff --git a/pkg/client/informers/externalversions/api/interface.go b/pkg/client/informers/externalversions/api/interface.go new file mode 100644 index 0000000000..c1be5e7310 --- /dev/null +++ b/pkg/client/informers/externalversions/api/interface.go @@ -0,0 +1,55 @@ +// 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 api + +import ( + v1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/api/v1alpha1" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/api/v2" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface + // V2 provides access to shared informers for resources in V2. + V2() v2.Interface +} + +type group 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 &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} + +// V2 returns a new v2.Interface. +func (g *group) V2() v2.Interface { + return v2.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/api/v1alpha1/backendtrafficpolicy.go b/pkg/client/informers/externalversions/api/v1alpha1/backendtrafficpolicy.go new file mode 100644 index 0000000000..9d29fa5a6e --- /dev/null +++ b/pkg/client/informers/externalversions/api/v1alpha1/backendtrafficpolicy.go @@ -0,0 +1,91 @@ +// 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 v1alpha1 + +import ( + "context" + time "time" + + apiv1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v1alpha1" + 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" +) + +// BackendTrafficPolicyInformer provides access to a shared informer and lister for +// BackendTrafficPolicies. +type BackendTrafficPolicyInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.BackendTrafficPolicyLister +} + +type backendTrafficPolicyInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewBackendTrafficPolicyInformer constructs a new informer for BackendTrafficPolicy 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 NewBackendTrafficPolicyInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredBackendTrafficPolicyInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredBackendTrafficPolicyInformer constructs a new informer for BackendTrafficPolicy 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 NewFilteredBackendTrafficPolicyInformer(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.ApisixV1alpha1().BackendTrafficPolicies(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV1alpha1().BackendTrafficPolicies(namespace).Watch(context.TODO(), options) + }, + }, + &apiv1alpha1.BackendTrafficPolicy{}, + resyncPeriod, + indexers, + ) +} + +func (f *backendTrafficPolicyInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredBackendTrafficPolicyInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *backendTrafficPolicyInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv1alpha1.BackendTrafficPolicy{}, f.defaultInformer) +} + +func (f *backendTrafficPolicyInformer) Lister() v1alpha1.BackendTrafficPolicyLister { + return v1alpha1.NewBackendTrafficPolicyLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v1alpha1/consumer.go b/pkg/client/informers/externalversions/api/v1alpha1/consumer.go new file mode 100644 index 0000000000..f6fe44c2e5 --- /dev/null +++ b/pkg/client/informers/externalversions/api/v1alpha1/consumer.go @@ -0,0 +1,91 @@ +// 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 v1alpha1 + +import ( + "context" + time "time" + + apiv1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v1alpha1" + 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" +) + +// ConsumerInformer provides access to a shared informer and lister for +// Consumers. +type ConsumerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ConsumerLister +} + +type consumerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewConsumerInformer constructs a new informer for Consumer 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 NewConsumerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredConsumerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredConsumerInformer constructs a new informer for Consumer 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 NewFilteredConsumerInformer(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.ApisixV1alpha1().Consumers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV1alpha1().Consumers(namespace).Watch(context.TODO(), options) + }, + }, + &apiv1alpha1.Consumer{}, + resyncPeriod, + indexers, + ) +} + +func (f *consumerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredConsumerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *consumerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv1alpha1.Consumer{}, f.defaultInformer) +} + +func (f *consumerInformer) Lister() v1alpha1.ConsumerLister { + return v1alpha1.NewConsumerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v1alpha1/interface.go b/pkg/client/informers/externalversions/api/v1alpha1/interface.go new file mode 100644 index 0000000000..eb5475d296 --- /dev/null +++ b/pkg/client/informers/externalversions/api/v1alpha1/interface.go @@ -0,0 +1,53 @@ +// 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 v1alpha1 + +import ( + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // BackendTrafficPolicies returns a BackendTrafficPolicyInformer. + BackendTrafficPolicies() BackendTrafficPolicyInformer + // Consumers returns a ConsumerInformer. + Consumers() ConsumerInformer +} + +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} +} + +// BackendTrafficPolicies returns a BackendTrafficPolicyInformer. +func (v *version) BackendTrafficPolicies() BackendTrafficPolicyInformer { + return &backendTrafficPolicyInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Consumers returns a ConsumerInformer. +func (v *version) Consumers() ConsumerInformer { + return &consumerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/api/v2/apisixconsumer.go b/pkg/client/informers/externalversions/api/v2/apisixconsumer.go new file mode 100644 index 0000000000..a2d71585ff --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/apisixconsumer.go @@ -0,0 +1,91 @@ +// 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 v2 + +import ( + "context" + time "time" + + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v2" + 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" +) + +// ApisixConsumerInformer provides access to a shared informer and lister for +// ApisixConsumers. +type ApisixConsumerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v2.ApisixConsumerLister +} + +type apisixConsumerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewApisixConsumerInformer constructs a new informer for ApisixConsumer 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 NewApisixConsumerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredApisixConsumerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredApisixConsumerInformer constructs a new informer for ApisixConsumer 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 NewFilteredApisixConsumerInformer(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.ApisixV2().ApisixConsumers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2().ApisixConsumers(namespace).Watch(context.TODO(), options) + }, + }, + &apiv2.ApisixConsumer{}, + resyncPeriod, + indexers, + ) +} + +func (f *apisixConsumerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredApisixConsumerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *apisixConsumerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv2.ApisixConsumer{}, f.defaultInformer) +} + +func (f *apisixConsumerInformer) Lister() v2.ApisixConsumerLister { + return v2.NewApisixConsumerLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v2/apisixglobalrule.go b/pkg/client/informers/externalversions/api/v2/apisixglobalrule.go new file mode 100644 index 0000000000..289a5ea749 --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/apisixglobalrule.go @@ -0,0 +1,91 @@ +// 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 v2 + +import ( + "context" + time "time" + + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v2" + 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" +) + +// ApisixGlobalRuleInformer provides access to a shared informer and lister for +// ApisixGlobalRules. +type ApisixGlobalRuleInformer interface { + Informer() cache.SharedIndexInformer + Lister() v2.ApisixGlobalRuleLister +} + +type apisixGlobalRuleInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewApisixGlobalRuleInformer constructs a new informer for ApisixGlobalRule 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 NewApisixGlobalRuleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredApisixGlobalRuleInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredApisixGlobalRuleInformer constructs a new informer for ApisixGlobalRule 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 NewFilteredApisixGlobalRuleInformer(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.ApisixV2().ApisixGlobalRules(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2().ApisixGlobalRules(namespace).Watch(context.TODO(), options) + }, + }, + &apiv2.ApisixGlobalRule{}, + resyncPeriod, + indexers, + ) +} + +func (f *apisixGlobalRuleInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredApisixGlobalRuleInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *apisixGlobalRuleInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv2.ApisixGlobalRule{}, f.defaultInformer) +} + +func (f *apisixGlobalRuleInformer) Lister() v2.ApisixGlobalRuleLister { + return v2.NewApisixGlobalRuleLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v2/apisixpluginconfig.go b/pkg/client/informers/externalversions/api/v2/apisixpluginconfig.go new file mode 100644 index 0000000000..8653ff09ab --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/apisixpluginconfig.go @@ -0,0 +1,91 @@ +// 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 v2 + +import ( + "context" + time "time" + + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v2" + 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" +) + +// ApisixPluginConfigInformer provides access to a shared informer and lister for +// ApisixPluginConfigs. +type ApisixPluginConfigInformer interface { + Informer() cache.SharedIndexInformer + Lister() v2.ApisixPluginConfigLister +} + +type apisixPluginConfigInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewApisixPluginConfigInformer constructs a new informer for ApisixPluginConfig 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 NewApisixPluginConfigInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredApisixPluginConfigInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredApisixPluginConfigInformer constructs a new informer for ApisixPluginConfig 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 NewFilteredApisixPluginConfigInformer(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.ApisixV2().ApisixPluginConfigs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2().ApisixPluginConfigs(namespace).Watch(context.TODO(), options) + }, + }, + &apiv2.ApisixPluginConfig{}, + resyncPeriod, + indexers, + ) +} + +func (f *apisixPluginConfigInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredApisixPluginConfigInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *apisixPluginConfigInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv2.ApisixPluginConfig{}, f.defaultInformer) +} + +func (f *apisixPluginConfigInformer) Lister() v2.ApisixPluginConfigLister { + return v2.NewApisixPluginConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v2/apisixroute.go b/pkg/client/informers/externalversions/api/v2/apisixroute.go new file mode 100644 index 0000000000..eb4a5de65d --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/apisixroute.go @@ -0,0 +1,91 @@ +// 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 v2 + +import ( + "context" + time "time" + + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v2" + 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() v2.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.ApisixV2().ApisixRoutes(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2().ApisixRoutes(namespace).Watch(context.TODO(), options) + }, + }, + &apiv2.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(&apiv2.ApisixRoute{}, f.defaultInformer) +} + +func (f *apisixRouteInformer) Lister() v2.ApisixRouteLister { + return v2.NewApisixRouteLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v2/apisixtls.go b/pkg/client/informers/externalversions/api/v2/apisixtls.go new file mode 100644 index 0000000000..93bd6b8cfe --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/apisixtls.go @@ -0,0 +1,91 @@ +// 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 v2 + +import ( + "context" + time "time" + + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v2" + 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" +) + +// ApisixTlsInformer provides access to a shared informer and lister for +// ApisixTlses. +type ApisixTlsInformer interface { + Informer() cache.SharedIndexInformer + Lister() v2.ApisixTlsLister +} + +type apisixTlsInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewApisixTlsInformer constructs a new informer for ApisixTls 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 NewApisixTlsInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredApisixTlsInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredApisixTlsInformer constructs a new informer for ApisixTls 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 NewFilteredApisixTlsInformer(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.ApisixV2().ApisixTlses(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2().ApisixTlses(namespace).Watch(context.TODO(), options) + }, + }, + &apiv2.ApisixTls{}, + resyncPeriod, + indexers, + ) +} + +func (f *apisixTlsInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredApisixTlsInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *apisixTlsInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv2.ApisixTls{}, f.defaultInformer) +} + +func (f *apisixTlsInformer) Lister() v2.ApisixTlsLister { + return v2.NewApisixTlsLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v2/apisixupstream.go b/pkg/client/informers/externalversions/api/v2/apisixupstream.go new file mode 100644 index 0000000000..7852c36142 --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/apisixupstream.go @@ -0,0 +1,91 @@ +// 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 v2 + +import ( + "context" + time "time" + + apiv2 "github.com/apache/apisix-ingress-controller/api/v2" + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v2 "github.com/apache/apisix-ingress-controller/pkg/client/listers/api/v2" + 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" +) + +// ApisixUpstreamInformer provides access to a shared informer and lister for +// ApisixUpstreams. +type ApisixUpstreamInformer interface { + Informer() cache.SharedIndexInformer + Lister() v2.ApisixUpstreamLister +} + +type apisixUpstreamInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewApisixUpstreamInformer constructs a new informer for ApisixUpstream 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 NewApisixUpstreamInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredApisixUpstreamInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredApisixUpstreamInformer constructs a new informer for ApisixUpstream 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 NewFilteredApisixUpstreamInformer(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.ApisixV2().ApisixUpstreams(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2().ApisixUpstreams(namespace).Watch(context.TODO(), options) + }, + }, + &apiv2.ApisixUpstream{}, + resyncPeriod, + indexers, + ) +} + +func (f *apisixUpstreamInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredApisixUpstreamInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *apisixUpstreamInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiv2.ApisixUpstream{}, f.defaultInformer) +} + +func (f *apisixUpstreamInformer) Lister() v2.ApisixUpstreamLister { + return v2.NewApisixUpstreamLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/api/v2/interface.go b/pkg/client/informers/externalversions/api/v2/interface.go new file mode 100644 index 0000000000..a3d7699b75 --- /dev/null +++ b/pkg/client/informers/externalversions/api/v2/interface.go @@ -0,0 +1,81 @@ +// 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 v2 + +import ( + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // ApisixConsumers returns a ApisixConsumerInformer. + ApisixConsumers() ApisixConsumerInformer + // ApisixGlobalRules returns a ApisixGlobalRuleInformer. + ApisixGlobalRules() ApisixGlobalRuleInformer + // ApisixPluginConfigs returns a ApisixPluginConfigInformer. + ApisixPluginConfigs() ApisixPluginConfigInformer + // ApisixRoutes returns a ApisixRouteInformer. + ApisixRoutes() ApisixRouteInformer + // ApisixTlses returns a ApisixTlsInformer. + ApisixTlses() ApisixTlsInformer + // ApisixUpstreams returns a ApisixUpstreamInformer. + ApisixUpstreams() ApisixUpstreamInformer +} + +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} +} + +// ApisixConsumers returns a ApisixConsumerInformer. +func (v *version) ApisixConsumers() ApisixConsumerInformer { + return &apisixConsumerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ApisixGlobalRules returns a ApisixGlobalRuleInformer. +func (v *version) ApisixGlobalRules() ApisixGlobalRuleInformer { + return &apisixGlobalRuleInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ApisixPluginConfigs returns a ApisixPluginConfigInformer. +func (v *version) ApisixPluginConfigs() ApisixPluginConfigInformer { + return &apisixPluginConfigInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ApisixRoutes returns a ApisixRouteInformer. +func (v *version) ApisixRoutes() ApisixRouteInformer { + return &apisixRouteInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ApisixTlses returns a ApisixTlsInformer. +func (v *version) ApisixTlses() ApisixTlsInformer { + return &apisixTlsInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ApisixUpstreams returns a ApisixUpstreamInformer. +func (v *version) ApisixUpstreams() ApisixUpstreamInformer { + return &apisixUpstreamInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 0000000000..20477025aa --- /dev/null +++ b/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,263 @@ +// 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 externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + api "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/api" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/client/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + informer.SetTransform(f.transform) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + // Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Apisix() api.Interface +} + +func (f *sharedInformerFactory) Apisix() api.Interface { + return api.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go new file mode 100644 index 0000000000..fa8c172976 --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,80 @@ +// 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 externalversions + +import ( + "fmt" + + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + v2 "github.com/apache/apisix-ingress-controller/api/v2" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// 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=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("backendtrafficpolicies"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V1alpha1().BackendTrafficPolicies().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("consumers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V1alpha1().Consumers().Informer()}, nil + + // Group=apisix.apache.org, Version=v2 + case v2.SchemeGroupVersion.WithResource("apisixconsumers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2().ApisixConsumers().Informer()}, nil + case v2.SchemeGroupVersion.WithResource("apisixglobalrules"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2().ApisixGlobalRules().Informer()}, nil + case v2.SchemeGroupVersion.WithResource("apisixpluginconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2().ApisixPluginConfigs().Informer()}, nil + case v2.SchemeGroupVersion.WithResource("apisixroutes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2().ApisixRoutes().Informer()}, nil + case v2.SchemeGroupVersion.WithResource("apisixtlses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2().ApisixTlses().Informer()}, nil + case v2.SchemeGroupVersion.WithResource("apisixupstreams"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2().ApisixUpstreams().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000000..30545e98f3 --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,41 @@ +// 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 internalinterfaces + +import ( + time "time" + + versioned "github.com/apache/apisix-ingress-controller/pkg/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/listers/api/v1alpha1/backendtrafficpolicy.go b/pkg/client/listers/api/v1alpha1/backendtrafficpolicy.go new file mode 100644 index 0000000000..e72beb3cad --- /dev/null +++ b/pkg/client/listers/api/v1alpha1/backendtrafficpolicy.go @@ -0,0 +1,71 @@ +// 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 v1alpha1 + +import ( + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// BackendTrafficPolicyLister helps list BackendTrafficPolicies. +// All objects returned here must be treated as read-only. +type BackendTrafficPolicyLister interface { + // List lists all BackendTrafficPolicies in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.BackendTrafficPolicy, err error) + // BackendTrafficPolicies returns an object that can list and get BackendTrafficPolicies. + BackendTrafficPolicies(namespace string) BackendTrafficPolicyNamespaceLister + BackendTrafficPolicyListerExpansion +} + +// backendTrafficPolicyLister implements the BackendTrafficPolicyLister interface. +type backendTrafficPolicyLister struct { + listers.ResourceIndexer[*v1alpha1.BackendTrafficPolicy] +} + +// NewBackendTrafficPolicyLister returns a new BackendTrafficPolicyLister. +func NewBackendTrafficPolicyLister(indexer cache.Indexer) BackendTrafficPolicyLister { + return &backendTrafficPolicyLister{listers.New[*v1alpha1.BackendTrafficPolicy](indexer, v1alpha1.Resource("backendtrafficpolicy"))} +} + +// BackendTrafficPolicies returns an object that can list and get BackendTrafficPolicies. +func (s *backendTrafficPolicyLister) BackendTrafficPolicies(namespace string) BackendTrafficPolicyNamespaceLister { + return backendTrafficPolicyNamespaceLister{listers.NewNamespaced[*v1alpha1.BackendTrafficPolicy](s.ResourceIndexer, namespace)} +} + +// BackendTrafficPolicyNamespaceLister helps list and get BackendTrafficPolicies. +// All objects returned here must be treated as read-only. +type BackendTrafficPolicyNamespaceLister interface { + // List lists all BackendTrafficPolicies in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.BackendTrafficPolicy, err error) + // Get retrieves the BackendTrafficPolicy from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.BackendTrafficPolicy, error) + BackendTrafficPolicyNamespaceListerExpansion +} + +// backendTrafficPolicyNamespaceLister implements the BackendTrafficPolicyNamespaceLister +// interface. +type backendTrafficPolicyNamespaceLister struct { + listers.ResourceIndexer[*v1alpha1.BackendTrafficPolicy] +} diff --git a/pkg/client/listers/api/v1alpha1/consumer.go b/pkg/client/listers/api/v1alpha1/consumer.go new file mode 100644 index 0000000000..a50ace41b7 --- /dev/null +++ b/pkg/client/listers/api/v1alpha1/consumer.go @@ -0,0 +1,71 @@ +// 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 v1alpha1 + +import ( + v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// ConsumerLister helps list Consumers. +// All objects returned here must be treated as read-only. +type ConsumerLister interface { + // List lists all Consumers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Consumer, err error) + // Consumers returns an object that can list and get Consumers. + Consumers(namespace string) ConsumerNamespaceLister + ConsumerListerExpansion +} + +// consumerLister implements the ConsumerLister interface. +type consumerLister struct { + listers.ResourceIndexer[*v1alpha1.Consumer] +} + +// NewConsumerLister returns a new ConsumerLister. +func NewConsumerLister(indexer cache.Indexer) ConsumerLister { + return &consumerLister{listers.New[*v1alpha1.Consumer](indexer, v1alpha1.Resource("consumer"))} +} + +// Consumers returns an object that can list and get Consumers. +func (s *consumerLister) Consumers(namespace string) ConsumerNamespaceLister { + return consumerNamespaceLister{listers.NewNamespaced[*v1alpha1.Consumer](s.ResourceIndexer, namespace)} +} + +// ConsumerNamespaceLister helps list and get Consumers. +// All objects returned here must be treated as read-only. +type ConsumerNamespaceLister interface { + // List lists all Consumers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Consumer, err error) + // Get retrieves the Consumer from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Consumer, error) + ConsumerNamespaceListerExpansion +} + +// consumerNamespaceLister implements the ConsumerNamespaceLister +// interface. +type consumerNamespaceLister struct { + listers.ResourceIndexer[*v1alpha1.Consumer] +} diff --git a/pkg/client/listers/api/v1alpha1/expansion_generated.go b/pkg/client/listers/api/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..c1d389bd0d --- /dev/null +++ b/pkg/client/listers/api/v1alpha1/expansion_generated.go @@ -0,0 +1,36 @@ +// 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 v1alpha1 + +// BackendTrafficPolicyListerExpansion allows custom methods to be added to +// BackendTrafficPolicyLister. +type BackendTrafficPolicyListerExpansion interface{} + +// BackendTrafficPolicyNamespaceListerExpansion allows custom methods to be added to +// BackendTrafficPolicyNamespaceLister. +type BackendTrafficPolicyNamespaceListerExpansion interface{} + +// ConsumerListerExpansion allows custom methods to be added to +// ConsumerLister. +type ConsumerListerExpansion interface{} + +// ConsumerNamespaceListerExpansion allows custom methods to be added to +// ConsumerNamespaceLister. +type ConsumerNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/api/v2/apisixconsumer.go b/pkg/client/listers/api/v2/apisixconsumer.go new file mode 100644 index 0000000000..a3443995f6 --- /dev/null +++ b/pkg/client/listers/api/v2/apisixconsumer.go @@ -0,0 +1,71 @@ +// 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 v2 + +import ( + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// ApisixConsumerLister helps list ApisixConsumers. +// All objects returned here must be treated as read-only. +type ApisixConsumerLister interface { + // List lists all ApisixConsumers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixConsumer, err error) + // ApisixConsumers returns an object that can list and get ApisixConsumers. + ApisixConsumers(namespace string) ApisixConsumerNamespaceLister + ApisixConsumerListerExpansion +} + +// apisixConsumerLister implements the ApisixConsumerLister interface. +type apisixConsumerLister struct { + listers.ResourceIndexer[*v2.ApisixConsumer] +} + +// NewApisixConsumerLister returns a new ApisixConsumerLister. +func NewApisixConsumerLister(indexer cache.Indexer) ApisixConsumerLister { + return &apisixConsumerLister{listers.New[*v2.ApisixConsumer](indexer, v2.Resource("apisixconsumer"))} +} + +// ApisixConsumers returns an object that can list and get ApisixConsumers. +func (s *apisixConsumerLister) ApisixConsumers(namespace string) ApisixConsumerNamespaceLister { + return apisixConsumerNamespaceLister{listers.NewNamespaced[*v2.ApisixConsumer](s.ResourceIndexer, namespace)} +} + +// ApisixConsumerNamespaceLister helps list and get ApisixConsumers. +// All objects returned here must be treated as read-only. +type ApisixConsumerNamespaceLister interface { + // List lists all ApisixConsumers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixConsumer, err error) + // Get retrieves the ApisixConsumer from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v2.ApisixConsumer, error) + ApisixConsumerNamespaceListerExpansion +} + +// apisixConsumerNamespaceLister implements the ApisixConsumerNamespaceLister +// interface. +type apisixConsumerNamespaceLister struct { + listers.ResourceIndexer[*v2.ApisixConsumer] +} diff --git a/pkg/client/listers/api/v2/apisixglobalrule.go b/pkg/client/listers/api/v2/apisixglobalrule.go new file mode 100644 index 0000000000..027b5ae100 --- /dev/null +++ b/pkg/client/listers/api/v2/apisixglobalrule.go @@ -0,0 +1,71 @@ +// 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 v2 + +import ( + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// ApisixGlobalRuleLister helps list ApisixGlobalRules. +// All objects returned here must be treated as read-only. +type ApisixGlobalRuleLister interface { + // List lists all ApisixGlobalRules in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixGlobalRule, err error) + // ApisixGlobalRules returns an object that can list and get ApisixGlobalRules. + ApisixGlobalRules(namespace string) ApisixGlobalRuleNamespaceLister + ApisixGlobalRuleListerExpansion +} + +// apisixGlobalRuleLister implements the ApisixGlobalRuleLister interface. +type apisixGlobalRuleLister struct { + listers.ResourceIndexer[*v2.ApisixGlobalRule] +} + +// NewApisixGlobalRuleLister returns a new ApisixGlobalRuleLister. +func NewApisixGlobalRuleLister(indexer cache.Indexer) ApisixGlobalRuleLister { + return &apisixGlobalRuleLister{listers.New[*v2.ApisixGlobalRule](indexer, v2.Resource("apisixglobalrule"))} +} + +// ApisixGlobalRules returns an object that can list and get ApisixGlobalRules. +func (s *apisixGlobalRuleLister) ApisixGlobalRules(namespace string) ApisixGlobalRuleNamespaceLister { + return apisixGlobalRuleNamespaceLister{listers.NewNamespaced[*v2.ApisixGlobalRule](s.ResourceIndexer, namespace)} +} + +// ApisixGlobalRuleNamespaceLister helps list and get ApisixGlobalRules. +// All objects returned here must be treated as read-only. +type ApisixGlobalRuleNamespaceLister interface { + // List lists all ApisixGlobalRules in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixGlobalRule, err error) + // Get retrieves the ApisixGlobalRule from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v2.ApisixGlobalRule, error) + ApisixGlobalRuleNamespaceListerExpansion +} + +// apisixGlobalRuleNamespaceLister implements the ApisixGlobalRuleNamespaceLister +// interface. +type apisixGlobalRuleNamespaceLister struct { + listers.ResourceIndexer[*v2.ApisixGlobalRule] +} diff --git a/pkg/client/listers/api/v2/apisixpluginconfig.go b/pkg/client/listers/api/v2/apisixpluginconfig.go new file mode 100644 index 0000000000..64515ba1a8 --- /dev/null +++ b/pkg/client/listers/api/v2/apisixpluginconfig.go @@ -0,0 +1,71 @@ +// 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 v2 + +import ( + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// ApisixPluginConfigLister helps list ApisixPluginConfigs. +// All objects returned here must be treated as read-only. +type ApisixPluginConfigLister interface { + // List lists all ApisixPluginConfigs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixPluginConfig, err error) + // ApisixPluginConfigs returns an object that can list and get ApisixPluginConfigs. + ApisixPluginConfigs(namespace string) ApisixPluginConfigNamespaceLister + ApisixPluginConfigListerExpansion +} + +// apisixPluginConfigLister implements the ApisixPluginConfigLister interface. +type apisixPluginConfigLister struct { + listers.ResourceIndexer[*v2.ApisixPluginConfig] +} + +// NewApisixPluginConfigLister returns a new ApisixPluginConfigLister. +func NewApisixPluginConfigLister(indexer cache.Indexer) ApisixPluginConfigLister { + return &apisixPluginConfigLister{listers.New[*v2.ApisixPluginConfig](indexer, v2.Resource("apisixpluginconfig"))} +} + +// ApisixPluginConfigs returns an object that can list and get ApisixPluginConfigs. +func (s *apisixPluginConfigLister) ApisixPluginConfigs(namespace string) ApisixPluginConfigNamespaceLister { + return apisixPluginConfigNamespaceLister{listers.NewNamespaced[*v2.ApisixPluginConfig](s.ResourceIndexer, namespace)} +} + +// ApisixPluginConfigNamespaceLister helps list and get ApisixPluginConfigs. +// All objects returned here must be treated as read-only. +type ApisixPluginConfigNamespaceLister interface { + // List lists all ApisixPluginConfigs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixPluginConfig, err error) + // Get retrieves the ApisixPluginConfig from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v2.ApisixPluginConfig, error) + ApisixPluginConfigNamespaceListerExpansion +} + +// apisixPluginConfigNamespaceLister implements the ApisixPluginConfigNamespaceLister +// interface. +type apisixPluginConfigNamespaceLister struct { + listers.ResourceIndexer[*v2.ApisixPluginConfig] +} diff --git a/pkg/client/listers/api/v2/apisixroute.go b/pkg/client/listers/api/v2/apisixroute.go new file mode 100644 index 0000000000..7e725cd778 --- /dev/null +++ b/pkg/client/listers/api/v2/apisixroute.go @@ -0,0 +1,71 @@ +// 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 v2 + +import ( + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "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 []*v2.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 { + listers.ResourceIndexer[*v2.ApisixRoute] +} + +// NewApisixRouteLister returns a new ApisixRouteLister. +func NewApisixRouteLister(indexer cache.Indexer) ApisixRouteLister { + return &apisixRouteLister{listers.New[*v2.ApisixRoute](indexer, v2.Resource("apisixroute"))} +} + +// ApisixRoutes returns an object that can list and get ApisixRoutes. +func (s *apisixRouteLister) ApisixRoutes(namespace string) ApisixRouteNamespaceLister { + return apisixRouteNamespaceLister{listers.NewNamespaced[*v2.ApisixRoute](s.ResourceIndexer, 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 []*v2.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) (*v2.ApisixRoute, error) + ApisixRouteNamespaceListerExpansion +} + +// apisixRouteNamespaceLister implements the ApisixRouteNamespaceLister +// interface. +type apisixRouteNamespaceLister struct { + listers.ResourceIndexer[*v2.ApisixRoute] +} diff --git a/pkg/client/listers/api/v2/apisixtls.go b/pkg/client/listers/api/v2/apisixtls.go new file mode 100644 index 0000000000..6a67929807 --- /dev/null +++ b/pkg/client/listers/api/v2/apisixtls.go @@ -0,0 +1,71 @@ +// 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 v2 + +import ( + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// ApisixTlsLister helps list ApisixTlses. +// All objects returned here must be treated as read-only. +type ApisixTlsLister interface { + // List lists all ApisixTlses in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixTls, err error) + // ApisixTlses returns an object that can list and get ApisixTlses. + ApisixTlses(namespace string) ApisixTlsNamespaceLister + ApisixTlsListerExpansion +} + +// apisixTlsLister implements the ApisixTlsLister interface. +type apisixTlsLister struct { + listers.ResourceIndexer[*v2.ApisixTls] +} + +// NewApisixTlsLister returns a new ApisixTlsLister. +func NewApisixTlsLister(indexer cache.Indexer) ApisixTlsLister { + return &apisixTlsLister{listers.New[*v2.ApisixTls](indexer, v2.Resource("apisixtls"))} +} + +// ApisixTlses returns an object that can list and get ApisixTlses. +func (s *apisixTlsLister) ApisixTlses(namespace string) ApisixTlsNamespaceLister { + return apisixTlsNamespaceLister{listers.NewNamespaced[*v2.ApisixTls](s.ResourceIndexer, namespace)} +} + +// ApisixTlsNamespaceLister helps list and get ApisixTlses. +// All objects returned here must be treated as read-only. +type ApisixTlsNamespaceLister interface { + // List lists all ApisixTlses in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixTls, err error) + // Get retrieves the ApisixTls from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v2.ApisixTls, error) + ApisixTlsNamespaceListerExpansion +} + +// apisixTlsNamespaceLister implements the ApisixTlsNamespaceLister +// interface. +type apisixTlsNamespaceLister struct { + listers.ResourceIndexer[*v2.ApisixTls] +} diff --git a/pkg/client/listers/api/v2/apisixupstream.go b/pkg/client/listers/api/v2/apisixupstream.go new file mode 100644 index 0000000000..7f3928be77 --- /dev/null +++ b/pkg/client/listers/api/v2/apisixupstream.go @@ -0,0 +1,71 @@ +// 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 v2 + +import ( + v2 "github.com/apache/apisix-ingress-controller/api/v2" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// ApisixUpstreamLister helps list ApisixUpstreams. +// All objects returned here must be treated as read-only. +type ApisixUpstreamLister interface { + // List lists all ApisixUpstreams in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixUpstream, err error) + // ApisixUpstreams returns an object that can list and get ApisixUpstreams. + ApisixUpstreams(namespace string) ApisixUpstreamNamespaceLister + ApisixUpstreamListerExpansion +} + +// apisixUpstreamLister implements the ApisixUpstreamLister interface. +type apisixUpstreamLister struct { + listers.ResourceIndexer[*v2.ApisixUpstream] +} + +// NewApisixUpstreamLister returns a new ApisixUpstreamLister. +func NewApisixUpstreamLister(indexer cache.Indexer) ApisixUpstreamLister { + return &apisixUpstreamLister{listers.New[*v2.ApisixUpstream](indexer, v2.Resource("apisixupstream"))} +} + +// ApisixUpstreams returns an object that can list and get ApisixUpstreams. +func (s *apisixUpstreamLister) ApisixUpstreams(namespace string) ApisixUpstreamNamespaceLister { + return apisixUpstreamNamespaceLister{listers.NewNamespaced[*v2.ApisixUpstream](s.ResourceIndexer, namespace)} +} + +// ApisixUpstreamNamespaceLister helps list and get ApisixUpstreams. +// All objects returned here must be treated as read-only. +type ApisixUpstreamNamespaceLister interface { + // List lists all ApisixUpstreams in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v2.ApisixUpstream, err error) + // Get retrieves the ApisixUpstream from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v2.ApisixUpstream, error) + ApisixUpstreamNamespaceListerExpansion +} + +// apisixUpstreamNamespaceLister implements the ApisixUpstreamNamespaceLister +// interface. +type apisixUpstreamNamespaceLister struct { + listers.ResourceIndexer[*v2.ApisixUpstream] +} diff --git a/pkg/client/listers/api/v2/expansion_generated.go b/pkg/client/listers/api/v2/expansion_generated.go new file mode 100644 index 0000000000..7eb371d306 --- /dev/null +++ b/pkg/client/listers/api/v2/expansion_generated.go @@ -0,0 +1,68 @@ +// 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 v2 + +// ApisixConsumerListerExpansion allows custom methods to be added to +// ApisixConsumerLister. +type ApisixConsumerListerExpansion interface{} + +// ApisixConsumerNamespaceListerExpansion allows custom methods to be added to +// ApisixConsumerNamespaceLister. +type ApisixConsumerNamespaceListerExpansion interface{} + +// ApisixGlobalRuleListerExpansion allows custom methods to be added to +// ApisixGlobalRuleLister. +type ApisixGlobalRuleListerExpansion interface{} + +// ApisixGlobalRuleNamespaceListerExpansion allows custom methods to be added to +// ApisixGlobalRuleNamespaceLister. +type ApisixGlobalRuleNamespaceListerExpansion interface{} + +// ApisixPluginConfigListerExpansion allows custom methods to be added to +// ApisixPluginConfigLister. +type ApisixPluginConfigListerExpansion interface{} + +// ApisixPluginConfigNamespaceListerExpansion allows custom methods to be added to +// ApisixPluginConfigNamespaceLister. +type ApisixPluginConfigNamespaceListerExpansion interface{} + +// ApisixRouteListerExpansion allows custom methods to be added to +// ApisixRouteLister. +type ApisixRouteListerExpansion interface{} + +// ApisixRouteNamespaceListerExpansion allows custom methods to be added to +// ApisixRouteNamespaceLister. +type ApisixRouteNamespaceListerExpansion interface{} + +// ApisixTlsListerExpansion allows custom methods to be added to +// ApisixTlsLister. +type ApisixTlsListerExpansion interface{} + +// ApisixTlsNamespaceListerExpansion allows custom methods to be added to +// ApisixTlsNamespaceLister. +type ApisixTlsNamespaceListerExpansion interface{} + +// ApisixUpstreamListerExpansion allows custom methods to be added to +// ApisixUpstreamLister. +type ApisixUpstreamListerExpansion interface{} + +// ApisixUpstreamNamespaceListerExpansion allows custom methods to be added to +// ApisixUpstreamNamespaceLister. +type ApisixUpstreamNamespaceListerExpansion interface{} diff --git a/scripts/kube_codegen.sh b/scripts/kube_codegen.sh new file mode 100644 index 0000000000..f517fba9d2 --- /dev/null +++ b/scripts/kube_codegen.sh @@ -0,0 +1,759 @@ +#!/usr/bin/env bash + +# Copyright 2023 The Kubernetes Authors. +# +# Licensed 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. + +# This presents several functions for packages which want to use kubernetes +# code-generation tools. + +# These functions insist that your input IDL (commented go) files be located in +# go packages following the pattern $input_pkg_root/$something_sans_slash/$api_version . +# Those $something_sans_slash will be propagated into the output directory structure. + +set -o errexit +set -o nounset +set -o pipefail + +KUBE_CODEGEN_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" + +function kube::codegen::internal::findz() { + # We use `find` rather than `git ls-files` because sometimes external + # projects use this across repos. This is an imperfect wrapper of find, + # but good enough for this script. + find "$@" -print0 +} + +function kube::codegen::internal::grep() { + # We use `grep` rather than `git grep` because sometimes external projects + # use this across repos. + grep "$@" \ + --exclude-dir .git \ + --exclude-dir _output \ + --exclude-dir vendor +} + +# Generate tagged helper code: conversions, deepcopy, and defaults +# +# USAGE: kube::codegen::gen_helpers [FLAGS] +# +# +# The root directory under which to search for Go files which request code to +# be generated. This must be a local path, not a Go package. +# +# See note at the top about package structure below that. +# +# FLAGS: +# +# --boilerplate +# An optional override for the header file to insert into generated files. +# +# --extra-peer-dir +# An optional list (this flag may be specified multiple times) of "extra" +# directories to consider during conversion generation. +# +function kube::codegen::gen_helpers() { + local in_dir="" + local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt" + local v="${KUBE_VERBOSE:-0}" + local extra_peers=() + + while [ "$#" -gt 0 ]; do + case "$1" in + "--boilerplate") + boilerplate="$2" + shift 2 + ;; + "--extra-peer-dir") + extra_peers+=("$2") + shift 2 + ;; + *) + if [[ "$1" =~ ^-- ]]; then + echo "unknown argument: $1" >&2 + return 1 + fi + if [ -n "$in_dir" ]; then + echo "too many arguments: $1 (already have $in_dir)" >&2 + return 1 + fi + in_dir="$1" + shift + ;; + esac + done + + if [ -z "${in_dir}" ]; then + echo "input-dir argument is required" >&2 + return 1 + fi + + ( + # To support running this from anywhere, first cd into this directory, + # and then install with forced module mode on and fully qualified name. + cd "${KUBE_CODEGEN_ROOT}" + BINS=( + conversion-gen + deepcopy-gen + defaulter-gen + ) + # shellcheck disable=2046 # printf word-splitting is intentional + GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}") + ) + # Go installs in $GOBIN if defined, and $GOPATH/bin otherwise + gobin="${GOBIN:-$(go env GOPATH)/bin}" + + # Deepcopy + # + local input_pkgs=() + while read -r dir; do + pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" + input_pkgs+=("${pkg}") + done < <( + ( kube::codegen::internal::grep -l --null \ + -e '^\s*//\s*+k8s:deepcopy-gen=' \ + -r "${in_dir}" \ + --include '*.go' \ + || true \ + ) | while read -r -d $'\0' F; do dirname "${F}"; done \ + | LC_ALL=C sort -u + ) + + if [ "${#input_pkgs[@]}" != 0 ]; then + echo "Generating deepcopy code for ${#input_pkgs[@]} targets" + + kube::codegen::internal::findz \ + "${in_dir}" \ + -type f \ + -name zz_generated.deepcopy.go \ + | xargs -0 rm -f + + "${gobin}/deepcopy-gen" \ + -v "${v}" \ + --output-file zz_generated.deepcopy.go \ + --go-header-file "${boilerplate}" \ + "${input_pkgs[@]}" + fi + + # Defaults + # + local input_pkgs=() + while read -r dir; do + pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" + input_pkgs+=("${pkg}") + done < <( + ( kube::codegen::internal::grep -l --null \ + -e '^\s*//\s*+k8s:defaulter-gen=' \ + -r "${in_dir}" \ + --include '*.go' \ + || true \ + ) | while read -r -d $'\0' F; do dirname "${F}"; done \ + | LC_ALL=C sort -u + ) + + if [ "${#input_pkgs[@]}" != 0 ]; then + echo "Generating defaulter code for ${#input_pkgs[@]} targets" + + kube::codegen::internal::findz \ + "${in_dir}" \ + -type f \ + -name zz_generated.defaults.go \ + | xargs -0 rm -f + + "${gobin}/defaulter-gen" \ + -v "${v}" \ + --output-file zz_generated.defaults.go \ + --go-header-file "${boilerplate}" \ + "${input_pkgs[@]}" + fi + + # Conversions + # + local input_pkgs=() + while read -r dir; do + pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" + input_pkgs+=("${pkg}") + done < <( + ( kube::codegen::internal::grep -l --null \ + -e '^\s*//\s*+k8s:conversion-gen=' \ + -r "${in_dir}" \ + --include '*.go' \ + || true \ + ) | while read -r -d $'\0' F; do dirname "${F}"; done \ + | LC_ALL=C sort -u + ) + + if [ "${#input_pkgs[@]}" != 0 ]; then + echo "Generating conversion code for ${#input_pkgs[@]} targets" + + kube::codegen::internal::findz \ + "${in_dir}" \ + -type f \ + -name zz_generated.conversion.go \ + | xargs -0 rm -f + + local extra_peer_args=() + for arg in "${extra_peers[@]:+"${extra_peers[@]}"}"; do + extra_peer_args+=("--extra-peer-dirs" "$arg") + done + "${gobin}/conversion-gen" \ + -v "${v}" \ + --output-file zz_generated.conversion.go \ + --go-header-file "${boilerplate}" \ + "${extra_peer_args[@]:+"${extra_peer_args[@]}"}" \ + "${input_pkgs[@]}" + fi +} + +# Generate openapi code +# +# USAGE: kube::codegen::gen_openapi [FLAGS] +# +# +# The root directory under which to search for Go files which request openapi +# to be generated. This must be a local path, not a Go package. +# +# See note at the top about package structure below that. +# +# FLAGS: +# +# --output-dir +# The directory into which to emit code. +# +# --output-pkg +# The Go package path (import path) of the --output-dir. +# +# --extra-pkgs +# An optional list of additional packages to be imported during openapi +# generation. The argument must be Go package syntax, e.g. +# "k8s.io/foo/bar". It may be a single value or a comma-delimited list. +# This flag may be repeated. +# +# --report-filename +# An optional path at which to write an API violations report. "-" means +# stdout. +# +# --update-report +# If specified, update the report file in place, rather than diffing it. +# +# --boilerplate +# An optional override for the header file to insert into generated files. +# +function kube::codegen::gen_openapi() { + local in_dir="" + local out_dir="" + local out_pkg="" + local extra_pkgs=() + local report="/dev/null" + local update_report="" + local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt" + local v="${KUBE_VERBOSE:-0}" + + while [ "$#" -gt 0 ]; do + case "$1" in + "--output-dir") + out_dir="$2" + shift 2 + ;; + "--output-pkg") + out_pkg="$2" + shift 2 + ;; + "--extra-pkgs") + extra_pkgs+=("$2") + shift 2 + ;; + "--report-filename") + report="$2" + shift 2 + ;; + "--update-report") + update_report="true" + shift + ;; + "--boilerplate") + boilerplate="$2" + shift 2 + ;; + *) + if [[ "$1" =~ ^-- ]]; then + echo "unknown argument: $1" >&2 + return 1 + fi + if [ -n "$in_dir" ]; then + echo "too many arguments: $1 (already have $in_dir)" >&2 + return 1 + fi + in_dir="$1" + shift + ;; + esac + done + + if [ -z "${in_dir}" ]; then + echo "input-dir argument is required" >&2 + return 1 + fi + if [ -z "${out_dir}" ]; then + echo "--output-dir is required" >&2 + return 1 + fi + if [ -z "${out_pkg}" ]; then + echo "--output-pkg is required" >&2 + return 1 + fi + + local new_report + new_report="$(mktemp -t "$(basename "$0").api_violations.XXXXXX")" + if [ -n "${update_report}" ]; then + new_report="${report}" + fi + + ( + # To support running this from anywhere, first cd into this directory, + # and then install with forced module mode on and fully qualified name. + cd "${KUBE_CODEGEN_ROOT}" + BINS=( + openapi-gen + ) + # shellcheck disable=2046 # printf word-splitting is intentional + GO111MODULE=on go install $(printf "k8s.io/kube-openapi/cmd/%s " "${BINS[@]}") + ) + # Go installs in $GOBIN if defined, and $GOPATH/bin otherwise + gobin="${GOBIN:-$(go env GOPATH)/bin}" + + local input_pkgs=( "${extra_pkgs[@]:+"${extra_pkgs[@]}"}") + while read -r dir; do + pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" + input_pkgs+=("${pkg}") + done < <( + ( kube::codegen::internal::grep -l --null \ + -e '^\s*//\s*+k8s:openapi-gen=' \ + -r "${in_dir}" \ + --include '*.go' \ + || true \ + ) | while read -r -d $'\0' F; do dirname "${F}"; done \ + | LC_ALL=C sort -u + ) + + if [ "${#input_pkgs[@]}" != 0 ]; then + echo "Generating openapi code for ${#input_pkgs[@]} targets" + + kube::codegen::internal::findz \ + "${in_dir}" \ + -type f \ + -name zz_generated.openapi.go \ + | xargs -0 rm -f + + "${gobin}/openapi-gen" \ + -v "${v}" \ + --output-file zz_generated.openapi.go \ + --go-header-file "${boilerplate}" \ + --output-dir "${out_dir}" \ + --output-pkg "${out_pkg}" \ + --report-filename "${new_report}" \ + "k8s.io/apimachinery/pkg/apis/meta/v1" \ + "k8s.io/apimachinery/pkg/runtime" \ + "k8s.io/apimachinery/pkg/version" \ + "${input_pkgs[@]}" + fi + + touch "${report}" # in case it doesn't exist yet + if ! diff -u "${report}" "${new_report}"; then + echo -e "ERROR:" + echo -e "\tAPI rule check failed for ${report}: new reported violations" + echo -e "\tPlease read api/api-rules/README.md" + return 1 + fi +} + +# Generate client code +# +# USAGE: kube::codegen::gen_client [FLAGS] +# +# +# The root package under which to search for Go files which request clients +# to be generated. This must be a local path, not a Go package. +# +# See note at the top about package structure below that. +# +# FLAGS: +# --one-input-api +# A specific API (a directory) under the input-dir for which to generate a +# client. If this is not set, clients for all APIs under the input-dir +# will be generated (under the --output-pkg). +# +# --output-dir +# The root directory under which to emit code. Each aspect of client +# generation will make one or more subdirectories. +# +# --output-pkg +# The Go package path (import path) of the --output-dir. Each aspect of +# client generation will make one or more sub-packages. +# +# --boilerplate +# An optional override for the header file to insert into generated files. +# +# --clientset-name +# An optional override for the leaf name of the generated "clientset" directory. +# +# --versioned-name +# An optional override for the leaf name of the generated +# "/versioned" directory. +# +# --with-applyconfig +# Enables generation of applyconfiguration files. +# +# --applyconfig-name +# An optional override for the leaf name of the generated "applyconfiguration" directory. +# +# --applyconfig-externals +# An optional list of comma separated external apply configurations locations +# in .: form. +# +# --with-watch +# Enables generation of listers and informers for APIs which support WATCH. +# +# --listers-name +# An optional override for the leaf name of the generated "listers" directory. +# +# --informers-name +# An optional override for the leaf name of the generated "informers" directory. +# +# --plural-exceptions +# An optional list of comma separated plural exception definitions in Type:PluralizedType form. +# +function kube::codegen::gen_client() { + local in_dir="" + local one_input_api="" + local out_dir="" + local out_pkg="" + local clientset_subdir="clientset" + local clientset_versioned_name="versioned" + local applyconfig="false" + local applyconfig_subdir="applyconfiguration" + local applyconfig_external="" + local applyconfig_openapi_schema="" + local watchable="false" + local listers_subdir="listers" + local informers_subdir="informers" + local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt" + local plural_exceptions="" + local v="${KUBE_VERBOSE:-0}" + + while [ "$#" -gt 0 ]; do + case "$1" in + "--one-input-api") + one_input_api="/$2" + shift 2 + ;; + "--output-dir") + out_dir="$2" + shift 2 + ;; + "--output-pkg") + out_pkg="$2" + shift 2 + ;; + "--boilerplate") + boilerplate="$2" + shift 2 + ;; + "--clientset-name") + clientset_subdir="$2" + shift 2 + ;; + "--versioned-name") + clientset_versioned_name="$2" + shift 2 + ;; + "--with-applyconfig") + applyconfig="true" + shift + ;; + "--applyconfig-name") + applyconfig_subdir="$2" + shift 2 + ;; + "--applyconfig-externals") + applyconfig_external="$2" + shift 2 + ;; + "--applyconfig-openapi-schema") + applyconfig_openapi_schema="$2" + shift 2 + ;; + "--with-watch") + watchable="true" + shift + ;; + "--listers-name") + listers_subdir="$2" + shift 2 + ;; + "--informers-name") + informers_subdir="$2" + shift 2 + ;; + "--plural-exceptions") + plural_exceptions="$2" + shift 2 + ;; + *) + if [[ "$1" =~ ^-- ]]; then + echo "unknown argument: $1" >&2 + return 1 + fi + if [ -n "$in_dir" ]; then + echo "too many arguments: $1 (already have $in_dir)" >&2 + return 1 + fi + in_dir="$1" + shift + ;; + esac + done + + if [ -z "${in_dir}" ]; then + echo "input-dir argument is required" >&2 + return 1 + fi + if [ -z "${out_dir}" ]; then + echo "--output-dir is required" >&2 + return 1 + fi + if [ -z "${out_pkg}" ]; then + echo "--output-pkg is required" >&2 + fi + + mkdir -p "${out_dir}" + + ( + # To support running this from anywhere, first cd into this directory, + # and then install with forced module mode on and fully qualified name. + cd "${KUBE_CODEGEN_ROOT}" + BINS=( + applyconfiguration-gen + client-gen + informer-gen + lister-gen + ) + # shellcheck disable=2046 # printf word-splitting is intentional + GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}") + ) + # Go installs in $GOBIN if defined, and $GOPATH/bin otherwise + gobin="${GOBIN:-$(go env GOPATH)/bin}" + + local group_versions=() + local input_pkgs=() + while read -r dir; do + pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" + leaf="$(basename "${dir}")" + if grep -E -q '^v[0-9]+((alpha|beta)[0-9]+)?$' <<< "${leaf}"; then + input_pkgs+=("${pkg}") + + dir2="$(dirname "${dir}")" + leaf2="$(basename "${dir2}")" + group_versions+=("${leaf2}/${leaf}") + fi + done < <( + ( kube::codegen::internal::grep -l --null \ + -e '^\s*//\s*+genclient' \ + -r "${in_dir}${one_input_api}" \ + --include '*.go' \ + || true \ + ) | while read -r -d $'\0' F; do dirname "${F}"; done \ + | LC_ALL=C sort -u + ) + + if [ "${#group_versions[@]}" == 0 ]; then + return 0 + fi + + applyconfig_pkg="" # set this for later use, iff enabled + if [ "${applyconfig}" == "true" ]; then + applyconfig_pkg="${out_pkg}/${applyconfig_subdir}" + + echo "Generating applyconfig code for ${#input_pkgs[@]} targets" + + ( kube::codegen::internal::grep -l --null \ + -e '^// Code generated by applyconfiguration-gen. DO NOT EDIT.$' \ + -r "${out_dir}/${applyconfig_subdir}" \ + --include '*.go' \ + || true \ + ) | xargs -0 rm -f + + "${gobin}/applyconfiguration-gen" \ + -v "${v}" \ + --go-header-file "${boilerplate}" \ + --output-dir "${out_dir}/${applyconfig_subdir}" \ + --output-pkg "${applyconfig_pkg}" \ + --external-applyconfigurations "${applyconfig_external}" \ + --openapi-schema "${applyconfig_openapi_schema}" \ + "${input_pkgs[@]}" + fi + + echo "Generating client code for ${#group_versions[@]} targets" + + ( kube::codegen::internal::grep -l --null \ + -e '^// Code generated by client-gen. DO NOT EDIT.$' \ + -r "${out_dir}/${clientset_subdir}" \ + --include '*.go' \ + || true \ + ) | xargs -0 rm -f + + local inputs=() + for arg in "${group_versions[@]}"; do + inputs+=("--input" "$arg") + done + "${gobin}/client-gen" \ + -v "${v}" \ + --go-header-file "${boilerplate}" \ + --output-dir "${out_dir}/${clientset_subdir}" \ + --output-pkg "${out_pkg}/${clientset_subdir}" \ + --clientset-name "${clientset_versioned_name}" \ + --apply-configuration-package "${applyconfig_pkg}" \ + --input-base "$(cd "${in_dir}" && pwd -P)" `# must be absolute path or Go import path"` \ + --plural-exceptions "${plural_exceptions}" \ + "${inputs[@]}" + + if [ "${watchable}" == "true" ]; then + echo "Generating lister code for ${#input_pkgs[@]} targets" + + ( kube::codegen::internal::grep -l --null \ + -e '^// Code generated by lister-gen. DO NOT EDIT.$' \ + -r "${out_dir}/${listers_subdir}" \ + --include '*.go' \ + || true \ + ) | xargs -0 rm -f + + "${gobin}/lister-gen" \ + -v "${v}" \ + --go-header-file "${boilerplate}" \ + --output-dir "${out_dir}/${listers_subdir}" \ + --output-pkg "${out_pkg}/${listers_subdir}" \ + --plural-exceptions "${plural_exceptions}" \ + "${input_pkgs[@]}" + + echo "Generating informer code for ${#input_pkgs[@]} targets" + + ( kube::codegen::internal::grep -l --null \ + -e '^// Code generated by informer-gen. DO NOT EDIT.$' \ + -r "${out_dir}/${informers_subdir}" \ + --include '*.go' \ + || true \ + ) | xargs -0 rm -f + + "${gobin}/informer-gen" \ + -v "${v}" \ + --go-header-file "${boilerplate}" \ + --output-dir "${out_dir}/${informers_subdir}" \ + --output-pkg "${out_pkg}/${informers_subdir}" \ + --versioned-clientset-package "${out_pkg}/${clientset_subdir}/${clientset_versioned_name}" \ + --listers-package "${out_pkg}/${listers_subdir}" \ + --plural-exceptions "${plural_exceptions}" \ + "${input_pkgs[@]}" + fi +} + +# Generate register code +# +# USAGE: kube::codegen::gen_register [FLAGS] +# +# +# The root directory under which to search for Go files which request code to +# be generated. This must be a local path, not a Go package. +# +# See note at the top about package structure below that. +# +# FLAGS: +# +# --boilerplate +# An optional override for the header file to insert into generated files. +# +function kube::codegen::gen_register() { + local in_dir="" + local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt" + local v="${KUBE_VERBOSE:-0}" + + while [ "$#" -gt 0 ]; do + case "$1" in + "--boilerplate") + boilerplate="$2" + shift 2 + ;; + *) + if [[ "$1" =~ ^-- ]]; then + echo "unknown argument: $1" >&2 + return 1 + fi + if [ -n "$in_dir" ]; then + echo "too many arguments: $1 (already have $in_dir)" >&2 + return 1 + fi + in_dir="$1" + shift + ;; + esac + done + + if [ -z "${in_dir}" ]; then + echo "input-dir argument is required" >&2 + return 1 + fi + + ( + # To support running this from anywhere, first cd into this directory, + # and then install with forced module mode on and fully qualified name. + cd "${KUBE_CODEGEN_ROOT}" + BINS=( + register-gen + ) + # shellcheck disable=2046 # printf word-splitting is intentional + GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}") + ) + # Go installs in $GOBIN if defined, and $GOPATH/bin otherwise + gobin="${GOBIN:-$(go env GOPATH)/bin}" + + # Register + # + local input_pkgs=() + while read -r dir; do + pkg="$(cd "${dir}" && GO111MODULE=on go list -find .)" + input_pkgs+=("${pkg}") + done < <( + ( kube::codegen::internal::grep -l --null \ + -e '^\s*//\s*+groupName' \ + -r "${in_dir}" \ + --include '*.go' \ + || true \ + ) | while read -r -d $'\0' F; do dirname "${F}"; done \ + | LC_ALL=C sort -u + ) + + if [ "${#input_pkgs[@]}" != 0 ]; then + echo "Generating register code for ${#input_pkgs[@]} targets" + + kube::codegen::internal::findz \ + "${in_dir}" \ + -type f \ + -name zz_generated.register.go \ + | xargs -0 rm -f + + "${gobin}/register-gen" \ + -v "${v}" \ + --output-file zz_generated.register.go \ + --go-header-file "${boilerplate}" \ + "${input_pkgs[@]}" + fi +} \ No newline at end of file diff --git a/scripts/update-codegen.sh b/scripts/update-codegen.sh new file mode 100755 index 0000000000..fda3cba32a --- /dev/null +++ b/scripts/update-codegen.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes Authors. +# +# Licensed 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. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}") +PROJECT_ROOT="$SCRIPT_ROOT/.." + +source "${SCRIPT_ROOT}/kube_codegen.sh" + +PKG_NAME="github.com/apache/apisix-ingress-controller" + +kube::codegen::gen_register \ + --boilerplate "${PROJECT_ROOT}/hack/boilerplate.go.txt" \ + "${PROJECT_ROOT}" 2>&1 | grep -v "Making unsupported type entry" + +kube::codegen::gen_client \ + --with-watch \ + --output-dir "${PROJECT_ROOT}/pkg/client" \ + --output-pkg "${PKG_NAME}/pkg/client" \ + --boilerplate "${PROJECT_ROOT}/hack/boilerplate.go.txt" \ + "${PROJECT_ROOT}" 2>&1 | grep -v "Making unsupported type entry" diff --git a/scripts/verify-codegen.sh b/scripts/verify-codegen.sh new file mode 100755 index 0000000000..4f48eab003 --- /dev/null +++ b/scripts/verify-codegen.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes Authors. +# +# Licensed 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. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +DIFFROOT="${SCRIPT_ROOT}/pkg" +TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg" + +cleanup() { + rm -rf "${TMP_DIFFROOT}" +} +trap "cleanup" EXIT SIGINT + +cleanup + +mkdir -p "${TMP_DIFFROOT}" +cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" + +"${SCRIPT_ROOT}/hack/update-codegen.sh" +echo "diffing ${DIFFROOT} against freshly generated codegen" +ret=0 +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +if [[ $ret -eq 0 ]]; then + echo "${DIFFROOT} up to date." +else + echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" + exit 1 +fi