diff --git a/pkg/kube/apisix/apis/config/v2beta2/types.go b/pkg/kube/apisix/apis/config/v2beta2/types.go index 2d0a795a45..7e276c51f7 100644 --- a/pkg/kube/apisix/apis/config/v2beta2/types.go +++ b/pkg/kube/apisix/apis/config/v2beta2/types.go @@ -195,3 +195,37 @@ type ApisixRouteList struct { metav1.ListMeta `json:"metadata" yaml:"metadata"` Items []ApisixRoute `json:"items,omitempty" yaml:"items,omitempty"` } + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:subresource:status + +// ApisixPluginConfig is the Schema for the ApisixPluginConfig resource. +// An ApisixPluginConfig is used to support a group of plugin configs +type ApisixPluginConfig struct { + metav1.TypeMeta `json:",inline" yaml:",inline"` + metav1.ObjectMeta `json:"metadata" yaml:"metadata"` + + // Spec defines the desired state of ApisixPluginConfigSpec. + Spec ApisixPluginConfigSpec `json:"spec" yaml:"spec"` + Status ApisixStatus `json:"status,omitempty" yaml:"status,omitempty"` +} + +// ApisixPluginConfigSpec defines the desired state of ApisixPluginConfigSpec. +type ApisixPluginConfigSpec struct { + // Plugins contains a list of ApisixRouteHTTPPluginConfig + // +required + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinItems=1 + Plugins []ApisixRouteHTTPPluginConfig `json:"plugins" yaml:"plugins"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:generate=true + +// ApisixPluginConfigList contains a list of ApisixPluginConfig. +type ApisixPluginConfigList struct { + metav1.TypeMeta `json:",inline" yaml:",inline"` + metav1.ListMeta `json:"metadata" yaml:"metadata"` + Items []ApisixPluginConfig `json:"items,omitempty" yaml:"items,omitempty"` +} diff --git a/pkg/kube/apisix/apis/config/v2beta2/zz_generated.deepcopy.go b/pkg/kube/apisix/apis/config/v2beta2/zz_generated.deepcopy.go index 0c1782fc95..7172824470 100644 --- a/pkg/kube/apisix/apis/config/v2beta2/zz_generated.deepcopy.go +++ b/pkg/kube/apisix/apis/config/v2beta2/zz_generated.deepcopy.go @@ -25,6 +25,90 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApisixPluginConfig) DeepCopyInto(out *ApisixPluginConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixPluginConfig. +func (in *ApisixPluginConfig) DeepCopy() *ApisixPluginConfig { + if in == nil { + return nil + } + out := new(ApisixPluginConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApisixPluginConfig) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApisixPluginConfigList) DeepCopyInto(out *ApisixPluginConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ApisixPluginConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixPluginConfigList. +func (in *ApisixPluginConfigList) DeepCopy() *ApisixPluginConfigList { + if in == nil { + return nil + } + out := new(ApisixPluginConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ApisixPluginConfigList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApisixPluginConfigSpec) DeepCopyInto(out *ApisixPluginConfigSpec) { + *out = *in + if in.Plugins != nil { + in, out := &in.Plugins, &out.Plugins + *out = make([]ApisixRouteHTTPPluginConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApisixPluginConfigSpec. +func (in *ApisixPluginConfigSpec) DeepCopy() *ApisixPluginConfigSpec { + if in == nil { + return nil + } + out := new(ApisixPluginConfigSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ApisixRoute) DeepCopyInto(out *ApisixRoute) { *out = *in diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/apisixpluginconfig.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/apisixpluginconfig.go new file mode 100644 index 0000000000..c5f29e9e3e --- /dev/null +++ b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/apisixpluginconfig.go @@ -0,0 +1,194 @@ +// 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 v2beta2 + +import ( + "context" + "time" + + v2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" + scheme "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// 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 *v2beta2.ApisixPluginConfig, opts v1.CreateOptions) (*v2beta2.ApisixPluginConfig, error) + Update(ctx context.Context, apisixPluginConfig *v2beta2.ApisixPluginConfig, opts v1.UpdateOptions) (*v2beta2.ApisixPluginConfig, error) + UpdateStatus(ctx context.Context, apisixPluginConfig *v2beta2.ApisixPluginConfig, opts v1.UpdateOptions) (*v2beta2.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) (*v2beta2.ApisixPluginConfig, error) + List(ctx context.Context, opts v1.ListOptions) (*v2beta2.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 *v2beta2.ApisixPluginConfig, err error) + ApisixPluginConfigExpansion +} + +// apisixPluginConfigs implements ApisixPluginConfigInterface +type apisixPluginConfigs struct { + client rest.Interface + ns string +} + +// newApisixPluginConfigs returns a ApisixPluginConfigs +func newApisixPluginConfigs(c *ApisixV2beta2Client, namespace string) *apisixPluginConfigs { + return &apisixPluginConfigs{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the apisixPluginConfig, and returns the corresponding apisixPluginConfig object, and an error if there is any. +func (c *apisixPluginConfigs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2beta2.ApisixPluginConfig, err error) { + result = &v2beta2.ApisixPluginConfig{} + err = c.client.Get(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ApisixPluginConfigs that match those selectors. +func (c *apisixPluginConfigs) List(ctx context.Context, opts v1.ListOptions) (result *v2beta2.ApisixPluginConfigList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v2beta2.ApisixPluginConfigList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested apisixPluginConfigs. +func (c *apisixPluginConfigs) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// 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 *apisixPluginConfigs) Create(ctx context.Context, apisixPluginConfig *v2beta2.ApisixPluginConfig, opts v1.CreateOptions) (result *v2beta2.ApisixPluginConfig, err error) { + result = &v2beta2.ApisixPluginConfig{} + err = c.client.Post(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(apisixPluginConfig). + Do(ctx). + Into(result) + return +} + +// 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 *apisixPluginConfigs) Update(ctx context.Context, apisixPluginConfig *v2beta2.ApisixPluginConfig, opts v1.UpdateOptions) (result *v2beta2.ApisixPluginConfig, err error) { + result = &v2beta2.ApisixPluginConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + Name(apisixPluginConfig.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(apisixPluginConfig). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *apisixPluginConfigs) UpdateStatus(ctx context.Context, apisixPluginConfig *v2beta2.ApisixPluginConfig, opts v1.UpdateOptions) (result *v2beta2.ApisixPluginConfig, err error) { + result = &v2beta2.ApisixPluginConfig{} + err = c.client.Put(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + Name(apisixPluginConfig.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(apisixPluginConfig). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the apisixPluginConfig and deletes it. Returns an error if one occurs. +func (c *apisixPluginConfigs) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *apisixPluginConfigs) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched apisixPluginConfig. +func (c *apisixPluginConfigs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2beta2.ApisixPluginConfig, err error) { + result = &v2beta2.ApisixPluginConfig{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("apisixpluginconfigs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/config_client.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/config_client.go index ae30d48e83..64da6882f0 100644 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/config_client.go +++ b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/config_client.go @@ -25,6 +25,7 @@ import ( type ApisixV2beta2Interface interface { RESTClient() rest.Interface + ApisixPluginConfigsGetter ApisixRoutesGetter } @@ -33,6 +34,10 @@ type ApisixV2beta2Client struct { restClient rest.Interface } +func (c *ApisixV2beta2Client) ApisixPluginConfigs(namespace string) ApisixPluginConfigInterface { + return newApisixPluginConfigs(c, namespace) +} + func (c *ApisixV2beta2Client) ApisixRoutes(namespace string) ApisixRouteInterface { return newApisixRoutes(c, namespace) } diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_apisixpluginconfig.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_apisixpluginconfig.go new file mode 100644 index 0000000000..d9572c3536 --- /dev/null +++ b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_apisixpluginconfig.go @@ -0,0 +1,141 @@ +// 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" + + v2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeApisixPluginConfigs implements ApisixPluginConfigInterface +type FakeApisixPluginConfigs struct { + Fake *FakeApisixV2beta2 + ns string +} + +var apisixpluginconfigsResource = schema.GroupVersionResource{Group: "apisix.apache.org", Version: "v2beta2", Resource: "apisixpluginconfigs"} + +var apisixpluginconfigsKind = schema.GroupVersionKind{Group: "apisix.apache.org", Version: "v2beta2", Kind: "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 *v2beta2.ApisixPluginConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(apisixpluginconfigsResource, c.ns, name), &v2beta2.ApisixPluginConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v2beta2.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 *v2beta2.ApisixPluginConfigList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(apisixpluginconfigsResource, apisixpluginconfigsKind, c.ns, opts), &v2beta2.ApisixPluginConfigList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v2beta2.ApisixPluginConfigList{ListMeta: obj.(*v2beta2.ApisixPluginConfigList).ListMeta} + for _, item := range obj.(*v2beta2.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.NewWatchAction(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 *v2beta2.ApisixPluginConfig, opts v1.CreateOptions) (result *v2beta2.ApisixPluginConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(apisixpluginconfigsResource, c.ns, apisixPluginConfig), &v2beta2.ApisixPluginConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v2beta2.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 *v2beta2.ApisixPluginConfig, opts v1.UpdateOptions) (result *v2beta2.ApisixPluginConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(apisixpluginconfigsResource, c.ns, apisixPluginConfig), &v2beta2.ApisixPluginConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v2beta2.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 *v2beta2.ApisixPluginConfig, opts v1.UpdateOptions) (*v2beta2.ApisixPluginConfig, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(apisixpluginconfigsResource, "status", c.ns, apisixPluginConfig), &v2beta2.ApisixPluginConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v2beta2.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.NewDeleteAction(apisixpluginconfigsResource, c.ns, name), &v2beta2.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.NewDeleteCollectionAction(apisixpluginconfigsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v2beta2.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 *v2beta2.ApisixPluginConfig, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(apisixpluginconfigsResource, c.ns, name, pt, data, subresources...), &v2beta2.ApisixPluginConfig{}) + + if obj == nil { + return nil, err + } + return obj.(*v2beta2.ApisixPluginConfig), err +} diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_config_client.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_config_client.go index 1898d4ac98..2ae389981a 100644 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_config_client.go +++ b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/fake/fake_config_client.go @@ -27,6 +27,10 @@ type FakeApisixV2beta2 struct { *testing.Fake } +func (c *FakeApisixV2beta2) ApisixPluginConfigs(namespace string) v2beta2.ApisixPluginConfigInterface { + return &FakeApisixPluginConfigs{c, namespace} +} + func (c *FakeApisixV2beta2) ApisixRoutes(namespace string) v2beta2.ApisixRouteInterface { return &FakeApisixRoutes{c, namespace} } diff --git a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/generated_expansion.go b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/generated_expansion.go index c837df3cb3..f2aaabc868 100644 --- a/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/generated_expansion.go +++ b/pkg/kube/apisix/client/clientset/versioned/typed/config/v2beta2/generated_expansion.go @@ -17,4 +17,6 @@ package v2beta2 +type ApisixPluginConfigExpansion interface{} + type ApisixRouteExpansion interface{} diff --git a/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/apisixpluginconfig.go b/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/apisixpluginconfig.go new file mode 100644 index 0000000000..4eaa183e25 --- /dev/null +++ b/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/apisixpluginconfig.go @@ -0,0 +1,89 @@ +// 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 v2beta2 + +import ( + "context" + time "time" + + configv2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" + versioned "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/clientset/versioned" + internalinterfaces "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/informers/externalversions/internalinterfaces" + v2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/client/listers/config/v2beta2" + 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() v2beta2.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.ApisixV2beta2().ApisixPluginConfigs(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ApisixV2beta2().ApisixPluginConfigs(namespace).Watch(context.TODO(), options) + }, + }, + &configv2beta2.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(&configv2beta2.ApisixPluginConfig{}, f.defaultInformer) +} + +func (f *apisixPluginConfigInformer) Lister() v2beta2.ApisixPluginConfigLister { + return v2beta2.NewApisixPluginConfigLister(f.Informer().GetIndexer()) +} diff --git a/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/interface.go b/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/interface.go index 778022f5ce..aed683c76d 100644 --- a/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/interface.go +++ b/pkg/kube/apisix/client/informers/externalversions/config/v2beta2/interface.go @@ -23,6 +23,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ApisixPluginConfigs returns a ApisixPluginConfigInformer. + ApisixPluginConfigs() ApisixPluginConfigInformer // ApisixRoutes returns a ApisixRouteInformer. ApisixRoutes() ApisixRouteInformer } @@ -38,6 +40,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: 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} diff --git a/pkg/kube/apisix/client/informers/externalversions/generic.go b/pkg/kube/apisix/client/informers/externalversions/generic.go index 6491abb50e..f4034eeef3 100644 --- a/pkg/kube/apisix/client/informers/externalversions/generic.go +++ b/pkg/kube/apisix/client/informers/externalversions/generic.go @@ -75,6 +75,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2beta1().ApisixRoutes().Informer()}, nil // Group=apisix.apache.org, Version=v2beta2 + case v2beta2.SchemeGroupVersion.WithResource("apisixpluginconfigs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2beta2().ApisixPluginConfigs().Informer()}, nil case v2beta2.SchemeGroupVersion.WithResource("apisixroutes"): return &genericInformer{resource: resource.GroupResource(), informer: f.Apisix().V2beta2().ApisixRoutes().Informer()}, nil diff --git a/pkg/kube/apisix/client/listers/config/v2beta2/apisixpluginconfig.go b/pkg/kube/apisix/client/listers/config/v2beta2/apisixpluginconfig.go new file mode 100644 index 0000000000..e23217a6f7 --- /dev/null +++ b/pkg/kube/apisix/client/listers/config/v2beta2/apisixpluginconfig.go @@ -0,0 +1,98 @@ +// 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 v2beta2 + +import ( + v2beta2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2beta2" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "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 []*v2beta2.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 { + indexer cache.Indexer +} + +// NewApisixPluginConfigLister returns a new ApisixPluginConfigLister. +func NewApisixPluginConfigLister(indexer cache.Indexer) ApisixPluginConfigLister { + return &apisixPluginConfigLister{indexer: indexer} +} + +// List lists all ApisixPluginConfigs in the indexer. +func (s *apisixPluginConfigLister) List(selector labels.Selector) (ret []*v2beta2.ApisixPluginConfig, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v2beta2.ApisixPluginConfig)) + }) + return ret, err +} + +// ApisixPluginConfigs returns an object that can list and get ApisixPluginConfigs. +func (s *apisixPluginConfigLister) ApisixPluginConfigs(namespace string) ApisixPluginConfigNamespaceLister { + return apisixPluginConfigNamespaceLister{indexer: s.indexer, namespace: 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 []*v2beta2.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) (*v2beta2.ApisixPluginConfig, error) + ApisixPluginConfigNamespaceListerExpansion +} + +// apisixPluginConfigNamespaceLister implements the ApisixPluginConfigNamespaceLister +// interface. +type apisixPluginConfigNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ApisixPluginConfigs in the indexer for a given namespace. +func (s apisixPluginConfigNamespaceLister) List(selector labels.Selector) (ret []*v2beta2.ApisixPluginConfig, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v2beta2.ApisixPluginConfig)) + }) + return ret, err +} + +// Get retrieves the ApisixPluginConfig from the indexer for a given namespace and name. +func (s apisixPluginConfigNamespaceLister) Get(name string) (*v2beta2.ApisixPluginConfig, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v2beta2.Resource("apisixpluginconfig"), name) + } + return obj.(*v2beta2.ApisixPluginConfig), nil +} diff --git a/pkg/kube/apisix/client/listers/config/v2beta2/expansion_generated.go b/pkg/kube/apisix/client/listers/config/v2beta2/expansion_generated.go index 6922ad2f97..5643751064 100644 --- a/pkg/kube/apisix/client/listers/config/v2beta2/expansion_generated.go +++ b/pkg/kube/apisix/client/listers/config/v2beta2/expansion_generated.go @@ -17,6 +17,14 @@ package v2beta2 +// 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{} diff --git a/samples/deploy/crd/v1/ApisixPluginConfig.yaml b/samples/deploy/crd/v1/ApisixPluginConfig.yaml new file mode 100644 index 0000000000..d2597aa159 --- /dev/null +++ b/samples/deploy/crd/v1/ApisixPluginConfig.yaml @@ -0,0 +1,83 @@ +# +# 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. +# + +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: apisixpluginconfigs.apisix.apache.org +spec: + group: apisix.apache.org + scope: Namespaced + names: + plural: apisixpluginconfigs + singular: apisixpluginconfig + kind: ApisixPluginConfig + shortNames: + - apc + versions: + - name: v2beta2 + served: true + storage: true + subresources: + status: {} + additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + priority: 0 + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + required: + - plugins + properties: + plugins: + type: array + items: + type: object + properties: + name: + type: string + minLength: 1 + enable: + type: boolean + config: + type: object + required: + - name + - enable + status: + type: object + properties: + conditions: + type: array + items: + type: object + properties: + "type": + type: string + reason: + type: string + status: + type: string + message: + type: string + observedGeneration: + type: integer diff --git a/samples/deploy/crd/v1/kustomization.yaml b/samples/deploy/crd/v1/kustomization.yaml index 356b080a05..3ef0cda252 100644 --- a/samples/deploy/crd/v1/kustomization.yaml +++ b/samples/deploy/crd/v1/kustomization.yaml @@ -21,3 +21,4 @@ resources: - ./ApisixTls.yaml - ./ApisixClusterConfig.yaml - ./ApisixConsumer.yaml + - ./ApisixPluginConfig.yaml diff --git a/samples/deploy/rbac/apisix_view_clusterrole.yaml b/samples/deploy/rbac/apisix_view_clusterrole.yaml index 7a9ff16232..6394903def 100644 --- a/samples/deploy/rbac/apisix_view_clusterrole.yaml +++ b/samples/deploy/rbac/apisix_view_clusterrole.yaml @@ -149,6 +149,8 @@ rules: - apisixclusterconfigs/status - apisixconsumers - apisixconsumers/status + - apisixpluginconfig + - apisixpluginconfig/status verbs: - '*' - apiGroups: diff --git a/test/e2e/scaffold/ingress.go b/test/e2e/scaffold/ingress.go index 4de7a0cd08..bd6ddbd3d4 100644 --- a/test/e2e/scaffold/ingress.go +++ b/test/e2e/scaffold/ingress.go @@ -168,6 +168,8 @@ rules: - apisixclusterconfigs/status - apisixconsumers - apisixconsumers/status + - apisixpluginconfig + - apisixpluginconfig/status verbs: - '*' - apiGroups: