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


Golang FakeRuntimeService.SetFakeSandboxes方法代碼示例

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


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

示例1: makeAndSetFakePod

// makeAndSetFakePod is a helper function to create and set one fake sandbox for a pod and
// one fake container for each of its container.
func makeAndSetFakePod(t *testing.T, m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService,
	pod *v1.Pod) (*apitest.FakePodSandbox, []*apitest.FakeContainer) {
	sandbox := makeFakePodSandbox(t, m, sandboxTemplate{
		pod:       pod,
		createdAt: fakeCreatedAt,
		state:     runtimeApi.PodSandboxState_SANDBOX_READY,
	})

	var containers []*apitest.FakeContainer
	newTemplate := func(c *v1.Container) containerTemplate {
		return containerTemplate{
			pod:       pod,
			container: c,
			createdAt: fakeCreatedAt,
			state:     runtimeApi.ContainerState_CONTAINER_RUNNING,
		}
	}
	for i := range pod.Spec.Containers {
		containers = append(containers, makeFakeContainer(t, m, newTemplate(&pod.Spec.Containers[i])))
	}
	for i := range pod.Spec.InitContainers {
		containers = append(containers, makeFakeContainer(t, m, newTemplate(&pod.Spec.InitContainers[i])))
	}

	fakeRuntime.SetFakeSandboxes([]*apitest.FakePodSandbox{sandbox})
	fakeRuntime.SetFakeContainers(containers)
	return sandbox, containers
}
開發者ID:paralin,項目名稱:kubernetes,代碼行數:30,代碼來源:kuberuntime_manager_test.go

示例2: makeAndSetFakeEvictablePod

func makeAndSetFakeEvictablePod(m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService, pods []*apiPodWithCreatedAt) error {
	sandboxes := make([]*apitest.FakePodSandbox, 0)
	containers := make([]*apitest.FakeContainer, 0)
	for _, pod := range pods {
		fakePodSandbox, err := makeFakePodSandbox(m, pod.apiPod, pod.createdAt)
		if err != nil {
			return err
		}

		fakeContainers, err := makeFakeContainers(m, pod.apiPod, pod.apiPod.Spec.Containers, pod.createdAt, runtimeApi.ContainerState_EXITED)
		if err != nil {
			return err
		}

		// Set sandbox to not ready state
		sandboxNotReady := runtimeApi.PodSandBoxState_NOTREADY
		fakePodSandbox.State = &sandboxNotReady
		sandboxes = append(sandboxes, fakePodSandbox)

		// Set containers to exited state
		containerExited := runtimeApi.ContainerState_EXITED
		for _, c := range fakeContainers {
			c.State = &containerExited
			containers = append(containers, c)
		}

	}

	fakeRuntime.SetFakeSandboxes(sandboxes)
	fakeRuntime.SetFakeContainers(containers)
	return nil
}
開發者ID:ncdc,項目名稱:kubernetes,代碼行數:32,代碼來源:kuberuntime_gc_test.go

示例3: makeAndSetFakePod

func makeAndSetFakePod(m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService, pod *api.Pod) (*apitest.FakePodSandbox, []*apitest.FakeContainer, error) {
	fakePodSandbox, err := makeFakePodSandbox(m, pod)
	if err != nil {
		return nil, nil, err
	}

	fakeContainers, err := makeFakeContainers(m, pod, pod.Spec.Containers)
	if err != nil {
		return nil, nil, err
	}

	fakeRuntime.SetFakeSandboxes([]*apitest.FakePodSandbox{fakePodSandbox})
	fakeRuntime.SetFakeContainers(fakeContainers)
	return fakePodSandbox, fakeContainers, nil
}
開發者ID:astropuffin,項目名稱:kubernetes,代碼行數:15,代碼來源:kuberuntime_manager_test.go

示例4: makeAndSetFakePod

func makeAndSetFakePod(m *kubeGenericRuntimeManager, fakeRuntime *apitest.FakeRuntimeService, pod *api.Pod) (*apitest.FakePodSandbox, []*apitest.FakeContainer, error) {
	fakePodSandbox, err := makeFakePodSandbox(m, pod, fakeCreatedAt)
	if err != nil {
		return nil, nil, err
	}

	fakeContainers, err := makeFakeContainers(m, pod, pod.Spec.Containers, fakeCreatedAt, runtimeApi.ContainerState_RUNNING)
	if err != nil {
		return nil, nil, err
	}

	fakeInitContainers, err := makeFakeContainers(m, pod, pod.Spec.InitContainers, fakeCreatedAt, runtimeApi.ContainerState_EXITED)
	if err != nil {
		return nil, nil, err
	}

	fakeContainers = append(fakeContainers, fakeInitContainers...)
	fakeRuntime.SetFakeSandboxes([]*apitest.FakePodSandbox{fakePodSandbox})
	fakeRuntime.SetFakeContainers(fakeContainers)
	return fakePodSandbox, fakeContainers, nil
}
開發者ID:ncdc,項目名稱:kubernetes,代碼行數:21,代碼來源:kuberuntime_manager_test.go


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