本文整理汇总了Golang中k8s/io/kubernetes/pkg/kubelet/api/testing.FakeRuntimeService.SetFakeContainers方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeRuntimeService.SetFakeContainers方法的具体用法?Golang FakeRuntimeService.SetFakeContainers怎么用?Golang FakeRuntimeService.SetFakeContainers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/kubelet/api/testing.FakeRuntimeService
的用法示例。
在下文中一共展示了FakeRuntimeService.SetFakeContainers方法的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
}
示例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
}
示例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
}
示例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
}