diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3345b95..b4cd900 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,12 @@ version: 2 updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "gomod: " + - package-ecosystem: "github-actions" directory: "/" schedule: @@ -8,8 +15,8 @@ updates: prefix: "workflows: " - package-ecosystem: "docker" - directory: "/" + directory: "/testdata" schedule: - interval: "weekly" + interval: "weekly" commit-message: prefix: "dockerfile: " diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ba6b5f4..06185d4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,13 +35,13 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.21" + go-version: "1.22" - name: Go mod download run: go mod download - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ secrets.CI_USERNAME }} @@ -77,7 +77,7 @@ jobs: - name: Upload coverage to Codecov if: ${{ github.event_name != 'pull_request' }} - uses: codecov/codecov-action@v4.4.1 + uses: codecov/codecov-action@v4 with: file: ./coverage.out flags: ${{ runner.os }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b39c86e..d624216 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -62,5 +62,17 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install cmetrics + env: + TARGETARCH: amd64 + CMETRICS_VERSION: "0.9.0" + CMETRICS_RELEASE: v0.9.0 + run: | + wget https://github.com/fluent/cmetrics/releases/download/${CMETRICS_RELEASE}/cmetrics_${CMETRICS_VERSION}_${TARGETARCH}-headers.deb + wget https://github.com/fluent/cmetrics/releases/download/${CMETRICS_RELEASE}/cmetrics_${CMETRICS_VERSION}_${TARGETARCH}.deb + sudo dpkg -i *.deb + rm *.deb + shell: bash + - name: golangci-lint - uses: reviewdog/action-golangci-lint@v2 \ No newline at end of file + uses: reviewdog/action-golangci-lint@v2 diff --git a/.golangci.yml b/.golangci.yml index 4dc2372..02333d8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,10 +15,11 @@ linters-settings: gocyclo: min-complexity: 25 govet: - check-shadowing: true + shadow: + strict: true misspell: locale: US - gomnd: + mnd: ignored-numbers: - 2 #used for word splitting. gocognit: @@ -34,16 +35,13 @@ linters: # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint disable-all: true enable: - - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - typecheck - unused - - varcheck - bodyclose - dupl - exportloopref @@ -57,10 +55,9 @@ linters: - godot - gofumpt - revive - - gomnd + - mnd - goprintffuncname - gosec - - ifshort - misspell - noctx - nolintlint @@ -75,16 +72,16 @@ linters: issues: exclude-use-default: false exclude-rules: - - linters: - - funlen - - stylecheck - - gocyclo - - gocognit - - revive - - dupl - - goconst - - errcheck - - bodyclose - - gomnd - - thelper - path: '.*test.*.go' + - linters: + - funlen + - stylecheck + - gocyclo + - gocognit + - revive + - dupl + - goconst + - errcheck + - bodyclose + - mnd + - thelper + path: ".*test.*.go" diff --git a/cshared.go b/cshared.go index ec55e07..d793048 100644 --- a/cshared.go +++ b/cshared.go @@ -13,7 +13,6 @@ import ( "io" "log" "os" - "reflect" "runtime" "strconv" "strings" @@ -21,7 +20,7 @@ import ( "time" "unsafe" - "github.com/ugorji/go/codec" + "github.com/vmihailenco/msgpack/v5" cmetrics "github.com/calyptia/cmetrics-go" "github.com/calyptia/plugin/input" @@ -44,6 +43,8 @@ var ( maxBufferedMessages = defaultMaxBufferedMessages ) +// FLBPluginPreRegister - +// //export FLBPluginPreRegister func FLBPluginPreRegister(hotReloading C.int) int { if hotReloading == C.int(1) { @@ -175,7 +176,6 @@ func flbPluginReset() { } }() - once = sync.Once{} close(theChannel) theInput = nil } @@ -194,11 +194,18 @@ func testFLBPluginInputCallback() ([]byte, error) { return C.GoBytes(data, C.int(csize)), nil } +// prepareOutputFlush is a testing utility. +func prepareOutputFlush(output OutputPlugin) error { + theOutput = output + FLBPluginOutputPreRun(0) + return nil +} + // Lock used to synchronize access to theInput variable. var theInputLock sync.Mutex // prepareInputCollector is meant to prepare resources for input collectors -func prepareInputCollector(multiInstance bool) (err error) { +func prepareInputCollector(multiInstance bool) { runCtx, runCancel = context.WithCancel(context.Background()) if !multiInstance { theChannel = make(chan Message, maxBufferedMessages) @@ -218,40 +225,26 @@ func prepareInputCollector(multiInstance bool) (err error) { } go func(theChannel chan<- Message) { - err = theInput.Collect(runCtx, theChannel) + err := theInput.Collect(runCtx, theChannel) + if err != nil { + fmt.Fprintf(os.Stderr, "collect error: %v\n", err) + } }(theChannel) - for { - select { - case <-runCtx.Done(): - log.Printf("goroutine will be stopping: name=%q\n", theName) - return - } - } + <-runCtx.Done() - if err != nil { - fmt.Fprintf(os.Stderr, - "collect error: %s\n", err.Error()) - } + log.Printf("goroutine will be stopping: name=%q\n", theName) }(theChannel) - - return err } // FLBPluginInputPreRun this method gets invoked by the fluent-bit runtime, once the plugin has been -// initialised, the plugin invoked only once before executing the input callbacks. +// initialized, the plugin invoked only once before executing the input callbacks. // //export FLBPluginInputPreRun func FLBPluginInputPreRun(useHotReload C.int) int { registerWG.Wait() - var err error - err = prepareInputCollector(true) - - if err != nil { - fmt.Fprintf(os.Stderr, "run: %s\n", err) - return input.FLB_ERROR - } + prepareInputCollector(true) return input.FLB_OK } @@ -282,12 +275,7 @@ func FLBPluginInputPause() { // //export FLBPluginInputResume func FLBPluginInputResume() { - var err error - err = prepareInputCollector(true) - - if err != nil { - fmt.Fprintf(os.Stderr, "run: %s\n", err) - } + prepareInputCollector(true) } // FLBPluginOutputPreExit this method gets invoked by the fluent-bit runtime, once the plugin has been @@ -311,6 +299,8 @@ func FLBPluginOutputPreExit() { } } +// FLBPluginOutputPreRun - +// //export FLBPluginOutputPreRun func FLBPluginOutputPreRun(useHotReload C.int) int { registerWG.Wait() @@ -323,14 +313,9 @@ func FLBPluginOutputPreRun(useHotReload C.int) int { err = theOutput.Flush(runCtx, theChannel) }(runCtx) - for { - select { - case <-runCtx.Done(): - log.Printf("goroutine will be stopping: name=%q\n", theName) - return - } - } + <-runCtx.Done() + log.Printf("goroutine will be stopping: name=%q\n", theName) }(runCtx) if err != nil { @@ -342,7 +327,7 @@ func FLBPluginOutputPreRun(useHotReload C.int) int { } // FLBPluginInputCallback this method gets invoked by the fluent-bit runtime, once the plugin has been -// initialised, the plugin implementation is responsible for handling the incoming data and the context +// initialized, the plugin implementation is responsible for handling the incoming data and the context // that gets past, for long-living collectors the plugin itself should keep a running thread and fluent-bit // will not execute further callbacks. // @@ -367,12 +352,12 @@ func FLBPluginInputCallback(data *unsafe.Pointer, csize *C.size_t) int { return input.FLB_ERROR } - t := input.FLBTime{Time: msg.Time} - b, err := input.NewEncoder().Encode([]any{t, msg.Record}) + b, err := msgpack.Marshal([]any{&EventTime{msg.Time}, msg.Record}) if err != nil { - fmt.Fprintf(os.Stderr, "encode: %s\n", err) + fmt.Fprintf(os.Stderr, "msgpack marshal: %s\n", err) return input.FLB_ERROR } + buf.Grow(len(b)) buf.Write(b) case <-runCtx.Done(): @@ -415,7 +400,6 @@ func FLBPluginInputCleanupCallback(data unsafe.Pointer) int { // plugin in the pipeline, a data pointer, length and a tag are passed to the plugin interface implementation. // //export FLBPluginFlush -//nolint:funlen //ignore length requirement for this function func FLBPluginFlush(data unsafe.Pointer, clength C.int, ctag *C.char) int { initWG.Wait() @@ -438,102 +422,89 @@ func FLBPluginFlush(data unsafe.Pointer, clength C.int, ctag *C.char) int { } in := C.GoBytes(data, clength) - h := &codec.MsgpackHandle{} - err = h.SetBytesExt(reflect.TypeOf(bigEndianTime{}), 0, &bigEndianTime{}) - if err != nil { - fmt.Fprintf(os.Stderr, "big endian time bytes ext: %v\n", err) + tag := C.GoString(ctag) + if err := pluginFlush(tag, in); err != nil { + fmt.Fprintf(os.Stderr, "flush: %s\n", err) return output.FLB_ERROR } - dec := codec.NewDecoderBytes(in, h) + return output.FLB_OK +} +func pluginFlush(tag string, b []byte) error { + dec := msgpack.NewDecoder(bytes.NewReader(b)) for { select { case <-runCtx.Done(): err := runCtx.Err() if err != nil && !errors.Is(err, context.Canceled) { fmt.Fprintf(os.Stderr, "run: %s\n", err) - return output.FLB_ERROR + return fmt.Errorf("run: %w", err) } - return output.FLB_OK + return nil default: } - var entry []any - err := dec.Decode(&entry) + msg, err := decodeMsg(dec, tag) if errors.Is(err, io.EOF) { - break + return nil } if err != nil { - fmt.Fprintf(os.Stderr, "decode: %s\n", err) - return output.FLB_ERROR + return err } - slice := reflect.ValueOf(entry) - if slice.Kind() != reflect.Slice || slice.Len() < 2 { - fmt.Fprintf(os.Stderr, "unexpected entry length: %d\n", slice.Len()) - return output.FLB_ERROR - } + theChannel <- msg + } +} - var t time.Time - ts := slice.Index(0).Interface() - switch ft := ts.(type) { - case bigEndianTime: - t = time.Time(ft) - case []interface{}: - s := reflect.ValueOf(ft) - st := s.Index(0).Interface() - ty := st.(bigEndianTime) - t = time.Time(ty) - default: - fmt.Fprintf(os.Stderr, "unexpected entry time type: %T\n", entry[0]) - return output.FLB_ERROR +// decodeMsg should be called with an already initialized decoder. +func decodeMsg(dec *msgpack.Decoder, tag string) (Message, error) { + var out Message + + var entry []msgpack.RawMessage + err := dec.Decode(&entry) + if errors.Is(err, io.EOF) { + return out, err + } + + if err != nil { + return out, fmt.Errorf("msgpack unmarshal: %w", err) + } + + if l := len(entry); l < 2 { + return out, fmt.Errorf("msgpack unmarshal: expected 2 elements, got %d", l) + } + + eventTime := &EventTime{} + if err := msgpack.Unmarshal(entry[0], &eventTime); err != nil { + var eventWithMetadata []msgpack.RawMessage // for Fluent Bit V2 metadata type of format + if err := msgpack.Unmarshal(entry[0], &eventWithMetadata); err != nil { + return out, fmt.Errorf("msgpack unmarshal event with metadata: %w", err) } - data := slice.Index(1) - recVal := data.Interface().(map[interface{}]interface{}) - - var rec map[string]string - if d := len(recVal); d != 0 { - rec = make(map[string]string, d) - for k, v := range recVal { - key, ok := k.(string) - if !ok { - fmt.Fprintf(os.Stderr, "unexpected record key type: %T\n", k) - return output.FLB_ERROR - } - - var val string - switch tv := v.(type) { - case []uint8: - val = string(tv) - case uint64: - val = strconv.FormatUint(tv, 10) - case int64: - val = strconv.FormatInt(tv, 10) - case bool: - val = strconv.FormatBool(tv) - default: - fmt.Fprintf(os.Stderr, "unexpected record value type: %T\n", v) - return output.FLB_ERROR - } - - rec[key] = val - } + if len(eventWithMetadata) < 1 { + return out, fmt.Errorf("msgpack unmarshal event time with metadata: expected 1 element, got %d", len(eventWithMetadata)) } - tag := C.GoString(ctag) - // C.free(unsafe.Pointer(ctag)) + if err := msgpack.Unmarshal(eventWithMetadata[0], &eventTime); err != nil { + return out, fmt.Errorf("msgpack unmarshal event time with metadata: %w", err) + } - theChannel <- Message{Time: t, Record: rec, tag: &tag} + return out, fmt.Errorf("msgpack unmarshal event time: %w", err) + } - // C.free(data) - // C.free(unsafe.Pointer(&clength)) + var record map[string]any + if err := msgpack.Unmarshal(entry[1], &record); err != nil { + return out, fmt.Errorf("msgpack unmarshal event record: %w", err) } - return output.FLB_OK + out.Time = eventTime.Time.UTC() + out.Record = record + out.tag = &tag + + return out, nil } // FLBPluginExit method is invoked once the plugin instance is exited from the fluent-bit context. diff --git a/cshared_test.go b/cshared_test.go index 86d294f..50e0e6c 100644 --- a/cshared_test.go +++ b/cshared_test.go @@ -1,15 +1,22 @@ package plugin import ( + "bytes" "context" + "errors" "fmt" + "io" + "reflect" "sync" "sync/atomic" "testing" "time" "unsafe" - "github.com/calyptia/plugin/output" + "github.com/alecthomas/assert/v2" + "github.com/vmihailenco/msgpack/v5" + + "github.com/calyptia/plugin/metric" ) type testPluginInputCallbackCtrlC struct{} @@ -43,11 +50,7 @@ func TestInputCallbackCtrlC(t *testing.T) { ptr := unsafe.Pointer(nil) // prepare channel for input explicitly. - err := prepareInputCollector(false) - if err != nil { - t.Fail() - return - } + prepareInputCollector(false) go func() { FLBPluginInputCallback(&ptr, nil) @@ -94,10 +97,7 @@ func TestInputCallbackDangle(t *testing.T) { ptr := unsafe.Pointer(nil) // prepare channel for input explicitly. - err := prepareInputCollector(false) - if err != nil { - t.Fail() - } + prepareInputCollector(false) go func() { t := time.NewTicker(collectInterval) @@ -168,11 +168,7 @@ func TestInputCallbackInfinite(t *testing.T) { ptr := unsafe.Pointer(nil) // prepare channel for input explicitly. - err := prepareInputCollector(false) - if err != nil { - t.Fail() - return - } + prepareInputCollector(false) go func() { t := time.NewTicker(collectInterval) @@ -254,11 +250,7 @@ func TestInputCallbackLatency(t *testing.T) { cmsg := make(chan []byte) // prepare channel for input explicitly. - err := prepareInputCollector(false) - if err != nil { - t.Fail() - return - } + prepareInputCollector(false) go func() { t := time.NewTicker(collectInterval) @@ -294,30 +286,22 @@ func TestInputCallbackLatency(t *testing.T) { for { select { case buf := <-cmsg: - dec := output.NewByteDecoder(buf) - if dec == nil { - t.Fatal("dec is nil") - } - + dec := msgpack.NewDecoder(bytes.NewReader(buf)) for { - ret, timestamp, _ := output.GetRecord(dec) - if ret == -1 { + msg, err := decodeMsg(dec, "test-tag") + if errors.Is(err, io.EOF) { break } - if ret < 0 { - t.Fatalf("ret is negative: %d", ret) + + if err != nil { + t.Fatalf("decode error: %v", err) } msgs++ - ts, ok := timestamp.(output.FLBTime) - if !ok { - t.Fatal() - } - - if time.Since(ts.Time) > time.Millisecond*5 { + if time.Since(msg.Time) > time.Millisecond*5 { t.Errorf("latency too high: %fms", - float64(time.Since(ts.Time)/time.Millisecond)) + float64(time.Since(msg.Time)/time.Millisecond)) } } case <-timeout.C: @@ -334,9 +318,11 @@ func TestInputCallbackLatency(t *testing.T) { type testInputCallbackInfiniteConcurrent struct{} -var concurrentWait sync.WaitGroup -var concurrentCountStart atomic.Int64 -var concurrentCountFinish atomic.Int64 +var ( + concurrentWait sync.WaitGroup + concurrentCountStart atomic.Int64 + concurrentCountFinish atomic.Int64 +) func (t testInputCallbackInfiniteConcurrent) Init(ctx context.Context, fbit *Fluentbit) error { return nil @@ -363,12 +349,9 @@ func (t testInputCallbackInfiniteConcurrent) Collect(ctx context.Context, ch cha } // for tests to correctly pass our infinite loop needs // to return once the context has been finished. - for { - select { - case <-ctx.Done(): - return nil - } - } + <-ctx.Done() + + return nil } // TestInputCallbackInfiniteConcurrent is meant to make sure we do not @@ -385,10 +368,7 @@ func TestInputCallbackInfiniteConcurrent(t *testing.T) { concurrentWait.Add(64) // prepare channel for input explicitly. - err := prepareInputCollector(false) - if err != nil { - t.Fail() - } + prepareInputCollector(false) go func(cstarted chan bool) { ticker := time.NewTicker(time.Second * 1) @@ -427,3 +407,209 @@ func TestInputCallbackInfiniteConcurrent(t *testing.T) { concurrentCountFinish.Load()) } } + +type testOutputHandlerReflect struct { + param string + flushCounter metric.Counter + log Logger + Test *testing.T + Check func(t *testing.T, msg Message) error +} + +func (plug *testOutputHandlerReflect) Init(ctx context.Context, fbit *Fluentbit) error { + plug.flushCounter = fbit.Metrics.NewCounter("flush_total", "Total number of flushes", "gstdout") + plug.param = fbit.Conf.String("param") + plug.log = fbit.Logger + + return nil +} + +func (plug *testOutputHandlerReflect) Flush(ctx context.Context, ch <-chan Message) error { + plug.Test.Helper() + count := 0 + + for { + select { + case msg := <-ch: + rec := reflect.ValueOf(msg.Record) + if rec.Kind() != reflect.Map { + return fmt.Errorf("incorrect record type in flush") + } + + if plug.Check != nil { + if err := plug.Check(plug.Test, msg); err != nil { + return err + } + } + count++ + case <-ctx.Done(): + if count <= 0 { + return fmt.Errorf("no records flushed") + } + return nil + } + } +} + +type testOutputHandlerMapString struct { + param string + flushCounter metric.Counter + log Logger +} + +func (plug *testOutputHandlerMapString) Init(ctx context.Context, fbit *Fluentbit) error { + plug.flushCounter = fbit.Metrics.NewCounter("flush_total", "Total number of flushes", "gstdout") + plug.param = fbit.Conf.String("param") + plug.log = fbit.Logger + + return nil +} + +func (plug *testOutputHandlerMapString) Flush(ctx context.Context, ch <-chan Message) error { + count := 0 + + for { + select { + case msg := <-ch: + record, ok := msg.Record.(map[string]interface{}) + if !ok { + return fmt.Errorf("unable to convert record to map[string]") + } + for _, value := range record { + _, ok := value.(string) + if !ok { + return fmt.Errorf("unable to convert value") + } + } + count++ + case <-ctx.Done(): + if count <= 0 { + return fmt.Errorf("no records flushed") + } + return nil + } + } +} + +// TestOutput is a simple output test. It also shows which format of records +// we currently support and how they should be handled. Feel free to use this +// code as an example of how to implement the Flush receive for output plugins. +// +// At the moment all Message.Records will be sent as a `map[string]interface{}`. +// Older plugins will have to do as testOutputHandlerMapString.Flush does +// and cast the actual value as a string. +func TestOutputSimulated(t *testing.T) { + var wg sync.WaitGroup + ctxt, cancel := context.WithCancel(context.Background()) + ch := make(chan Message) + tag := "tag" + + outputReflect := testOutputHandlerReflect{Test: t} + + wg.Add(1) + go func(ctxt context.Context, wg *sync.WaitGroup, ch <-chan Message) { + err := outputReflect.Flush(ctxt, ch) + if err != nil { + t.Error(err) + } + wg.Done() + }(ctxt, &wg, ch) + + ch <- Message{ + Time: time.Now(), + Record: map[string]interface{}{ + "foo": "bar", + "bar": "1", + }, + tag: &tag, + } + + cancel() + wg.Wait() + wg = sync.WaitGroup{} + ctxt, cancel = context.WithCancel(context.Background()) + + outputMapString := testOutputHandlerMapString{} + + wg.Add(1) + go func(ctxt context.Context, wg *sync.WaitGroup, ch <-chan Message) { + err := outputMapString.Flush(ctxt, ch) + if err != nil { + t.Error(err) + t.Fail() + } + wg.Done() + }(ctxt, &wg, ch) + + ch <- Message{ + Time: time.Now(), + Record: map[string]interface{}{ + "foo": "bar", + "foobar": "1", + }, + tag: &tag, + } + + cancel() + wg.Wait() + close(ch) +} + +func TestOutputFlush(t *testing.T) { + var wg sync.WaitGroup + + now := time.Now().UTC() + + out := testOutputHandlerReflect{ + Test: t, + Check: func(t *testing.T, msg Message) error { + defer wg.Done() + + assert.Equal(t, now, msg.Time) + + record := assertType[map[string]any](t, msg.Record) + + foo := assertType[string](t, record["foo"]) + assert.Equal(t, "bar", foo) + + bar := assertType[int8](t, record["bar"]) + assert.Equal(t, 3, bar) + + foobar := assertType[float64](t, record["foobar"]) + assert.Equal(t, 1.337, foobar) + + return nil + }, + } + _ = prepareOutputFlush(&out) + + msg := Message{ + Time: now, + Record: map[string]any{ + "foo": "bar", + "bar": 3, + "foobar": 1.337, + }, + } + + b, err := msgpack.Marshal([]any{ + &EventTime{msg.Time}, + msg.Record, + }) + assert.NoError(t, err) + + wg.Add(1) + assert.NoError(t, pluginFlush("foobar", b)) + wg.Wait() +} + +func assertType[T any](tb testing.TB, got any) T { + tb.Helper() + + var want T + + v, ok := got.(T) + assert.True(tb, ok, "Expected types to be equal:\n-%T\n+%T", want, got) + + return v +} diff --git a/go.mod b/go.mod index 320ccb6..7ae8bb8 100644 --- a/go.mod +++ b/go.mod @@ -1,47 +1,50 @@ module github.com/calyptia/plugin -go 1.21.0 +go 1.22.3 + +replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16 require ( - github.com/alecthomas/assert/v2 v2.3.0 + github.com/alecthomas/assert/v2 v2.9.0 github.com/calyptia/cmetrics-go v0.1.7 - github.com/calyptia/go-fluentbit-config/v2 v2.1.0 + github.com/calyptia/go-fluentbit-config/v2 v2.2.0 github.com/ory/dockertest/v3 v3.10.0 - github.com/stretchr/testify v1.8.4 - github.com/ugorji/go/codec v1.2.11 + github.com/stretchr/testify v1.9.0 + github.com/ugorji/go/codec v1.2.12 + github.com/vmihailenco/msgpack/v5 v5.4.1 ) require ( - github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect - github.com/Microsoft/go-winio v0.6.0 // indirect + dario.cat/mergo v1.0.0 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect - github.com/alecthomas/repr v0.2.0 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // indirect - github.com/containerd/continuity v0.3.0 // indirect + github.com/alecthomas/repr v0.4.0 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/containerd/continuity v0.4.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/docker/cli v20.10.17+incompatible // indirect - github.com/docker/docker v20.10.7+incompatible // indirect - github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-units v0.4.0 // indirect + github.com/docker/cli v26.1.3+incompatible // indirect + github.com/docker/docker v26.1.3+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect - github.com/imdario/mergo v0.3.12 // indirect - github.com/mitchellh/mapstructure v1.4.1 // indirect - github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/term v0.5.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/opencontainers/runc v1.1.5 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect + github.com/opencontainers/runc v1.1.12 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect - golang.org/x/mod v0.11.0 // indirect - golang.org/x/sys v0.7.0 // indirect - golang.org/x/tools v0.7.0 // indirect - gopkg.in/yaml.v2 v2.3.0 // indirect + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/sys v0.20.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index df332a1..1961c00 100644 --- a/go.sum +++ b/go.sum @@ -1,110 +1,86 @@ -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= -github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= -github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= -github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= -github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/assert/v2 v2.9.0 h1:ZcLG8ccMEtlMLkLW4gwGpBWBb0N8MUCmsy1lYBVd1xQ= +github.com/alecthomas/assert/v2 v2.9.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/calyptia/cmetrics-go v0.1.7 h1:A4kEFuFqVuWzytIbbey9KivHi0GQVjOkE2JJkdRbQ2U= github.com/calyptia/cmetrics-go v0.1.7/go.mod h1:K1IEPgICDtD4mJW7RVhfG4BkCywnjCdYZwbKs0jSw/U= -github.com/calyptia/go-fluentbit-config/v2 v2.1.0 h1:DWV0N4DO9vJX9I1Y3tdYi0P7A1xa+rqGsqLG06tUmEc= -github.com/calyptia/go-fluentbit-config/v2 v2.1.0/go.mod h1:bmPxFuwb7//+pLPSvLbLxS/fYesxysQtiSksElDVszQ= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= -github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= -github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= -github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= -github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/calyptia/go-fluentbit-config/v2 v2.2.0 h1:vBILRvCCJdZMSe5PhEWGrchzT01R20L9QR2kCSqzHsY= +github.com/calyptia/go-fluentbit-config/v2 v2.2.0/go.mod h1:gHrbMJ2HJdoufaJy+PWqUoju5JRCulQcFD+BDJLqwWQ= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= +github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/cli v20.10.17+incompatible h1:eO2KS7ZFeov5UJeaDmIs1NFEDRf32PaqRpvoEkKBy5M= -github.com/docker/cli v20.10.17+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/docker v20.10.7+incompatible h1:Z6O9Nhsjv+ayUEeI1IojKbYcsGdgYSNqxe1s2MYzUhQ= -github.com/docker/docker v20.10.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/docker/cli v26.1.3+incompatible h1:bUpXT/N0kDE3VUHI2r5VMsYQgi38kYuoC0oL9yt3lqc= +github.com/docker/cli v26.1.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/docker v26.1.3+incompatible h1:lLCzRbrVZrljpVNobJu1J2FHk8V0s4BawoZippkc+xo= +github.com/docker/docker v26.1.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= -github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/influxdata/influxdb v1.9.5 h1:4O7AC5jOA9RoqtDuD2rysXbumcEwaqWlWXmwuyK+a2s= github.com/influxdata/influxdb v1.9.5/go.mod h1:4uPVvcry9KWQVWLxyT9641qpkRXUBN+xa0MJFFNNLKo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2 h1:hRGSmZu7j271trc9sneMrpOW7GN5ngLm8YUZIPzf394= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= -github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 h1:rzf0wL0CHVc8CEsgyygG0Mn9CNCCPZqOPaz8RiiHYQk= -github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= -github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= -github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v1.1.5 h1:L44KXEpKmfWDcS02aeGm8QNTFXTo2D+8MYGDIJ/GDEs= -github.com/opencontainers/runc v1.1.5/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= -github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= +github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= +github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= +github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss= +github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8= github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4= github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= -github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= @@ -114,60 +90,40 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= -golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= diff --git a/input/encoder.go b/input/encoder.go index 13d9fa9..70c3f6a 100644 --- a/input/encoder.go +++ b/input/encoder.go @@ -17,8 +17,9 @@ package input +import "C" + import ( - "C" "encoding/binary" "reflect" "time" @@ -26,6 +27,8 @@ import ( "github.com/ugorji/go/codec" ) +const flbTimeBytesLen = 8 + type FLBEncoder struct { handle *codec.MsgpackHandle mpenc *codec.Encoder @@ -36,9 +39,9 @@ type FLBTime struct { } func (f FLBTime) WriteExt(i interface{}) []byte { - bs := make([]byte, 8) + bs := make([]byte, flbTimeBytesLen) - tm := i.(*FLBTime) + tm, _ := i.(*FLBTime) utc := tm.UTC() sec := utc.Unix() @@ -50,7 +53,7 @@ func (f FLBTime) WriteExt(i interface{}) []byte { return bs } -func (f FLBTime) ReadExt(i interface{}, b []byte) { +func (f FLBTime) ReadExt(interface{}, []byte) { panic("unsupported") } diff --git a/input/input.go b/input/input.go index a08e390..f503733 100644 --- a/input/input.go +++ b/input/input.go @@ -45,13 +45,13 @@ const ( FLB_LOG_DEBUG = C.FLB_LOG_DEBUG ) -// Local type to define a plugin definition type ( + // FLBPluginProxyDef local type. FLBPluginProxyDef C.struct_flb_plugin_proxy_def FLBInPlugin C.struct_flbgo_input_plugin ) -// When the FLBPluginInit is triggered by Fluent Bit, a plugin context +// FLBPluginRegister when the FLBPluginInit is triggered by Fluent Bit, a plugin context // is passed and the next step is to invoke this FLBPluginRegister() function // to fill the required information: type, proxy type, flags name and // description. @@ -65,7 +65,7 @@ func FLBPluginRegister(def unsafe.Pointer, name, desc string) int { return 0 } -// Release resources allocated by the plugin initialization +// FLBPluginUnregister release resources allocated by the plugin initialization func FLBPluginUnregister(def unsafe.Pointer) { p := (*FLBPluginProxyDef)(def) C.free(unsafe.Pointer(p.name)) @@ -80,8 +80,7 @@ func FLBPluginConfigKey(plugin unsafe.Pointer, key string) string { } func FLBPluginGetCMetricsContext(plugin unsafe.Pointer) (*cmetrics.Context, error) { - ctx := C.input_get_cmt_instance(plugin) - cmt := unsafe.Pointer(ctx) + cmt := C.input_get_cmt_instance(plugin) return cmetrics.NewContextFromCMTPointer(cmt) } diff --git a/metric/cmetric/counter.go b/metric/cmetric/counter.go index 368db80..15a7c13 100644 --- a/metric/cmetric/counter.go +++ b/metric/cmetric/counter.go @@ -21,4 +21,4 @@ func (c *Counter) Add(delta float64, labelValues ...string) { type noopCounter struct{} -func (n noopCounter) Add(delta float64, labelValues ...string) {} +func (n noopCounter) Add(float64, ...string) {} diff --git a/metric/cmetric/gauge.go b/metric/cmetric/gauge.go index 6601b00..45971bd 100644 --- a/metric/cmetric/gauge.go +++ b/metric/cmetric/gauge.go @@ -28,5 +28,5 @@ func (c *Gauge) Set(value float64, labelValues ...string) { type noopGauge struct{} -func (n noopGauge) Add(delta float64, labelValues ...string) {} -func (n noopGauge) Set(value float64, labelValues ...string) {} +func (n noopGauge) Add(float64, ...string) {} +func (n noopGauge) Set(float64, ...string) {} diff --git a/output/decoder.go b/output/decoder.go index aa9e508..d405fec 100644 --- a/output/decoder.go +++ b/output/decoder.go @@ -17,8 +17,9 @@ package output +import "C" + import ( - "C" "encoding/binary" "reflect" "time" @@ -41,7 +42,7 @@ func (f FLBTime) WriteExt(interface{}) []byte { } func (f FLBTime) ReadExt(i interface{}, b []byte) { - out := i.(*FLBTime) + out, _ := i.(*FLBTime) sec := binary.BigEndian.Uint32(b) usec := binary.BigEndian.Uint32(b[4:]) out.Time = time.Unix(int64(sec), int64(usec)) @@ -112,7 +113,7 @@ func GetRecord(dec *FLBDecoder) (ret int, ts interface{}, rec map[interface{}]in } data := slice.Index(1) - map_data := data.Interface().(map[interface{}]interface{}) + md, _ := data.Interface().(map[any]any) - return 0, t, map_data + return 0, t, md } diff --git a/output/output.go b/output/output.go index 81453c9..babc048 100644 --- a/output/output.go +++ b/output/output.go @@ -46,13 +46,13 @@ const ( FLB_LOG_DEBUG = C.FLB_LOG_DEBUG ) -// Local type to define a plugin definition type ( + // FLBPluginProxyDef local type. FLBPluginProxyDef C.struct_flb_plugin_proxy_def FLBOutPlugin C.struct_flbgo_output_plugin ) -// When the FLBPluginInit is triggered by Fluent Bit, a plugin context +// FLBPluginRegister when the FLBPluginInit is triggered by Fluent Bit, a plugin context // is passed and the next step is to invoke this FLBPluginRegister() function // to fill the required information: type, proxy type, flags name and // description. @@ -66,7 +66,7 @@ func FLBPluginRegister(def unsafe.Pointer, name, desc string) int { return 0 } -// Release resources allocated by the plugin initialization +// FLBPluginUnregister release resources allocated by the plugin initialization func FLBPluginUnregister(def unsafe.Pointer) { p := (*FLBPluginProxyDef)(def) C.free(unsafe.Pointer(p.name)) @@ -103,8 +103,7 @@ func FLBPluginGetContext(proxyCtx unsafe.Pointer) interface{} { } func FLBPluginGetCMetricsContext(plugin unsafe.Pointer) (*cmetrics.Context, error) { - ctx := C.output_get_cmt_instance(plugin) - cmt := unsafe.Pointer(ctx) + cmt := C.output_get_cmt_instance(plugin) return cmetrics.NewContextFromCMTPointer(cmt) } diff --git a/plugin.go b/plugin.go index 5c51fba..44b75d8 100644 --- a/plugin.go +++ b/plugin.go @@ -24,7 +24,6 @@ var ( var ( registerWG sync.WaitGroup initWG sync.WaitGroup - once sync.Once runCtx context.Context runCancel context.CancelFunc theChannel chan Message @@ -75,7 +74,8 @@ type Metrics interface { // Message struct to store a fluent-bit message this is collected (input) or flushed (output) // from a plugin implementation. type Message struct { - Time time.Time + Time time.Time + // Record should be a map or a struct. Record any tag *string } diff --git a/plugin_test.go b/plugin_test.go index be513fa..c11d646 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -33,7 +33,6 @@ func testPlugin(t *testing.T, pool *dockertest.Pool) { pwd, err := os.Getwd() assert.NoError(t, err) - //nolint:gosec //required filesystem access to read fixture data. f, err := os.Create(filepath.Join(t.TempDir(), "output.txt")) assert.NoError(t, err) @@ -143,8 +142,12 @@ func testPlugin(t *testing.T, pool *dockertest.Pool) { Message string `json:"message"` TmplOut string `json:"tmpl_out"` MultilineSplit []string `json:"multiline_split"` + Time string `json:"-"` } + t.Log(line) + + defer cancel() err := json.Unmarshal([]byte(line), &got) assert.NoError(t, err) assert.Equal(t, "bar", got.Foo) @@ -152,9 +155,12 @@ func testPlugin(t *testing.T, pool *dockertest.Pool) { assert.Equal(t, "inside double quotes\nnew line", got.TmplOut) assert.Equal(t, []string{"foo", "bar"}, got.MultilineSplit) + // TODO: Fix time.Time printing in fluent-bit. + // Right now it is getting some bytes "\x66\x4e\x3c\x49" + // assert.Equal(t, "2024-05-21T18:41:13Z", got.Time) + t.Logf("took %s", time.Since(start)) - cancel() return } } diff --git a/testdata/Dockerfile b/testdata/Dockerfile index c82eb60..29eb943 100644 --- a/testdata/Dockerfile +++ b/testdata/Dockerfile @@ -1,12 +1,12 @@ -FROM golang:1.21 AS builder +FROM golang:1.22 AS builder ARG TARGETPLATFORM=linux/amd64 ARG BUILDPLATFORM=linux/amd64 # These should change very infrequently and are coupled tightly -ARG CMETRICS_VERSION=0.6.0 +ARG CMETRICS_VERSION=0.9.0 ENV CMETRICS_VERSION=${CMETRICS_VERSION} -ARG CMETRICS_RELEASE=v0.6.0 +ARG CMETRICS_RELEASE=v0.9.0 ENV CMETRICS_RELEASE=${CMETRICS_RELEASE} ARG PACKAGEARCH=amd64 diff --git a/testdata/fluent-bit.conf b/testdata/fluent-bit.conf index 18aeacb..6ad4ddf 100644 --- a/testdata/fluent-bit.conf +++ b/testdata/fluent-bit.conf @@ -1,14 +1,15 @@ [SERVICE] - flush 1 - log_level info - plugins_file /fluent-bit/etc/plugins.conf + flush 1 + log_level debug + plugins_file /fluent-bit/etc/plugins.conf [INPUT] - Name go-test-input-plugin - Tag test-input - foo bar - tmpl "{{print \"inside double quotes\"}}\nnew line" + Name go-test-input-plugin + Tag test-input + foo bar + tmpl "{{print \"inside double quotes\"}}\nnew line" multiline foo\nbar + # time 2024-05-22T18:41:13Z # [OUTPUT] # Name go-test-output-plugin @@ -17,8 +18,13 @@ # Match * [OUTPUT] - Name file - match * - path /fluent-bit/etc - file output.txt + Name stdout + match * + format json_lines + +[OUTPUT] + Name file + match * + path /fluent-bit/etc + file output.txt format plain diff --git a/testdata/input/input.go b/testdata/input/input.go index 74680e2..d3a579c 100644 --- a/testdata/input/input.go +++ b/testdata/input/input.go @@ -19,6 +19,7 @@ type inputPlugin struct { foo string tmpl *template.Template multilineSplit []string + // time time.Time collectCounter metric.Counter log plugin.Logger } @@ -32,6 +33,11 @@ func (plug *inputPlugin) Init(ctx context.Context, fbit *plugin.Fluentbit) error plug.foo = fbit.Conf.String("foo") plug.multilineSplit = strings.Split(fbit.Conf.String("multiline"), "\n") + // plug.time, err = time.Parse(time.RFC3339, fbit.Conf.String("time")) + // if err != nil { + // return fmt.Errorf("parse time as RFC3339: %w", err) + // } + plug.collectCounter = fbit.Metrics.NewCounter("collect_total", "Total number of collects", "go-test-input-plugin") plug.log = fbit.Logger return nil @@ -68,6 +74,7 @@ func (plug inputPlugin) Collect(ctx context.Context, ch chan<- plugin.Message) e "foo": plug.foo, "tmpl_out": buff.String(), "multiline_split": plug.multilineSplit, + // "time": plug.time, }, } } diff --git a/time.go b/time.go index 96cb7e7..e2da8a5 100644 --- a/time.go +++ b/time.go @@ -5,47 +5,37 @@ import ( "fmt" "time" - "github.com/ugorji/go/codec" + "github.com/vmihailenco/msgpack/v5" ) -const fFimeSize = 8 +const eventTimeBytesLen = 8 -var _ codec.BytesExt = (*bigEndianTime)(nil) - -// bigEndianTime implements codec.BytesExt to handle custom (de)serialization of types to/from []byte. -// It is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types. -type bigEndianTime time.Time - -func (*bigEndianTime) WriteExt(v interface{}) []byte { - ft, ok := v.(*bigEndianTime) - if !ok { - panic(fmt.Sprintf("unexpected big endian time type %T", v)) - } - - t := time.Time(*ft).UTC() - sec := t.Unix() - nsec := t.UnixNano() +type EventTime struct { + time.Time +} - b := make([]byte, fFimeSize) - binary.BigEndian.PutUint32(b, uint32(sec)) - binary.BigEndian.PutUint32(b[4:], uint32(nsec)) +var ( + _ msgpack.Marshaler = (*EventTime)(nil) + _ msgpack.Unmarshaler = (*EventTime)(nil) +) - return b +func init() { + msgpack.RegisterExt(0, (*EventTime)(nil)) } -func (*bigEndianTime) ReadExt(dst interface{}, src []byte) { - ft, ok := dst.(*bigEndianTime) - if !ok { - panic(fmt.Sprintf("unexpected big endian time type %T", dst)) - } +func (tm *EventTime) MarshalMsgpack() ([]byte, error) { + b := make([]byte, eventTimeBytesLen) + binary.BigEndian.PutUint32(b, uint32(tm.Unix())) + binary.BigEndian.PutUint32(b[4:], uint32(tm.Nanosecond())) + return b, nil +} - if len(src) != fFimeSize { - panic(fmt.Sprintf("unexpected big endian time length %d", len(src))) +func (tm *EventTime) UnmarshalMsgpack(b []byte) error { + if len(b) != eventTimeBytesLen { + return fmt.Errorf("invalid data length: got %d, wanted %d", len(b), eventTimeBytesLen) } - - sec := binary.BigEndian.Uint32(src) - nsec := binary.BigEndian.Uint32(src[4:]) - - t := time.Unix(int64(sec), int64(nsec)).UTC() - *ft = bigEndianTime(t) + sec := binary.BigEndian.Uint32(b) + usec := binary.BigEndian.Uint32(b[4:]) + tm.Time = time.Unix(int64(sec), int64(usec)) + return nil }