Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame^] | 1 | /* |
| 2 | Copyright The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // Code generated by informer-gen. DO NOT EDIT. |
| 18 | |
| 19 | package informers |
| 20 | |
| 21 | import ( |
| 22 | reflect "reflect" |
| 23 | sync "sync" |
| 24 | time "time" |
| 25 | |
| 26 | v1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 27 | runtime "k8s.io/apimachinery/pkg/runtime" |
| 28 | schema "k8s.io/apimachinery/pkg/runtime/schema" |
| 29 | admissionregistration "k8s.io/client-go/informers/admissionregistration" |
| 30 | apps "k8s.io/client-go/informers/apps" |
| 31 | autoscaling "k8s.io/client-go/informers/autoscaling" |
| 32 | batch "k8s.io/client-go/informers/batch" |
| 33 | certificates "k8s.io/client-go/informers/certificates" |
| 34 | core "k8s.io/client-go/informers/core" |
| 35 | events "k8s.io/client-go/informers/events" |
| 36 | extensions "k8s.io/client-go/informers/extensions" |
| 37 | internalinterfaces "k8s.io/client-go/informers/internalinterfaces" |
| 38 | networking "k8s.io/client-go/informers/networking" |
| 39 | policy "k8s.io/client-go/informers/policy" |
| 40 | rbac "k8s.io/client-go/informers/rbac" |
| 41 | scheduling "k8s.io/client-go/informers/scheduling" |
| 42 | settings "k8s.io/client-go/informers/settings" |
| 43 | storage "k8s.io/client-go/informers/storage" |
| 44 | kubernetes "k8s.io/client-go/kubernetes" |
| 45 | cache "k8s.io/client-go/tools/cache" |
| 46 | ) |
| 47 | |
| 48 | // SharedInformerOption defines the functional option type for SharedInformerFactory. |
| 49 | type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory |
| 50 | |
| 51 | type sharedInformerFactory struct { |
| 52 | client kubernetes.Interface |
| 53 | namespace string |
| 54 | tweakListOptions internalinterfaces.TweakListOptionsFunc |
| 55 | lock sync.Mutex |
| 56 | defaultResync time.Duration |
| 57 | customResync map[reflect.Type]time.Duration |
| 58 | |
| 59 | informers map[reflect.Type]cache.SharedIndexInformer |
| 60 | // startedInformers is used for tracking which informers have been started. |
| 61 | // This allows Start() to be called multiple times safely. |
| 62 | startedInformers map[reflect.Type]bool |
| 63 | } |
| 64 | |
| 65 | // WithCustomResyncConfig sets a custom resync period for the specified informer types. |
| 66 | func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { |
| 67 | return func(factory *sharedInformerFactory) *sharedInformerFactory { |
| 68 | for k, v := range resyncConfig { |
| 69 | factory.customResync[reflect.TypeOf(k)] = v |
| 70 | } |
| 71 | return factory |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. |
| 76 | func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { |
| 77 | return func(factory *sharedInformerFactory) *sharedInformerFactory { |
| 78 | factory.tweakListOptions = tweakListOptions |
| 79 | return factory |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // WithNamespace limits the SharedInformerFactory to the specified namespace. |
| 84 | func WithNamespace(namespace string) SharedInformerOption { |
| 85 | return func(factory *sharedInformerFactory) *sharedInformerFactory { |
| 86 | factory.namespace = namespace |
| 87 | return factory |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. |
| 92 | func NewSharedInformerFactory(client kubernetes.Interface, defaultResync time.Duration) SharedInformerFactory { |
| 93 | return NewSharedInformerFactoryWithOptions(client, defaultResync) |
| 94 | } |
| 95 | |
| 96 | // NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. |
| 97 | // Listers obtained via this SharedInformerFactory will be subject to the same filters |
| 98 | // as specified here. |
| 99 | // Deprecated: Please use NewSharedInformerFactoryWithOptions instead |
| 100 | func NewFilteredSharedInformerFactory(client kubernetes.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { |
| 101 | return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) |
| 102 | } |
| 103 | |
| 104 | // NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. |
| 105 | func NewSharedInformerFactoryWithOptions(client kubernetes.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { |
| 106 | factory := &sharedInformerFactory{ |
| 107 | client: client, |
| 108 | namespace: v1.NamespaceAll, |
| 109 | defaultResync: defaultResync, |
| 110 | informers: make(map[reflect.Type]cache.SharedIndexInformer), |
| 111 | startedInformers: make(map[reflect.Type]bool), |
| 112 | customResync: make(map[reflect.Type]time.Duration), |
| 113 | } |
| 114 | |
| 115 | // Apply all options |
| 116 | for _, opt := range options { |
| 117 | factory = opt(factory) |
| 118 | } |
| 119 | |
| 120 | return factory |
| 121 | } |
| 122 | |
| 123 | // Start initializes all requested informers. |
| 124 | func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { |
| 125 | f.lock.Lock() |
| 126 | defer f.lock.Unlock() |
| 127 | |
| 128 | for informerType, informer := range f.informers { |
| 129 | if !f.startedInformers[informerType] { |
| 130 | go informer.Run(stopCh) |
| 131 | f.startedInformers[informerType] = true |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | // WaitForCacheSync waits for all started informers' cache were synced. |
| 137 | func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { |
| 138 | informers := func() map[reflect.Type]cache.SharedIndexInformer { |
| 139 | f.lock.Lock() |
| 140 | defer f.lock.Unlock() |
| 141 | |
| 142 | informers := map[reflect.Type]cache.SharedIndexInformer{} |
| 143 | for informerType, informer := range f.informers { |
| 144 | if f.startedInformers[informerType] { |
| 145 | informers[informerType] = informer |
| 146 | } |
| 147 | } |
| 148 | return informers |
| 149 | }() |
| 150 | |
| 151 | res := map[reflect.Type]bool{} |
| 152 | for informType, informer := range informers { |
| 153 | res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) |
| 154 | } |
| 155 | return res |
| 156 | } |
| 157 | |
| 158 | // InternalInformerFor returns the SharedIndexInformer for obj using an internal |
| 159 | // client. |
| 160 | func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { |
| 161 | f.lock.Lock() |
| 162 | defer f.lock.Unlock() |
| 163 | |
| 164 | informerType := reflect.TypeOf(obj) |
| 165 | informer, exists := f.informers[informerType] |
| 166 | if exists { |
| 167 | return informer |
| 168 | } |
| 169 | |
| 170 | resyncPeriod, exists := f.customResync[informerType] |
| 171 | if !exists { |
| 172 | resyncPeriod = f.defaultResync |
| 173 | } |
| 174 | |
| 175 | informer = newFunc(f.client, resyncPeriod) |
| 176 | f.informers[informerType] = informer |
| 177 | |
| 178 | return informer |
| 179 | } |
| 180 | |
| 181 | // SharedInformerFactory provides shared informers for resources in all known |
| 182 | // API group versions. |
| 183 | type SharedInformerFactory interface { |
| 184 | internalinterfaces.SharedInformerFactory |
| 185 | ForResource(resource schema.GroupVersionResource) (GenericInformer, error) |
| 186 | WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool |
| 187 | |
| 188 | Admissionregistration() admissionregistration.Interface |
| 189 | Apps() apps.Interface |
| 190 | Autoscaling() autoscaling.Interface |
| 191 | Batch() batch.Interface |
| 192 | Certificates() certificates.Interface |
| 193 | Core() core.Interface |
| 194 | Events() events.Interface |
| 195 | Extensions() extensions.Interface |
| 196 | Networking() networking.Interface |
| 197 | Policy() policy.Interface |
| 198 | Rbac() rbac.Interface |
| 199 | Scheduling() scheduling.Interface |
| 200 | Settings() settings.Interface |
| 201 | Storage() storage.Interface |
| 202 | } |
| 203 | |
| 204 | func (f *sharedInformerFactory) Admissionregistration() admissionregistration.Interface { |
| 205 | return admissionregistration.New(f, f.namespace, f.tweakListOptions) |
| 206 | } |
| 207 | |
| 208 | func (f *sharedInformerFactory) Apps() apps.Interface { |
| 209 | return apps.New(f, f.namespace, f.tweakListOptions) |
| 210 | } |
| 211 | |
| 212 | func (f *sharedInformerFactory) Autoscaling() autoscaling.Interface { |
| 213 | return autoscaling.New(f, f.namespace, f.tweakListOptions) |
| 214 | } |
| 215 | |
| 216 | func (f *sharedInformerFactory) Batch() batch.Interface { |
| 217 | return batch.New(f, f.namespace, f.tweakListOptions) |
| 218 | } |
| 219 | |
| 220 | func (f *sharedInformerFactory) Certificates() certificates.Interface { |
| 221 | return certificates.New(f, f.namespace, f.tweakListOptions) |
| 222 | } |
| 223 | |
| 224 | func (f *sharedInformerFactory) Core() core.Interface { |
| 225 | return core.New(f, f.namespace, f.tweakListOptions) |
| 226 | } |
| 227 | |
| 228 | func (f *sharedInformerFactory) Events() events.Interface { |
| 229 | return events.New(f, f.namespace, f.tweakListOptions) |
| 230 | } |
| 231 | |
| 232 | func (f *sharedInformerFactory) Extensions() extensions.Interface { |
| 233 | return extensions.New(f, f.namespace, f.tweakListOptions) |
| 234 | } |
| 235 | |
| 236 | func (f *sharedInformerFactory) Networking() networking.Interface { |
| 237 | return networking.New(f, f.namespace, f.tweakListOptions) |
| 238 | } |
| 239 | |
| 240 | func (f *sharedInformerFactory) Policy() policy.Interface { |
| 241 | return policy.New(f, f.namespace, f.tweakListOptions) |
| 242 | } |
| 243 | |
| 244 | func (f *sharedInformerFactory) Rbac() rbac.Interface { |
| 245 | return rbac.New(f, f.namespace, f.tweakListOptions) |
| 246 | } |
| 247 | |
| 248 | func (f *sharedInformerFactory) Scheduling() scheduling.Interface { |
| 249 | return scheduling.New(f, f.namespace, f.tweakListOptions) |
| 250 | } |
| 251 | |
| 252 | func (f *sharedInformerFactory) Settings() settings.Interface { |
| 253 | return settings.New(f, f.namespace, f.tweakListOptions) |
| 254 | } |
| 255 | |
| 256 | func (f *sharedInformerFactory) Storage() storage.Interface { |
| 257 | return storage.New(f, f.namespace, f.tweakListOptions) |
| 258 | } |