2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2018-10-06 03:32:43 +00:00
|
|
|
package docklog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/drivers/docker/docklog/proto"
|
|
|
|
)
|
|
|
|
|
2018-10-16 17:49:50 +00:00
|
|
|
// dockerLoggerClient implements the dockerLogger interface for client side requests
|
|
|
|
type dockerLoggerClient struct {
|
|
|
|
client proto.DockerLoggerClient
|
2018-10-06 03:32:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Start proxies the Start client side func to the protobuf interface
|
2018-10-16 17:49:50 +00:00
|
|
|
func (c *dockerLoggerClient) Start(opts *StartOpts) error {
|
2018-10-06 03:32:43 +00:00
|
|
|
req := &proto.StartRequest{
|
|
|
|
Endpoint: opts.Endpoint,
|
|
|
|
ContainerId: opts.ContainerID,
|
|
|
|
StdoutFifo: opts.Stdout,
|
|
|
|
StderrFifo: opts.Stderr,
|
2019-04-25 02:00:00 +00:00
|
|
|
Tty: opts.TTY,
|
2018-10-06 03:32:43 +00:00
|
|
|
|
|
|
|
TlsCert: opts.TLSCert,
|
|
|
|
TlsKey: opts.TLSKey,
|
|
|
|
TlsCa: opts.TLSCA,
|
|
|
|
}
|
|
|
|
_, err := c.client.Start(context.Background(), req)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop proxies the Stop client side func to the protobuf interface
|
2018-10-16 17:49:50 +00:00
|
|
|
func (c *dockerLoggerClient) Stop() error {
|
2018-10-06 03:32:43 +00:00
|
|
|
req := &proto.StopRequest{}
|
|
|
|
_, err := c.client.Stop(context.Background(), req)
|
|
|
|
return err
|
|
|
|
}
|