// NewPersistentVolumeControllerFromClient returns a new // *PersistentVolumeController that runs its own informer. func NewPersistentVolumeControllerFromClient( kubeClient clientset.Interface, syncPeriod time.Duration, alphaProvisioner vol.ProvisionableVolumePlugin, volumePlugins []vol.VolumePlugin, cloud cloudprovider.Interface, clusterName string, volumeSource, claimSource, classSource cache.ListerWatcher, eventRecorder record.EventRecorder, enableDynamicProvisioning bool, ) *PersistentVolumeController { pvInformer := informers.NewPVInformer(kubeClient, syncPeriod) if volumeSource != nil { pvInformer = framework.NewSharedIndexInformer(volumeSource, &api.PersistentVolume{}, syncPeriod, cache.Indexers{"accessmodes": accessModesIndexFunc}) } ctrl := NewPersistentVolumeController( kubeClient, syncPeriod, alphaProvisioner, volumePlugins, cloud, clusterName, pvInformer, claimSource, classSource, eventRecorder, enableDynamicProvisioning, ) ctrl.isInformerInternal = true return ctrl }
func Test_NewAttachDetachController_Positive(t *testing.T) { // Arrange fakeKubeClient := controllervolumetesting.CreateTestClient() resyncPeriod := 5 * time.Minute podInformer := informers.NewPodInformer(fakeKubeClient, resyncPeriod) nodeInformer := informers.NewNodeInformer(fakeKubeClient, resyncPeriod) pvcInformer := informers.NewPVCInformer(fakeKubeClient, resyncPeriod) pvInformer := informers.NewPVInformer(fakeKubeClient, resyncPeriod) fakeRecorder := &record.FakeRecorder{} // Act _, err := NewAttachDetachController( fakeKubeClient, podInformer, nodeInformer, pvcInformer, pvInformer, nil, /* cloud */ nil, /* plugins */ fakeRecorder) // Assert if err != nil { t.Fatalf("Run failed with error. Expected: <no error> Actual: <%v>", err) } }