From 6a8a1e9f339664bab4dd47973537f357ccd6413a Mon Sep 17 00:00:00 2001 From: Alex Kursell Date: Wed, 3 Apr 2019 16:46:44 -0400 Subject: [PATCH 1/2] wip --- cmd/nginx/main.go | 75 +++++++- deploy/mandatory.yaml | 16 ++ internal/ingress/controller/controller.go | 2 + internal/ingress/controller/nginx.go | 1 + .../controller/store/ingress_nginx_plugin.go | 39 ++++ internal/ingress/controller/store/store.go | 62 +++++- pkg/apis/ingressnginxplugin/v1alpha1/doc.go | 5 + .../ingressnginxplugin/v1alpha1/register.go | 52 +++++ pkg/apis/ingressnginxplugin/v1alpha1/types.go | 37 ++++ .../v1alpha1/zz_generated.deepcopy.go | 101 ++++++++++ pkg/client/clientset/versioned/clientset.go | 98 ++++++++++ pkg/client/clientset/versioned/doc.go | 20 ++ .../versioned/fake/clientset_generated.go | 82 ++++++++ pkg/client/clientset/versioned/fake/doc.go | 20 ++ .../clientset/versioned/fake/register.go | 56 ++++++ pkg/client/clientset/versioned/scheme/doc.go | 20 ++ .../clientset/versioned/scheme/register.go | 56 ++++++ .../typed/ingressnginxplugin/v1alpha1/doc.go | 20 ++ .../ingressnginxplugin/v1alpha1/fake/doc.go | 20 ++ .../v1alpha1/fake/fake_ingressnginxplugin.go | 128 +++++++++++++ .../fake/fake_ingressnginxplugin_client.go | 40 ++++ .../v1alpha1/generated_expansion.go | 21 ++ .../v1alpha1/ingressnginxplugin.go | 174 +++++++++++++++++ .../v1alpha1/ingressnginxplugin_client.go | 90 +++++++++ .../informers/externalversions/factory.go | 180 ++++++++++++++++++ .../informers/externalversions/generic.go | 62 ++++++ .../ingressnginxplugin/interface.go | 46 +++++ .../v1alpha1/ingressnginxplugin.go | 89 +++++++++ .../ingressnginxplugin/v1alpha1/interface.go | 45 +++++ .../internalinterfaces/factory_interfaces.go | 40 ++++ .../v1alpha1/expansion_generated.go | 27 +++ .../v1alpha1/ingressnginxplugin.go | 94 +++++++++ 32 files changed, 1811 insertions(+), 7 deletions(-) create mode 100644 internal/ingress/controller/store/ingress_nginx_plugin.go create mode 100644 pkg/apis/ingressnginxplugin/v1alpha1/doc.go create mode 100644 pkg/apis/ingressnginxplugin/v1alpha1/register.go create mode 100644 pkg/apis/ingressnginxplugin/v1alpha1/types.go create mode 100644 pkg/apis/ingressnginxplugin/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/clientset.go create mode 100644 pkg/client/clientset/versioned/doc.go create mode 100644 pkg/client/clientset/versioned/fake/clientset_generated.go create mode 100644 pkg/client/clientset/versioned/fake/doc.go create mode 100644 pkg/client/clientset/versioned/fake/register.go create mode 100644 pkg/client/clientset/versioned/scheme/doc.go create mode 100644 pkg/client/clientset/versioned/scheme/register.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin_client.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin.go create mode 100644 pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin_client.go create mode 100644 pkg/client/informers/externalversions/factory.go create mode 100644 pkg/client/informers/externalversions/generic.go create mode 100644 pkg/client/informers/externalversions/ingressnginxplugin/interface.go create mode 100644 pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/ingressnginxplugin.go create mode 100644 pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/interface.go create mode 100644 pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/client/listers/ingressnginxplugin/v1alpha1/expansion_generated.go create mode 100644 pkg/client/listers/ingressnginxplugin/v1alpha1/ingressnginxplugin.go diff --git a/cmd/nginx/main.go b/cmd/nginx/main.go index 13bb3e761d..1a9aa1c243 100644 --- a/cmd/nginx/main.go +++ b/cmd/nginx/main.go @@ -36,6 +36,7 @@ import ( discovery "k8s.io/apimachinery/pkg/version" "k8s.io/apiserver/pkg/server/healthz" "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "k8s.io/klog" @@ -45,6 +46,8 @@ import ( "k8s.io/ingress-nginx/internal/k8s" "k8s.io/ingress-nginx/internal/net/ssl" "k8s.io/ingress-nginx/version" + + pluginclientset "k8s.io/ingress-nginx/pkg/client/clientset/versioned" ) const ( @@ -86,6 +89,11 @@ func main() { handleFatalInitError(err) } + ingressNginxPluginClient, err := createApiserverPluginClient(conf.APIServerHost, conf.KubeConfigFile) + if err != nil { + handleFatalInitError(err) + } + if len(conf.DefaultService) > 0 { defSvcNs, defSvcName, err := k8s.ParseNameNS(conf.DefaultService) if err != nil { @@ -125,6 +133,7 @@ func main() { // end create default fake SSL certificates conf.Client = kubeClient + conf.PluginClient = ingressNginxPluginClient reg := prometheus.NewRegistry() @@ -193,6 +202,60 @@ func handleSigterm(ngx *controller.NGINXController, exit exiter) { // controller runs inside Kubernetes and fallback to the in-cluster config. If // the in-cluster config is missing or fails, we fallback to the default config. func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Clientset, error) { + cfg, err := createClientConfig(apiserverHost, kubeConfig) + if err != nil { + return nil, err + } + + client, err := kubernetes.NewForConfig(cfg) + if err != nil { + return nil, err + } + + var v *discovery.Info + + // The client may fail to connect to the API server in the first request. + // https://github.com/kubernetes/ingress-nginx/issues/1968 + defaultRetry := wait.Backoff{ + Steps: 10, + Duration: 1 * time.Second, + Factor: 1.5, + Jitter: 0.1, + } + + var lastErr error + retries := 0 + klog.V(2).Info("Trying to discover Kubernetes version") + err = wait.ExponentialBackoff(defaultRetry, func() (bool, error) { + v, err = client.Discovery().ServerVersion() + + if err == nil { + return true, nil + } + + lastErr = err + klog.V(2).Infof("Unexpected error discovering Kubernetes version (attempt %v): %v", retries, err) + retries++ + return false, nil + }) + + // err is returned in case of timeout in the exponential backoff (ErrWaitTimeout) + if err != nil { + return nil, lastErr + } + + // this should not happen, warn the user + if retries > 0 { + klog.Warningf("Initial connection to the Kubernetes API server was retried %d times.", retries) + } + + klog.Infof("Running in Kubernetes cluster version v%v.%v (%v) - git (%v) commit %v - platform %v", + v.Major, v.Minor, v.GitVersion, v.GitTreeState, v.GitCommit, v.Platform) + + return client, nil +} + +func createClientConfig(apiserverHost, kubeConfig string) (*rest.Config, error) { cfg, err := clientcmd.BuildConfigFromFlags(apiserverHost, kubeConfig) if err != nil { return nil, err @@ -204,7 +267,17 @@ func createApiserverClient(apiserverHost, kubeConfig string) (*kubernetes.Client klog.Infof("Creating API client for %s", cfg.Host) - client, err := kubernetes.NewForConfig(cfg) + return cfg, nil + +} + +func createApiserverPluginClient(apiserverHost, kubeConfig string) (*pluginclientset.Clientset, error) { + cfg, err := createClientConfig(apiserverHost, kubeConfig) + if err != nil { + return nil, err + } + + client, err := pluginclientset.NewForConfig(cfg) if err != nil { return nil, err } diff --git a/deploy/mandatory.yaml b/deploy/mandatory.yaml index 90d102cb92..e51cf713fa 100644 --- a/deploy/mandatory.yaml +++ b/deploy/mandatory.yaml @@ -67,6 +67,14 @@ rules: verbs: - list - watch + - apiGroups: + - "nginx.ingress.kubernetes.io" + resources: + - ingressnginxplugins + verbs: + - get + - list + - watch - apiGroups: - "" resources: @@ -147,6 +155,14 @@ rules: - endpoints verbs: - get + - apiGroups: + - "nginx.ingress.kubernetes.io" + resources: + - ingressnginxplugins + verbs: + - get + - list + - watch --- apiVersion: rbac.authorization.k8s.io/v1beta1 diff --git a/internal/ingress/controller/controller.go b/internal/ingress/controller/controller.go index 90f7897703..23feb5e921 100644 --- a/internal/ingress/controller/controller.go +++ b/internal/ingress/controller/controller.go @@ -33,6 +33,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" + pluginclientset "k8s.io/ingress-nginx/pkg/client/clientset/versioned" "k8s.io/ingress-nginx/internal/ingress" "k8s.io/ingress-nginx/internal/ingress/annotations" @@ -52,6 +53,7 @@ type Configuration struct { APIServerHost string KubeConfigFile string Client clientset.Interface + PluginClient pluginclientset.Interface ResyncPeriod time.Duration diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index da0b05467d..b77759a19e 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -127,6 +127,7 @@ func NewNGINXController(config *Configuration, mc metric.Collector, fs file.File config.DefaultSSLCertificate, config.ResyncPeriod, config.Client, + config.PluginClient, fs, n.updateCh, config.DynamicCertificatesEnabled, diff --git a/internal/ingress/controller/store/ingress_nginx_plugin.go b/internal/ingress/controller/store/ingress_nginx_plugin.go new file mode 100644 index 0000000000..5b8adf8bc1 --- /dev/null +++ b/internal/ingress/controller/store/ingress_nginx_plugin.go @@ -0,0 +1,39 @@ +/* +Copyright 2019 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. +*/ + +package store + +import ( + "k8s.io/client-go/tools/cache" + inp "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" +) + +// IngressNginxPluginLister makes a Store that lists IngressNginxPlugins. +type IngressNginxPluginLister struct { + cache.Store +} + +// ByKey returns the Plugin matching key in the local IngressNginxPlugin Store. +func (cml *IngressNginxPluginLister) ByKey(key string) (*inp.IngressNginxPlugin, error) { + s, exists, err := cml.GetByKey(key) + if err != nil { + return nil, err + } + if !exists { + return nil, NotExistsError(key) + } + return s.(*inp.IngressNginxPlugin), nil +} diff --git a/internal/ingress/controller/store/store.go b/internal/ingress/controller/store/store.go index e537b1894e..37e9af358d 100644 --- a/internal/ingress/controller/store/store.go +++ b/internal/ingress/controller/store/store.go @@ -41,6 +41,7 @@ import ( clientcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" + pluginclientset "k8s.io/ingress-nginx/pkg/client/clientset/versioned" "k8s.io/klog" "k8s.io/ingress-nginx/internal/file" @@ -54,6 +55,8 @@ import ( "k8s.io/ingress-nginx/internal/ingress/errors" "k8s.io/ingress-nginx/internal/ingress/resolver" "k8s.io/ingress-nginx/internal/k8s" + inp "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" + inpinformer "k8s.io/ingress-nginx/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1" ) // Storer is the interface that wraps the required methods to gather information @@ -65,6 +68,9 @@ type Storer interface { // GetConfigMap returns the ConfigMap matching key. GetConfigMap(key string) (*corev1.ConfigMap, error) + // GetIngressNginxPlugin returns the IngressNginxPlugin matching key. + GetIngressNginxPlugin(key string) (*inp.IngressNginxPlugin, error) + // GetSecret returns the Secret matching key. GetSecret(key string) (*corev1.Secret, error) @@ -120,17 +126,19 @@ type Event struct { // Informer defines the required SharedIndexInformers that interact with the API server. type Informer struct { - Ingress cache.SharedIndexInformer - Endpoint cache.SharedIndexInformer - Service cache.SharedIndexInformer - Secret cache.SharedIndexInformer - ConfigMap cache.SharedIndexInformer - Pod cache.SharedIndexInformer + Ingress cache.SharedIndexInformer + Endpoint cache.SharedIndexInformer + IngressNginxPlugin cache.SharedIndexInformer + Service cache.SharedIndexInformer + Secret cache.SharedIndexInformer + ConfigMap cache.SharedIndexInformer + Pod cache.SharedIndexInformer } // Lister contains object listers (stores). type Lister struct { Ingress IngressLister + IngressNginxPlugin IngressNginxPluginLister Service ServiceLister Endpoint EndpointLister Secret SecretLister @@ -150,6 +158,9 @@ func (e NotExistsError) Error() string { // Run initiates the synchronization of the informers against the API server. func (i *Informer) Run(stopCh chan struct{}) { go i.Endpoint.Run(stopCh) + klog.Infof("ABOUT TO RUN Plugin INFORMER") + go i.IngressNginxPlugin.Run(stopCh) + klog.Infof("RAN Plugin INFORMER") go i.Service.Run(stopCh) go i.Secret.Run(stopCh) go i.ConfigMap.Run(stopCh) @@ -159,6 +170,7 @@ func (i *Informer) Run(stopCh chan struct{}) { // from the queue if !cache.WaitForCacheSync(stopCh, i.Endpoint.HasSynced, + i.IngressNginxPlugin.HasSynced, i.Service.HasSynced, i.Secret.HasSynced, i.ConfigMap.HasSynced, @@ -230,6 +242,7 @@ func New(checkOCSP bool, namespace, configmap, tcp, udp, defaultSSLCertificate string, resyncPeriod time.Duration, client clientset.Interface, + pluginClient pluginclientset.Interface, fs file.Filesystem, updateCh *channels.RingChannel, isDynamicCertificatesEnabled bool, @@ -286,6 +299,9 @@ func New(checkOCSP bool, store.informers.Service = infFactory.Core().V1().Services().Informer() store.listers.Service.Store = store.informers.Service.GetStore() + store.informers.IngressNginxPlugin = inpinformer.NewIngressNginxPluginInformer(pluginClient, namespace, resyncPeriod, cache.Indexers{}) + store.listers.IngressNginxPlugin.Store = store.informers.IngressNginxPlugin.GetStore() + labelSelector := labels.SelectorFromSet(store.pod.Labels) store.informers.Pod = cache.NewSharedIndexInformer( &cache.ListWatch{ @@ -599,10 +615,39 @@ func New(checkOCSP bool, }, } + pluginEventHandler := cache.ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { + klog.Infof("APluginAddition!!!") + updateCh.In() <- Event{ + Type: CreateEvent, + Obj: obj, + } + }, + DeleteFunc: func(obj interface{}) { + klog.Infof("APluginDELETION!!!") + updateCh.In() <- Event{ + Type: DeleteEvent, + Obj: obj, + } + }, + UpdateFunc: func(old, cur interface{}) { + oep := old.(*inp.IngressNginxPlugin) + cep := cur.(*inp.IngressNginxPlugin) + if !reflect.DeepEqual(oep, cep) { + klog.Infof("APluginCHANGE!!!") + updateCh.In() <- Event{ + Type: UpdateEvent, + Obj: cur, + } + } + }, + } + store.informers.Ingress.AddEventHandler(ingEventHandler) store.informers.Endpoint.AddEventHandler(epEventHandler) store.informers.Secret.AddEventHandler(secrEventHandler) store.informers.ConfigMap.AddEventHandler(cmEventHandler) + store.informers.IngressNginxPlugin.AddEventHandler(pluginEventHandler) store.informers.Service.AddEventHandler(cache.ResourceEventHandlerFuncs{}) store.informers.Pod.AddEventHandler(podEventHandler) @@ -725,6 +770,11 @@ func (s *k8sStore) syncSecrets(ing *extensions.Ingress) { } } +// GetIngressNginxPlugin returns the IngressNginxPlugin matching key. +func (s *k8sStore) GetIngressNginxPlugin(key string) (*inp.IngressNginxPlugin, error) { + return s.listers.IngressNginxPlugin.ByKey(key) +} + // GetSecret returns the Secret matching key. func (s *k8sStore) GetSecret(key string) (*corev1.Secret, error) { return s.listers.Secret.ByKey(key) diff --git a/pkg/apis/ingressnginxplugin/v1alpha1/doc.go b/pkg/apis/ingressnginxplugin/v1alpha1/doc.go new file mode 100644 index 0000000000..a17e1202b8 --- /dev/null +++ b/pkg/apis/ingressnginxplugin/v1alpha1/doc.go @@ -0,0 +1,5 @@ +// +k8s:deepcopy-gen=package +// +k8s:defaulter-gen=TypeMeta +// +groupName=nginx.ingress.kubernetes.io + +package v1alpha1 diff --git a/pkg/apis/ingressnginxplugin/v1alpha1/register.go b/pkg/apis/ingressnginxplugin/v1alpha1/register.go new file mode 100644 index 0000000000..2b28ab4a24 --- /dev/null +++ b/pkg/apis/ingressnginxplugin/v1alpha1/register.go @@ -0,0 +1,52 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// Define your schema name and the version +var SchemeGroupVersion = schema.GroupVersion{ + Group: "nginx.ingress.kubernetes.io", + Version: "v1alpha1", +} + +var ( + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + AddToScheme = 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) +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes( + SchemeGroupVersion, + &IngressNginxPlugin{}, + &IngressNginxPluginList{}, + ) + + scheme.AddKnownTypes( + SchemeGroupVersion, + &metav1.Status{}, + ) + + metav1.AddToGroupVersion( + scheme, + SchemeGroupVersion, + ) + + return nil +} diff --git a/pkg/apis/ingressnginxplugin/v1alpha1/types.go b/pkg/apis/ingressnginxplugin/v1alpha1/types.go new file mode 100644 index 0000000000..90dabe1ed1 --- /dev/null +++ b/pkg/apis/ingressnginxplugin/v1alpha1/types.go @@ -0,0 +1,37 @@ +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IngressNginxPluginis a top-level type +type IngressNginxPlugin struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + // Status HelloTypeStatus `json:"status,omitempty"` + // This is where you can define + // your own custom spec + Spec IngressNginxPluginSpec `json:"spec,omitempty"` +} + +// custom spec +type IngressNginxPluginSpec struct { + Archive string `json:"archive,omitempty"` + Sha256Sum string `json:"sha256sum,omitempty"` + //Vars map[string]interface{} `json:"vars,"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// no client needed for list as it's been created in above +type IngressNginxPluginList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + Items []IngressNginxPlugin `json:"items"` +} diff --git a/pkg/apis/ingressnginxplugin/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ingressnginxplugin/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..7c2a80aa7a --- /dev/null +++ b/pkg/apis/ingressnginxplugin/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,101 @@ +// +build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +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 *IngressNginxPlugin) DeepCopyInto(out *IngressNginxPlugin) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressNginxPlugin. +func (in *IngressNginxPlugin) DeepCopy() *IngressNginxPlugin { + if in == nil { + return nil + } + out := new(IngressNginxPlugin) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IngressNginxPlugin) 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 *IngressNginxPluginList) DeepCopyInto(out *IngressNginxPluginList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IngressNginxPlugin, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressNginxPluginList. +func (in *IngressNginxPluginList) DeepCopy() *IngressNginxPluginList { + if in == nil { + return nil + } + out := new(IngressNginxPluginList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IngressNginxPluginList) 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 *IngressNginxPluginSpec) DeepCopyInto(out *IngressNginxPluginSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressNginxPluginSpec. +func (in *IngressNginxPluginSpec) DeepCopy() *IngressNginxPluginSpec { + if in == nil { + return nil + } + out := new(IngressNginxPluginSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 0000000000..9776dbbd99 --- /dev/null +++ b/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,98 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + nginxv1alpha1 "k8s.io/ingress-nginx/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + NginxV1alpha1() nginxv1alpha1.NginxV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Nginx() nginxv1alpha1.NginxV1alpha1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + nginxV1alpha1 *nginxv1alpha1.NginxV1alpha1Client +} + +// NginxV1alpha1 retrieves the NginxV1alpha1Client +func (c *Clientset) NginxV1alpha1() nginxv1alpha1.NginxV1alpha1Interface { + return c.nginxV1alpha1 +} + +// Deprecated: Nginx retrieves the default version of NginxClient. +// Please explicitly pick a version. +func (c *Clientset) Nginx() nginxv1alpha1.NginxV1alpha1Interface { + return c.nginxV1alpha1 +} + +// 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. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.nginxV1alpha1, err = nginxv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + 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 { + var cs Clientset + cs.nginxV1alpha1 = nginxv1alpha1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.nginxV1alpha1 = nginxv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/clientset/versioned/doc.go b/pkg/client/clientset/versioned/doc.go new file mode 100644 index 0000000000..41721ca52d --- /dev/null +++ b/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package versioned 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..c4536e4d60 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,82 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "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" + clientset "k8s.io/ingress-nginx/pkg/client/clientset/versioned" + nginxv1alpha1 "k8s.io/ingress-nginx/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1" + fakenginxv1alpha1 "k8s.io/ingress-nginx/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake" +) + +// 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 validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +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{} + 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 +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +var _ clientset.Interface = &Clientset{} + +// NginxV1alpha1 retrieves the NginxV1alpha1Client +func (c *Clientset) NginxV1alpha1() nginxv1alpha1.NginxV1alpha1Interface { + return &fakenginxv1alpha1.FakeNginxV1alpha1{Fake: &c.Fake} +} + +// Nginx retrieves the NginxV1alpha1Client +func (c *Clientset) Nginx() nginxv1alpha1.NginxV1alpha1Interface { + return &fakenginxv1alpha1.FakeNginxV1alpha1{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..9b99e71670 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// 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..3448a850b8 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + 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" + nginxv1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + nginxv1alpha1.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..7dc3756168 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// 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..a4bfe9de8a --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + 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" + nginxv1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + nginxv1alpha1.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/ingressnginxplugin/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/doc.go new file mode 100644 index 0000000000..df51baa4d4 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// 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/ingressnginxplugin/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..16f4439906 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 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. +*/ + +// 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/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin.go new file mode 100644 index 0000000000..79c590959f --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin.go @@ -0,0 +1,128 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + 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" + v1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" +) + +// FakeIngressNginxPlugins implements IngressNginxPluginInterface +type FakeIngressNginxPlugins struct { + Fake *FakeNginxV1alpha1 + ns string +} + +var ingressnginxpluginsResource = schema.GroupVersionResource{Group: "nginx.ingress.kubernetes.io", Version: "v1alpha1", Resource: "ingressnginxplugins"} + +var ingressnginxpluginsKind = schema.GroupVersionKind{Group: "nginx.ingress.kubernetes.io", Version: "v1alpha1", Kind: "IngressNginxPlugin"} + +// Get takes name of the ingressNginxPlugin, and returns the corresponding ingressNginxPlugin object, and an error if there is any. +func (c *FakeIngressNginxPlugins) Get(name string, options v1.GetOptions) (result *v1alpha1.IngressNginxPlugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(ingressnginxpluginsResource, c.ns, name), &v1alpha1.IngressNginxPlugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IngressNginxPlugin), err +} + +// List takes label and field selectors, and returns the list of IngressNginxPlugins that match those selectors. +func (c *FakeIngressNginxPlugins) List(opts v1.ListOptions) (result *v1alpha1.IngressNginxPluginList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(ingressnginxpluginsResource, ingressnginxpluginsKind, c.ns, opts), &v1alpha1.IngressNginxPluginList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.IngressNginxPluginList{ListMeta: obj.(*v1alpha1.IngressNginxPluginList).ListMeta} + for _, item := range obj.(*v1alpha1.IngressNginxPluginList).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 ingressNginxPlugins. +func (c *FakeIngressNginxPlugins) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(ingressnginxpluginsResource, c.ns, opts)) + +} + +// Create takes the representation of a ingressNginxPlugin and creates it. Returns the server's representation of the ingressNginxPlugin, and an error, if there is any. +func (c *FakeIngressNginxPlugins) Create(ingressNginxPlugin *v1alpha1.IngressNginxPlugin) (result *v1alpha1.IngressNginxPlugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(ingressnginxpluginsResource, c.ns, ingressNginxPlugin), &v1alpha1.IngressNginxPlugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IngressNginxPlugin), err +} + +// Update takes the representation of a ingressNginxPlugin and updates it. Returns the server's representation of the ingressNginxPlugin, and an error, if there is any. +func (c *FakeIngressNginxPlugins) Update(ingressNginxPlugin *v1alpha1.IngressNginxPlugin) (result *v1alpha1.IngressNginxPlugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(ingressnginxpluginsResource, c.ns, ingressNginxPlugin), &v1alpha1.IngressNginxPlugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IngressNginxPlugin), err +} + +// Delete takes name of the ingressNginxPlugin and deletes it. Returns an error if one occurs. +func (c *FakeIngressNginxPlugins) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(ingressnginxpluginsResource, c.ns, name), &v1alpha1.IngressNginxPlugin{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIngressNginxPlugins) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(ingressnginxpluginsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.IngressNginxPluginList{}) + return err +} + +// Patch applies the patch and returns the patched ingressNginxPlugin. +func (c *FakeIngressNginxPlugins) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.IngressNginxPlugin, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ingressnginxpluginsResource, c.ns, name, pt, data, subresources...), &v1alpha1.IngressNginxPlugin{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IngressNginxPlugin), err +} diff --git a/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin_client.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin_client.go new file mode 100644 index 0000000000..362730cad7 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/fake/fake_ingressnginxplugin_client.go @@ -0,0 +1,40 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "k8s.io/ingress-nginx/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1" +) + +type FakeNginxV1alpha1 struct { + *testing.Fake +} + +func (c *FakeNginxV1alpha1) IngressNginxPlugins(namespace string) v1alpha1.IngressNginxPluginInterface { + return &FakeIngressNginxPlugins{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeNginxV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..28f0cba316 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type IngressNginxPluginExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin.go new file mode 100644 index 0000000000..e9a9a38fb5 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin.go @@ -0,0 +1,174 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + 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" + v1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" + scheme "k8s.io/ingress-nginx/pkg/client/clientset/versioned/scheme" +) + +// IngressNginxPluginsGetter has a method to return a IngressNginxPluginInterface. +// A group's client should implement this interface. +type IngressNginxPluginsGetter interface { + IngressNginxPlugins(namespace string) IngressNginxPluginInterface +} + +// IngressNginxPluginInterface has methods to work with IngressNginxPlugin resources. +type IngressNginxPluginInterface interface { + Create(*v1alpha1.IngressNginxPlugin) (*v1alpha1.IngressNginxPlugin, error) + Update(*v1alpha1.IngressNginxPlugin) (*v1alpha1.IngressNginxPlugin, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.IngressNginxPlugin, error) + List(opts v1.ListOptions) (*v1alpha1.IngressNginxPluginList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.IngressNginxPlugin, err error) + IngressNginxPluginExpansion +} + +// ingressNginxPlugins implements IngressNginxPluginInterface +type ingressNginxPlugins struct { + client rest.Interface + ns string +} + +// newIngressNginxPlugins returns a IngressNginxPlugins +func newIngressNginxPlugins(c *NginxV1alpha1Client, namespace string) *ingressNginxPlugins { + return &ingressNginxPlugins{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the ingressNginxPlugin, and returns the corresponding ingressNginxPlugin object, and an error if there is any. +func (c *ingressNginxPlugins) Get(name string, options v1.GetOptions) (result *v1alpha1.IngressNginxPlugin, err error) { + result = &v1alpha1.IngressNginxPlugin{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingressnginxplugins"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IngressNginxPlugins that match those selectors. +func (c *ingressNginxPlugins) List(opts v1.ListOptions) (result *v1alpha1.IngressNginxPluginList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.IngressNginxPluginList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingressnginxplugins"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ingressNginxPlugins. +func (c *ingressNginxPlugins) Watch(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("ingressnginxplugins"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a ingressNginxPlugin and creates it. Returns the server's representation of the ingressNginxPlugin, and an error, if there is any. +func (c *ingressNginxPlugins) Create(ingressNginxPlugin *v1alpha1.IngressNginxPlugin) (result *v1alpha1.IngressNginxPlugin, err error) { + result = &v1alpha1.IngressNginxPlugin{} + err = c.client.Post(). + Namespace(c.ns). + Resource("ingressnginxplugins"). + Body(ingressNginxPlugin). + Do(). + Into(result) + return +} + +// Update takes the representation of a ingressNginxPlugin and updates it. Returns the server's representation of the ingressNginxPlugin, and an error, if there is any. +func (c *ingressNginxPlugins) Update(ingressNginxPlugin *v1alpha1.IngressNginxPlugin) (result *v1alpha1.IngressNginxPlugin, err error) { + result = &v1alpha1.IngressNginxPlugin{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ingressnginxplugins"). + Name(ingressNginxPlugin.Name). + Body(ingressNginxPlugin). + Do(). + Into(result) + return +} + +// Delete takes name of the ingressNginxPlugin and deletes it. Returns an error if one occurs. +func (c *ingressNginxPlugins) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ingressnginxplugins"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ingressNginxPlugins) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("ingressnginxplugins"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched ingressNginxPlugin. +func (c *ingressNginxPlugins) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.IngressNginxPlugin, err error) { + result = &v1alpha1.IngressNginxPlugin{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("ingressnginxplugins"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin_client.go b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin_client.go new file mode 100644 index 0000000000..f8b9c2475d --- /dev/null +++ b/pkg/client/clientset/versioned/typed/ingressnginxplugin/v1alpha1/ingressnginxplugin_client.go @@ -0,0 +1,90 @@ +/* +Copyright 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" + v1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" + "k8s.io/ingress-nginx/pkg/client/clientset/versioned/scheme" +) + +type NginxV1alpha1Interface interface { + RESTClient() rest.Interface + IngressNginxPluginsGetter +} + +// NginxV1alpha1Client is used to interact with features provided by the nginx.ingress.kubernetes.io group. +type NginxV1alpha1Client struct { + restClient rest.Interface +} + +func (c *NginxV1alpha1Client) IngressNginxPlugins(namespace string) IngressNginxPluginInterface { + return newIngressNginxPlugins(c, namespace) +} + +// NewForConfig creates a new NginxV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*NginxV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &NginxV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new NginxV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NginxV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NginxV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *NginxV1alpha1Client { + return &NginxV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + 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 *NginxV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 0000000000..a5bd975087 --- /dev/null +++ b/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,180 @@ +/* +Copyright 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + 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" + versioned "k8s.io/ingress-nginx/pkg/client/clientset/versioned" + ingressnginxplugin "k8s.io/ingress-nginx/pkg/client/informers/externalversions/ingressnginxplugin" + internalinterfaces "k8s.io/ingress-nginx/pkg/client/informers/externalversions/internalinterfaces" +) + +// 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 + + 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 +} + +// 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 + } +} + +// 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 +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +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 +} + +// InternalInformerFor 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) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Nginx() ingressnginxplugin.Interface +} + +func (f *sharedInformerFactory) Nginx() ingressnginxplugin.Interface { + return ingressnginxplugin.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..e04f17786d --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +Copyright 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + v1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" +) + +// 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=nginx.ingress.kubernetes.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("ingressnginxplugins"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Nginx().V1alpha1().IngressNginxPlugins().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/ingressnginxplugin/interface.go b/pkg/client/informers/externalversions/ingressnginxplugin/interface.go new file mode 100644 index 0000000000..f57b760078 --- /dev/null +++ b/pkg/client/informers/externalversions/ingressnginxplugin/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package nginx + +import ( + v1alpha1 "k8s.io/ingress-nginx/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1" + internalinterfaces "k8s.io/ingress-nginx/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 +} + +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) +} diff --git a/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/ingressnginxplugin.go b/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/ingressnginxplugin.go new file mode 100644 index 0000000000..820b70b248 --- /dev/null +++ b/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/ingressnginxplugin.go @@ -0,0 +1,89 @@ +/* +Copyright 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + 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" + ingressnginxpluginv1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" + versioned "k8s.io/ingress-nginx/pkg/client/clientset/versioned" + internalinterfaces "k8s.io/ingress-nginx/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "k8s.io/ingress-nginx/pkg/client/listers/ingressnginxplugin/v1alpha1" +) + +// IngressNginxPluginInformer provides access to a shared informer and lister for +// IngressNginxPlugins. +type IngressNginxPluginInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.IngressNginxPluginLister +} + +type ingressNginxPluginInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewIngressNginxPluginInformer constructs a new informer for IngressNginxPlugin 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 NewIngressNginxPluginInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIngressNginxPluginInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredIngressNginxPluginInformer constructs a new informer for IngressNginxPlugin 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 NewFilteredIngressNginxPluginInformer(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.NginxV1alpha1().IngressNginxPlugins(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NginxV1alpha1().IngressNginxPlugins(namespace).Watch(options) + }, + }, + &ingressnginxpluginv1alpha1.IngressNginxPlugin{}, + resyncPeriod, + indexers, + ) +} + +func (f *ingressNginxPluginInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIngressNginxPluginInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *ingressNginxPluginInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&ingressnginxpluginv1alpha1.IngressNginxPlugin{}, f.defaultInformer) +} + +func (f *ingressNginxPluginInformer) Lister() v1alpha1.IngressNginxPluginLister { + return v1alpha1.NewIngressNginxPluginLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/interface.go b/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/interface.go new file mode 100644 index 0000000000..23dd9479a5 --- /dev/null +++ b/pkg/client/informers/externalversions/ingressnginxplugin/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "k8s.io/ingress-nginx/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // IngressNginxPlugins returns a IngressNginxPluginInformer. + IngressNginxPlugins() IngressNginxPluginInformer +} + +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} +} + +// IngressNginxPlugins returns a IngressNginxPluginInformer. +func (v *version) IngressNginxPlugins() IngressNginxPluginInformer { + return &ingressNginxPluginInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} 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..a1bebdf3b2 --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 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. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" + versioned "k8s.io/ingress-nginx/pkg/client/clientset/versioned" +) + +// 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/ingressnginxplugin/v1alpha1/expansion_generated.go b/pkg/client/listers/ingressnginxplugin/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..499ffe0b3c --- /dev/null +++ b/pkg/client/listers/ingressnginxplugin/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// IngressNginxPluginListerExpansion allows custom methods to be added to +// IngressNginxPluginLister. +type IngressNginxPluginListerExpansion interface{} + +// IngressNginxPluginNamespaceListerExpansion allows custom methods to be added to +// IngressNginxPluginNamespaceLister. +type IngressNginxPluginNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/ingressnginxplugin/v1alpha1/ingressnginxplugin.go b/pkg/client/listers/ingressnginxplugin/v1alpha1/ingressnginxplugin.go new file mode 100644 index 0000000000..cc120ddf1f --- /dev/null +++ b/pkg/client/listers/ingressnginxplugin/v1alpha1/ingressnginxplugin.go @@ -0,0 +1,94 @@ +/* +Copyright 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. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "k8s.io/ingress-nginx/pkg/apis/ingressnginxplugin/v1alpha1" +) + +// IngressNginxPluginLister helps list IngressNginxPlugins. +type IngressNginxPluginLister interface { + // List lists all IngressNginxPlugins in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.IngressNginxPlugin, err error) + // IngressNginxPlugins returns an object that can list and get IngressNginxPlugins. + IngressNginxPlugins(namespace string) IngressNginxPluginNamespaceLister + IngressNginxPluginListerExpansion +} + +// ingressNginxPluginLister implements the IngressNginxPluginLister interface. +type ingressNginxPluginLister struct { + indexer cache.Indexer +} + +// NewIngressNginxPluginLister returns a new IngressNginxPluginLister. +func NewIngressNginxPluginLister(indexer cache.Indexer) IngressNginxPluginLister { + return &ingressNginxPluginLister{indexer: indexer} +} + +// List lists all IngressNginxPlugins in the indexer. +func (s *ingressNginxPluginLister) List(selector labels.Selector) (ret []*v1alpha1.IngressNginxPlugin, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IngressNginxPlugin)) + }) + return ret, err +} + +// IngressNginxPlugins returns an object that can list and get IngressNginxPlugins. +func (s *ingressNginxPluginLister) IngressNginxPlugins(namespace string) IngressNginxPluginNamespaceLister { + return ingressNginxPluginNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// IngressNginxPluginNamespaceLister helps list and get IngressNginxPlugins. +type IngressNginxPluginNamespaceLister interface { + // List lists all IngressNginxPlugins in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.IngressNginxPlugin, err error) + // Get retrieves the IngressNginxPlugin from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.IngressNginxPlugin, error) + IngressNginxPluginNamespaceListerExpansion +} + +// ingressNginxPluginNamespaceLister implements the IngressNginxPluginNamespaceLister +// interface. +type ingressNginxPluginNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all IngressNginxPlugins in the indexer for a given namespace. +func (s ingressNginxPluginNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.IngressNginxPlugin, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IngressNginxPlugin)) + }) + return ret, err +} + +// Get retrieves the IngressNginxPlugin from the indexer for a given namespace and name. +func (s ingressNginxPluginNamespaceLister) Get(name string) (*v1alpha1.IngressNginxPlugin, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ingressnginxplugin"), name) + } + return obj.(*v1alpha1.IngressNginxPlugin), nil +} From f3180096c44ccc95fda25b69f27d8a4236500e35 Mon Sep 17 00:00:00 2001 From: Alex Kursell Date: Wed, 3 Apr 2019 16:48:10 -0400 Subject: [PATCH 2/2] wip CRD --- deploy/mandatory.yaml | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/deploy/mandatory.yaml b/deploy/mandatory.yaml index e51cf713fa..61dd1a88d2 100644 --- a/deploy/mandatory.yaml +++ b/deploy/mandatory.yaml @@ -227,7 +227,8 @@ spec: serviceAccountName: nginx-ingress-serviceaccount containers: - name: nginx-ingress-controller - image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.23.0 + image: ingress-controller/nginx-ingress-controller:dev + imagePullPolicy: Never args: - /nginx-ingress-controller - --configmap=$(POD_NAMESPACE)/nginx-configuration @@ -235,6 +236,7 @@ spec: - --udp-services-configmap=$(POD_NAMESPACE)/udp-services - --publish-service=$(POD_NAMESPACE)/ingress-nginx - --annotations-prefix=nginx.ingress.kubernetes.io + - --v=3 securityContext: allowPrivilegeEscalation: true capabilities: @@ -279,3 +281,34 @@ spec: timeoutSeconds: 10 --- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: ingressnginxplugins.nginx.ingress.kubernetes.io +spec: + group: nginx.ingress.kubernetes.io + versions: + - name: v1alpha1 + served: true + storage: true + scope: Namespaced + names: + plural: ingressnginxplugins + singular: ingressnginxplugin + kind: IngressNginxPlugin + shortNames: + - inp + validation: + openAPIV3Schema: + properties: + spec: + required: + - archive + - sha256sum + properties: + archive: + type: string + pattern: '^.*\.tar.gz$' + sha256sum: + type: string + pattern: '^[A-Fa-f0-9]{64}$' \ No newline at end of file