2018-10-06 03:32:43 +00:00
|
|
|
package docklog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
|
|
|
plugin "github.com/hashicorp/go-plugin"
|
|
|
|
"github.com/hashicorp/nomad/drivers/docker/docklog/proto"
|
|
|
|
)
|
|
|
|
|
2018-10-16 17:49:50 +00:00
|
|
|
// dockerLoggerServer is the server side translation between the protobuf and native interfaces
|
|
|
|
type dockerLoggerServer struct {
|
2018-10-06 03:32:43 +00:00
|
|
|
broker *plugin.GRPCBroker
|
2018-10-16 17:49:50 +00:00
|
|
|
impl DockerLogger
|
2018-10-06 03:32:43 +00:00
|
|
|
}
|
|
|
|
|
2018-10-16 17:49:50 +00:00
|
|
|
// Start proxies the protobuf Start RPC to the Start fun of the DockerLogger interface
|
|
|
|
func (s *dockerLoggerServer) Start(ctx context.Context, req *proto.StartRequest) (*proto.StartResponse, error) {
|
2018-10-06 03:32:43 +00:00
|
|
|
opts := &StartOpts{
|
|
|
|
Endpoint: req.Endpoint,
|
|
|
|
ContainerID: req.ContainerId,
|
|
|
|
Stdout: req.StdoutFifo,
|
|
|
|
Stderr: req.StderrFifo,
|
2019-04-25 02:00:00 +00:00
|
|
|
TTY: req.Tty,
|
2018-10-06 03:32:43 +00:00
|
|
|
|
|
|
|
TLSCert: req.TlsCert,
|
|
|
|
TLSKey: req.TlsKey,
|
|
|
|
TLSCA: req.TlsCa,
|
|
|
|
}
|
|
|
|
err := s.impl.Start(opts)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
resp := &proto.StartResponse{}
|
|
|
|
return resp, nil
|
|
|
|
}
|
|
|
|
|
2018-10-16 17:49:50 +00:00
|
|
|
// Stop proxies the protobuf Stop RPC to the Stop fun of the DockerLogger interface
|
|
|
|
func (s *dockerLoggerServer) Stop(ctx context.Context, req *proto.StopRequest) (*proto.StopResponse, error) {
|
2018-10-06 03:32:43 +00:00
|
|
|
return &proto.StopResponse{}, s.impl.Stop()
|
|
|
|
}
|