Example #1
0
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
func (ds *dockerService) Exec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
	if ds.streamingServer == nil {
		return nil, streaming.ErrorStreamingDisabled("exec")
	}
	_, err := checkContainerStatus(ds.client, req.GetContainerId())
	if err != nil {
		return nil, err
	}
	return ds.streamingServer.GetExec(req)
}
Example #2
0
func (s *server) GetExec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
	url := s.buildURL("exec", req.GetContainerId(), streamOpts{
		stdin:   req.GetStdin(),
		stdout:  true,
		stderr:  !req.GetTty(), // For TTY connections, both stderr is combined with stdout.
		tty:     req.GetTty(),
		command: req.GetCmd(),
	})
	return &runtimeapi.ExecResponse{
		Url: &url,
	}, nil
}
// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.
func (r *RemoteRuntimeService) Exec(req *runtimeApi.ExecRequest) (*runtimeApi.ExecResponse, error) {
	ctx, cancel := getContextWithTimeout(r.timeout)
	defer cancel()

	resp, err := r.runtimeClient.Exec(ctx, req)
	if err != nil {
		glog.Errorf("Exec %s '%s' from runtime service failed: %v", req.GetContainerId(), strings.Join(req.GetCmd(), " "), err)
		return nil, err
	}

	return resp, nil
}
Example #4
0
func (s *server) GetExec(req *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) {
	if req.GetContainerId() == "" {
		return nil, grpc.Errorf(codes.InvalidArgument, "missing required container_id")
	}
	token, err := s.cache.Insert(req)
	if err != nil {
		return nil, err
	}
	return &runtimeapi.ExecResponse{
		Url: s.buildURL("exec", token),
	}, nil
}
func (r *FakeRuntime) Exec(req *runtimeApi.ExecRequest) (*runtimeApi.ExecResponse, error) {
	url := "http://" + FakeStreamingHost + ":" + FakeStreamingPort + "/exec/" + req.GetContainerId()
	return &runtimeApi.ExecResponse{
		Url: &url,
	}, nil
}