コード例 #1
0
func installPods(controller *Controller, podInterface, podStore *mock.Mock, namespace string, count int) {
	keys := make([]string, count)
	for i := 0; i < count; i++ {
		pod := &api.Pod{
			ObjectMeta: api.ObjectMeta{
				Name:      fmt.Sprintf("pod%02d", i),
				Namespace: namespace,
				UID:       kubetypes.UID(uuid.New()),
				Labels: map[string]string{
					"app": fmt.Sprintf("pod%02d", i),
				},
			},
		}
		key := fmt.Sprintf("%s/%s", namespace, pod.Name)
		keys[i] = key
		podStore.On("GetByKey", key).Return(pod, true, nil)
		podInterface.On("Update", pod).Return(pod, nil)
		podInterface.On("List", makeListOptSelector(pod.Labels)).Return(&api.PodList{Items: []api.Pod{*pod}}, nil)
		controller.AddPod(pod)
	}

	podStore.On("ListKeys").Return(keys)
}