當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Clientset.AddReactor方法代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/client/clientset_generated/clientset/fake.Clientset.AddReactor方法的典型用法代碼示例。如果您正苦於以下問題:Golang Clientset.AddReactor方法的具體用法?Golang Clientset.AddReactor怎麽用?Golang Clientset.AddReactor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/kubernetes/pkg/client/clientset_generated/clientset/fake.Clientset的用法示例。


在下文中一共展示了Clientset.AddReactor方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: addUpdatePodsReactor

func addUpdatePodsReactor(fakeClient *fake.Clientset) *fake.Clientset {
	fakeClient.AddReactor("update", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) {
		obj := action.(core.UpdateAction).GetObject().(*v1.Pod)
		return true, obj, nil
	})
	return fakeClient
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:7,代碼來源:deployment_util_test.go

示例2: addUpdateRSReactor

func addUpdateRSReactor(fakeClient *fake.Clientset) *fake.Clientset {
	fakeClient.AddReactor("update", "replicasets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
		obj := action.(core.UpdateAction).GetObject().(*extensions.ReplicaSet)
		return true, obj, nil
	})
	return fakeClient
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:7,代碼來源:deployment_util_test.go

示例3: newVolumeReactor

func newVolumeReactor(client *fake.Clientset, ctrl *PersistentVolumeController, volumeSource *fcache.FakePVControllerSource, claimSource *fcache.FakePVCControllerSource, errors []reactorError) *volumeReactor {
	reactor := &volumeReactor{
		volumes:      make(map[string]*v1.PersistentVolume),
		claims:       make(map[string]*v1.PersistentVolumeClaim),
		ctrl:         ctrl,
		volumeSource: volumeSource,
		claimSource:  claimSource,
		errors:       errors,
	}
	client.AddReactor("*", "*", reactor.React)
	return reactor
}
開發者ID:nak3,項目名稱:kubernetes,代碼行數:12,代碼來源:framework_test.go

示例4: TestSyncBatchIgnoresNotFound

func TestSyncBatchIgnoresNotFound(t *testing.T) {
	client := fake.Clientset{}
	syncer := newTestManager(&client)
	client.AddReactor("get", "pods", func(action core.Action) (bool, runtime.Object, error) {
		return true, nil, errors.NewNotFound(api.Resource("pods"), "test-pod")
	})
	syncer.SetPodStatus(getTestPod(), getRandomPodStatus())
	syncer.testSyncBatch()

	verifyActions(t, syncer.kubeClient, []core.Action{
		core.GetActionImpl{ActionImpl: core.ActionImpl{Verb: "get", Resource: schema.GroupVersionResource{Resource: "pods"}}},
	})
}
開發者ID:jonboulle,項目名稱:kubernetes,代碼行數:13,代碼來源:status_manager_test.go

示例5: addGetRSReactor

func addGetRSReactor(fakeClient *fake.Clientset, obj runtime.Object) *fake.Clientset {
	rsList, ok := obj.(*extensions.ReplicaSetList)
	fakeClient.AddReactor("get", "replicasets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
		name := action.(core.GetAction).GetName()
		if ok {
			for _, rs := range rsList.Items {
				if rs.Name == name {
					return true, &rs, nil
				}
			}
		}
		return false, nil, fmt.Errorf("could not find the requested replica set: %s", name)

	})
	return fakeClient
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:16,代碼來源:deployment_util_test.go

示例6: addListPodsReactor

func addListPodsReactor(fakeClient *fake.Clientset, obj runtime.Object) *fake.Clientset {
	fakeClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) {
		return true, obj, nil
	})
	return fakeClient
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:6,代碼來源:deployment_util_test.go


注:本文中的k8s/io/kubernetes/pkg/client/clientset_generated/clientset/fake.Clientset.AddReactor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。