1 /* 2 Copyright 2018 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 package dynamicinformer 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 "k8s.io/apimachinery/pkg/runtime/schema" 22 "k8s.io/client-go/informers" 23 ) 24 25 // DynamicSharedInformerFactory provides access to a shared informer and lister for dynamic client 26 type DynamicSharedInformerFactory interface { 27 // Start initializes all requested informers. They are handled in goroutines 28 // which run until the stop channel gets closed. 29 Start(stopCh <-chan struct{}) 30 31 // ForResource gives generic access to a shared informer of the matching type. 32 ForResource(gvr schema.GroupVersionResource) informers.GenericInformer 33 34 // WaitForCacheSync blocks until all started informers' caches were synced 35 // or the stop channel gets closed. 36 WaitForCacheSync(stopCh <-chan struct{}) map[schema.GroupVersionResource]bool 37 38 // Shutdown marks a factory as shutting down. At that point no new 39 // informers can be started anymore and Start will return without 40 // doing anything. 41 // 42 // In addition, Shutdown blocks until all goroutines have terminated. For that 43 // to happen, the close channel(s) that they were started with must be closed, 44 // either before Shutdown gets called or while it is waiting. 45 // 46 // Shutdown may be called multiple times, even concurrently. All such calls will 47 // block until all goroutines have terminated. 48 Shutdown() 49 } 50 51 // TweakListOptionsFunc defines the signature of a helper function 52 // that wants to provide more listing options to API 53 type TweakListOptionsFunc func(*metav1.ListOptions) 54