本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/cache.NewSharedIndexInformer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSharedIndexInformer函数的具体用法?Golang NewSharedIndexInformer怎么用?Golang NewSharedIndexInformer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSharedIndexInformer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Informer
func (f *deploymentInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(&extensions.Deployment{})
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return f.client.Extensions().Deployments(api.NamespaceAll).List(options)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return f.client.Extensions().Deployments(api.NamespaceAll).Watch(options)
},
},
&extensions.Deployment{},
// TODO remove this. It is hardcoded so that "Waiting for the second deployment to clear overlapping annotation" in
// "overlapping deployment should not fight with each other" will work since it requires a full resync to work properly.
30*time.Second,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
f.informers[informerType] = informer
return informer
}
示例2: Informer
func (f *storageClassInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(&storage.StorageClass{})
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.client.Storage().StorageClasses().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.client.Storage().StorageClasses().Watch(options)
},
},
&storage.StorageClass{},
f.defaultResync,
cache.Indexers{},
)
f.informers[informerType] = informer
return informer
}
示例3: Informer
func (f *clusterResourceQuotaInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerObj := "aapi.ClusterResourceQuota{}
informerType := reflect.TypeOf(informerObj)
informer, exists := f.coreInformers[informerType]
if exists {
return informer
}
lw := f.customListerWatchers.GetListerWatcher(kapi.Resource("clusterresourcequotas"))
if lw == nil {
lw = &cache.ListWatch{
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return f.originClient.ClusterResourceQuotas().List(options)
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
return f.originClient.ClusterResourceQuotas().Watch(options)
},
}
}
informer = cache.NewSharedIndexInformer(
lw,
informerObj,
f.defaultResync,
cache.Indexers{},
)
f.coreInformers[informerType] = informer
return informer
}
示例4: Informer
func (s *securityContextConstraintsInformer) Informer() cache.SharedIndexInformer {
s.lock.Lock()
defer s.lock.Unlock()
informerObj := &kapi.SecurityContextConstraints{}
informerType := reflect.TypeOf(informerObj)
informer, exists := s.informers[informerType]
if exists {
return informer
}
informer = cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return s.kubeClient.Core().SecurityContextConstraints().List(options)
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
return s.kubeClient.Core().SecurityContextConstraints().Watch(options)
},
},
informerObj,
s.defaultResync,
cache.Indexers{},
)
s.informers[informerType] = informer
return informer
}
示例5: Informer
func (f *roleInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(&rbac.Role{})
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return f.internalclient.Rbac().Roles(v1.NamespaceAll).List(convertListOptionsOrDie(options))
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return f.internalclient.Rbac().Roles(v1.NamespaceAll).Watch(convertListOptionsOrDie(options))
},
},
&rbac.Role{},
f.defaultResync,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
f.informers[informerType] = informer
return informer
}
示例6: Informer
func (f *replicationControllerInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerObj := &kapi.ReplicationController{}
informerType := reflect.TypeOf(informerObj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
lw := f.customListerWatchers.GetListerWatcher(kapi.Resource("replicationcontrollers"))
if lw == nil {
lw = &cache.ListWatch{
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return f.kubeClient.Core().ReplicationControllers(kapi.NamespaceAll).List(options)
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
return f.kubeClient.Core().ReplicationControllers(kapi.NamespaceAll).Watch(options)
},
}
}
informer = cache.NewSharedIndexInformer(
lw,
informerObj,
f.defaultResync,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
f.informers[informerType] = informer
return informer
}
示例7: newJobInformer
func newJobInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
var internalOptions api.ListOptions
if err := api.Scheme.Convert(&options, &internalOptions, nil); err != nil {
return nil, err
}
return client.Batch().Jobs(api.NamespaceAll).List(internalOptions)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
var internalOptions api.ListOptions
if err := api.Scheme.Convert(&options, &internalOptions, nil); err != nil {
return nil, err
}
return client.Batch().Jobs(api.NamespaceAll).Watch(internalOptions)
},
},
&batch.Job{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
示例8: Informer
func (f *clusterRoleBindingInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerType := reflect.TypeOf(&rbac.ClusterRoleBinding{})
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return f.client.Rbac().ClusterRoleBindings().List(options)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return f.client.Rbac().ClusterRoleBindings().Watch(options)
},
},
&rbac.ClusterRoleBinding{},
f.defaultResync,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
f.informers[informerType] = informer
return informer
}
示例9: NewLimitRangeInformer
// NewLimitRangeInformer returns a SharedIndexInformer that lists and watches all LimitRanges
func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.Core().LimitRanges(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.Core().LimitRanges(v1.NamespaceAll).Watch(options)
},
},
&v1.LimitRange{},
resyncPeriod,
cache.Indexers{})
return sharedIndexInformer
}
示例10: newRoleBindingInformer
func newRoleBindingInformer(client release_1_5.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.RbacV1alpha1().RoleBindings(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.RbacV1alpha1().RoleBindings(v1.NamespaceAll).Watch(options)
},
},
&rbac_v1alpha1.RoleBinding{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
示例11: NewPVCInformer
// NewPVCInformer returns a SharedIndexInformer that lists and watches all PVCs
func NewPVCInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.Core().PersistentVolumeClaims(v1.NamespaceAll).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.Core().PersistentVolumeClaims(v1.NamespaceAll).Watch(options)
},
},
&v1.PersistentVolumeClaim{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
示例12: newHorizontalPodAutoscalerInformer
func newHorizontalPodAutoscalerInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options api_v1.ListOptions) (runtime.Object, error) {
return client.AutoscalingV1().HorizontalPodAutoscalers(api_v1.NamespaceAll).List(options)
},
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
return client.AutoscalingV1().HorizontalPodAutoscalers(api_v1.NamespaceAll).Watch(options)
},
},
&autoscaling_v1.HorizontalPodAutoscaler{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
示例13: newThirdPartyResourceInformer
func newThirdPartyResourceInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.ExtensionsV1beta1().ThirdPartyResources().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.ExtensionsV1beta1().ThirdPartyResources().Watch(options)
},
},
&extensions_v1beta1.ThirdPartyResource{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
示例14: newCertificateSigningRequestInformer
func newCertificateSigningRequestInformer(client release_1_5.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.CertificatesV1alpha1().CertificateSigningRequests().List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.CertificatesV1alpha1().CertificateSigningRequests().Watch(options)
},
},
&certificates_v1alpha1.CertificateSigningRequest{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}
示例15: newComponentStatusInformer
func newComponentStatusInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
sharedIndexInformer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options api_v1.ListOptions) (runtime.Object, error) {
return client.CoreV1().ComponentStatuses().List(options)
},
WatchFunc: func(options api_v1.ListOptions) (watch.Interface, error) {
return client.CoreV1().ComponentStatuses().Watch(options)
},
},
&api_v1.ComponentStatus{},
resyncPeriod,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
return sharedIndexInformer
}