Этот коммит содержится в:
Christopher Speller
2019-07-29 07:39:56 -07:00
коммит произвёл GitHub
родитель f226f672f3
Коммит 20825a1702
547 изменённых файлов: 44126 добавлений и 27501 удалений

1
vendor/github.com/hashicorp/go-plugin/.gitignore сгенерированный поставляемый
Просмотреть файл

@@ -1 +1,2 @@
.DS_Store
.idea

30
vendor/github.com/hashicorp/go-plugin/client.go сгенерированный поставляемый
Просмотреть файл

@@ -87,6 +87,10 @@ type Client struct {
// goroutines.
clientWaitGroup sync.WaitGroup
// stderrWaitGroup is used to prevent the command's Wait() function from
// being called before we've finished reading from the stderr pipe.
stderrWaitGroup sync.WaitGroup
// processKilled is used for testing only, to flag when the process was
// forcefully killed.
processKilled bool
@@ -590,6 +594,12 @@ func (c *Client) Start() (addr net.Addr, err error) {
// Create a context for when we kill
c.doneCtx, c.ctxCancel = context.WithCancel(context.Background())
// Start goroutine that logs the stderr
c.clientWaitGroup.Add(1)
c.stderrWaitGroup.Add(1)
// logStderr calls Done()
go c.logStderr(cmdStderr)
c.clientWaitGroup.Add(1)
go func() {
// ensure the context is cancelled when we're done
@@ -602,6 +612,10 @@ func (c *Client) Start() (addr net.Addr, err error) {
pid := c.process.Pid
path := cmd.Path
// wait to finish reading from stderr since the stderr pipe reader
// will be closed by the subsequent call to cmd.Wait().
c.stderrWaitGroup.Wait()
// Wait for the command to end.
err := cmd.Wait()
@@ -624,11 +638,6 @@ func (c *Client) Start() (addr net.Addr, err error) {
c.exited = true
}()
// Start goroutine that logs the stderr
c.clientWaitGroup.Add(1)
// logStderr calls Done()
go c.logStderr(cmdStderr)
// Start a goroutine that is going to be reading the lines
// out of stdout
linesCh := make(chan string)
@@ -936,6 +945,7 @@ var stdErrBufferSize = 64 * 1024
func (c *Client) logStderr(r io.Reader) {
defer c.clientWaitGroup.Done()
defer c.stderrWaitGroup.Done()
l := c.logger.Named(filepath.Base(c.config.Cmd.Path))
reader := bufio.NewReaderSize(r, stdErrBufferSize)
@@ -976,15 +986,15 @@ func (c *Client) logStderr(r io.Reader) {
// Attempt to infer the desired log level from the commonly used
// string prefixes
switch line := string(line); {
case strings.HasPrefix("[TRACE]", line):
case strings.HasPrefix(line, "[TRACE]"):
l.Trace(line)
case strings.HasPrefix("[DEBUG]", line):
case strings.HasPrefix(line, "[DEBUG]"):
l.Debug(line)
case strings.HasPrefix("[INFO]", line):
case strings.HasPrefix(line, "[INFO]"):
l.Info(line)
case strings.HasPrefix("[WARN]", line):
case strings.HasPrefix(line, "[WARN]"):
l.Warn(line)
case strings.HasPrefix("[ERROR]", line):
case strings.HasPrefix(line, "[ERROR]"):
l.Error(line)
default:
l.Debug(line)

6
vendor/github.com/hashicorp/go-plugin/grpc_client.go сгенерированный поставляемый
Просмотреть файл

@@ -3,6 +3,7 @@ package plugin
import (
"crypto/tls"
"fmt"
"math"
"net"
"time"
@@ -32,6 +33,11 @@ func dialGRPCConn(tls *tls.Config, dialer func(string, time.Duration) (net.Conn,
credentials.NewTLS(tls)))
}
opts = append(opts,
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxInt32)),
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(math.MaxInt32)))
// Connect. Note the first parameter is unused because we use a custom
// dialer that has the state to see the address.
conn, err := grpc.Dial("unused", opts...)

32
vendor/github.com/hashicorp/go-plugin/server.go сгенерированный поставляемый
Просмотреть файл

@@ -363,14 +363,34 @@ func serverListener() (net.Listener, error) {
}
func serverListener_tcp() (net.Listener, error) {
minPort, err := strconv.ParseInt(os.Getenv("PLUGIN_MIN_PORT"), 10, 32)
if err != nil {
return nil, err
envMinPort := os.Getenv("PLUGIN_MIN_PORT")
envMaxPort := os.Getenv("PLUGIN_MAX_PORT")
var minPort, maxPort int64
var err error
switch {
case len(envMinPort) == 0:
minPort = 0
default:
minPort, err = strconv.ParseInt(envMinPort, 10, 32)
if err != nil {
return nil, fmt.Errorf("Couldn't get value from PLUGIN_MIN_PORT: %v", err)
}
}
maxPort, err := strconv.ParseInt(os.Getenv("PLUGIN_MAX_PORT"), 10, 32)
if err != nil {
return nil, err
switch {
case len(envMaxPort) == 0:
maxPort = 0
default:
maxPort, err = strconv.ParseInt(envMaxPort, 10, 32)
if err != nil {
return nil, fmt.Errorf("Couldn't get value from PLUGIN_MAX_PORT: %v", err)
}
}
if minPort > maxPort {
return nil, fmt.Errorf("ENV_MIN_PORT value of %d is greater than PLUGIN_MAX_PORT value of %d", minPort, maxPort)
}
for port := minPort; port <= maxPort; port++ {