コード例 #1
0
ファイル: lifecycle.go プロジェクト: kimsh92/origin
// NewHookExecutor makes a HookExecutor from a client.
func NewHookExecutor(client kclient.Interface, podLogDestination io.Writer) *HookExecutor {
	return &HookExecutor{
		podClient: &HookExecutorPodClientImpl{
			CreatePodFunc: func(namespace string, pod *kapi.Pod) (*kapi.Pod, error) {
				return client.Pods(namespace).Create(pod)
			},
			PodWatchFunc: func(namespace, name, resourceVersion string, stopChannel chan struct{}) func() *kapi.Pod {
				return NewPodWatch(client, namespace, name, resourceVersion, stopChannel)
			},
		},
		podLogStream: func(namespace, name string, opts *kapi.PodLogOptions) (io.ReadCloser, error) {
			req, err := client.PodLogs(namespace).Get(name, opts)
			if err != nil {
				return nil, err
			}
			return req.Stream()
		},
		podLogDestination: podLogDestination,
	}
}