当前位置: 首页>>代码示例>>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;未经允许,请勿转载。