Skip to content

Commit 8c50ed7

Browse files
committed
bump hashicorp/go-plugin v1.7.0
1 parent 5f5c55e commit 8c50ed7

File tree

5 files changed

+39
-22
lines changed

5 files changed

+39
-22
lines changed

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/google/uuid v1.6.0
2020
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1
2121
github.com/hashicorp/go-hclog v1.6.3
22-
github.com/hashicorp/go-plugin v1.6.3
22+
github.com/hashicorp/go-plugin v1.7.0
2323
github.com/iancoleman/strcase v0.3.0
2424
github.com/invopop/jsonschema v0.12.0
2525
github.com/jackc/pgx/v4 v4.18.3
@@ -80,7 +80,6 @@ require (
8080
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59 // indirect
8181
github.com/bahlo/generic-list-go v0.2.0 // indirect
8282
github.com/beorn7/perks v1.0.1 // indirect
83-
github.com/bufbuild/protocompile v0.14.1 // indirect
8483
github.com/buger/goterm v0.0.0-20200322175922-2f3e71b85129 // indirect
8584
github.com/buger/jsonparser v1.1.1 // indirect
8685
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
@@ -100,7 +99,7 @@ require (
10099
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
101100
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
102101
github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026 // indirect
103-
github.com/hashicorp/yamux v0.1.1 // indirect
102+
github.com/hashicorp/yamux v0.1.2 // indirect
104103
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
105104
github.com/jackc/pgconn v1.14.3 // indirect
106105
github.com/jackc/pgio v1.0.0 // indirect
@@ -123,7 +122,7 @@ require (
123122
github.com/modern-go/reflect2 v1.0.2 // indirect
124123
github.com/mr-tron/base58 v1.2.0 // indirect
125124
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
126-
github.com/oklog/run v1.0.0 // indirect
125+
github.com/oklog/run v1.1.0 // indirect
127126
github.com/pierrec/lz4/v4 v4.1.22 // indirect
128127
github.com/pkg/errors v0.9.1 // indirect
129128
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026 h1:BpJ2o0OR5FV7vrkDYf
140140
github.com/hako/durafmt v0.0.0-20200710122514-c0fb7b4da026/go.mod h1:5Scbynm8dF1XAPwIwkGPqzkM/shndPm79Jd1003hTjE=
141141
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
142142
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
143-
github.com/hashicorp/go-plugin v1.6.3 h1:xgHB+ZUSYeuJi96WtxEjzi23uh7YQpznjGh0U0UUrwg=
144-
github.com/hashicorp/go-plugin v1.6.3/go.mod h1:MRobyh+Wc/nYy1V4KAXUiYfzxoYhs7V1mlH1Z7iY2h0=
145-
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
146-
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
143+
github.com/hashicorp/go-plugin v1.7.0 h1:YghfQH/0QmPNc/AZMTFE3ac8fipZyZECHdDPshfk+mA=
144+
github.com/hashicorp/go-plugin v1.7.0/go.mod h1:BExt6KEaIYx804z8k4gRzRLEvxKVb+kn0NMcihqOqb8=
145+
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
146+
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
147147
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
148148
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
149149
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
@@ -198,8 +198,8 @@ github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0f
198198
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
199199
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
200200
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
201-
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
202-
github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo=
201+
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
202+
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
203203
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
204204
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
205205
github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4=
@@ -272,8 +272,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
272272
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
273273
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
274274
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
275-
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
276-
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
275+
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
276+
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
277277
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
278278
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
279279
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=

pkg/loop/internal/test/logger_loop.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package test
33
import (
44
"context"
55
"errors"
6+
"strconv"
67
"time"
78

89
"github.com/hashicorp/go-plugin"
@@ -24,6 +25,27 @@ const (
2425
DEBUG
2526
)
2627

28+
func FormatLevel(l int) string {
29+
switch l {
30+
case PANIC:
31+
return "panic"
32+
case FATAL:
33+
return "fatal"
34+
case CRITICAL:
35+
return "critical"
36+
case ERROR:
37+
return "error"
38+
case INFO:
39+
return "info"
40+
case WARN:
41+
return "warn"
42+
case DEBUG:
43+
return "debug"
44+
default:
45+
return "unknown-" + strconv.Itoa(l)
46+
}
47+
}
48+
2749
// NOTE: This is part of the test package because it needs to be imported by the test binary at `./internal/test/cmd`
2850
// as well as the test at `./pkg/loop/logger_loop_test.go`
2951
type GRPCPluginLoggerTest struct {

pkg/loop/logger.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ func parseJSON(input string) (*logMessage, error) {
114114
return entry, nil
115115
}
116116

117-
// logDebug will parse msg and figure out if it's a panic, fatal or critical log message, this is done here because the hashicorp plugin will push any
118-
// unrecognizable message from stderr as a debug statement
119-
func logDebug(msg string, l logger.SugaredLogger, args ...interface{}) {
117+
// maybeCritical recognizes panic, fatal or critical log message, and logs them again at critical level.
118+
func maybeCritical(msg string, l logger.SugaredLogger, args ...interface{}) {
120119
if strings.HasPrefix(msg, "panic:") {
121120
l.Criticalw(fmt.Sprintf("[PANIC] %s", msg), args...)
122121
} else if log, err := parseJSON(msg); err == nil {
@@ -125,11 +124,7 @@ func logDebug(msg string, l logger.SugaredLogger, args ...interface{}) {
125124
l.Criticalw(fmt.Sprintf("[FATAL] %s", log.Message), flattenExtraArgs(log)...)
126125
case "critical", "dpanic":
127126
l.Criticalw(log.Message, flattenExtraArgs(log)...)
128-
default:
129-
l.Debugw(log.Message, flattenExtraArgs(log)...)
130127
}
131-
} else {
132-
l.Debugw(msg, args...)
133128
}
134129
}
135130

@@ -150,12 +145,14 @@ func (h *hclSinkAdapter) Accept(_ string, level hclog.Level, msg string, args ..
150145
case hclog.Trace:
151146
l.Debugw(msg, args...)
152147
case hclog.Debug:
153-
logDebug(msg, l, args...)
148+
maybeCritical(msg, l, args...) // panic/fatal/critical used to come through as stderr/out which maps to debug
149+
l.Debugw(msg, args...)
154150
case hclog.Info:
155151
l.Infow(msg, args...)
156152
case hclog.Warn:
157153
l.Warnw(msg, args...)
158154
case hclog.Error:
155+
maybeCritical(msg, l, args...) // as of v1.7.0, panic/fatal errors are send at error level
159156
l.Errorw(msg, args...)
160157
}
161158
}

pkg/loop/logger_loop_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func TestHCLogLoggerPanic(t *testing.T) {
1717
lggr, ol := logger.TestObservedSugared(t, zapcore.DebugLevel)
1818

1919
type testCase struct {
20-
name string
2120
level int
2221
expectedMessage string
2322
expectedCustomKey string
@@ -77,7 +76,7 @@ func TestHCLogLoggerPanic(t *testing.T) {
7776
}
7877

7978
for _, tt := range tests {
80-
t.Run(tt.name, func(t *testing.T) {
79+
t.Run(test.FormatLevel(tt.level), func(t *testing.T) {
8180
loggerTest := &test.GRPCPluginLoggerTest{SugaredLogger: lggr}
8281
cc := loggerTest.ClientConfig()
8382
cc.Cmd = NewHelperProcessCommand(test.PluginLoggerTestName, false, tt.level)

0 commit comments

Comments
 (0)