Skip to content

Commit

Permalink
Merge pull request #37 from calyptia/unquote
Browse files Browse the repository at this point in the history
Fix quotes for configuration options
  • Loading branch information
niedbalski authored Aug 28, 2023
2 parents 785e549 + 50d3f66 commit da513de
Show file tree
Hide file tree
Showing 20 changed files with 2,639 additions and 217 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [main]
tags:
- 'v*'
- "v*"
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -33,23 +33,25 @@ jobs:
TARGETARCH: amd64
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.21"

- name: Go mod download
run: go mod download

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CI_USERNAME }}
password: ${{ secrets.CI_PAT }}

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Cache Golang Docker Image
run: docker pull golang:latest

- name: Cache ghcr.io/calyptia/internal/core-fluent-bit Docker Image
run: docker pull ghcr.io/calyptia/internal/core-fluent-bit:main

- name: Unit tests
run: |
Expand Down
33 changes: 24 additions & 9 deletions cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (
"os"
"reflect"
"runtime"
"strconv"
"time"
"unsafe"

"github.com/calyptia/plugin/input"
metricbuilder "github.com/calyptia/plugin/metric/cmetric"
"github.com/calyptia/plugin/output"
"github.com/ugorji/go/codec"

cmetrics "github.com/calyptia/cmetrics-go"
"github.com/calyptia/plugin/input"
metricbuilder "github.com/calyptia/plugin/metric/cmetric"
"github.com/calyptia/plugin/output"
)

var unregister func()
Expand All @@ -31,6 +32,7 @@ var logger Logger

// FLBPluginRegister registers a plugin in the context of the fluent-bit runtime, a name and description
// can be provided.
//
//export FLBPluginRegister
func FLBPluginRegister(def unsafe.Pointer) int {
defer registerWG.Done()
Expand Down Expand Up @@ -59,6 +61,7 @@ func FLBPluginRegister(def unsafe.Pointer) int {
// FLBPluginInit this method gets invoked once by the fluent-bit runtime at initialisation phase.
// here all the plugin context should be initialised and any data or flag required for
// plugins to execute the collect or flush callback.
//
//export FLBPluginInit
func FLBPluginInit(ptr unsafe.Pointer) int {
defer initWG.Done()
Expand All @@ -82,9 +85,9 @@ func FLBPluginInit(ptr unsafe.Pointer) int {
}
logger = &flbInputLogger{ptr: ptr}
fbit := &Fluentbit{
Conf: conf,
Conf: conf,
Metrics: makeMetrics(cmt),
Logger: logger,
Logger: logger,
}

err = theInput.Init(ctx, fbit)
Expand All @@ -96,9 +99,9 @@ func FLBPluginInit(ptr unsafe.Pointer) int {
}
logger = &flbOutputLogger{ptr: ptr}
fbit := &Fluentbit{
Conf: conf,
Conf: conf,
Metrics: makeMetrics(cmt),
Logger: logger,
Logger: logger,
}
err = theOutput.Init(ctx, fbit)
}
Expand All @@ -114,6 +117,7 @@ func FLBPluginInit(ptr unsafe.Pointer) int {
// initialised, 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.
//
//export FLBPluginInputCallback
func FLBPluginInputCallback(data *unsafe.Pointer, csize *C.size_t) int {
initWG.Wait()
Expand Down Expand Up @@ -171,6 +175,7 @@ func FLBPluginInputCallback(data *unsafe.Pointer, csize *C.size_t) int {
}

// FLBPluginInputCleanupCallback releases the memory used during the input callback
//
//export FLBPluginInputCleanupCallback
func FLBPluginInputCleanupCallback(data unsafe.Pointer) int {
C.free(data)
Expand All @@ -179,6 +184,7 @@ func FLBPluginInputCleanupCallback(data unsafe.Pointer) int {

// FLBPluginFlush callback gets invoked by the fluent-bit runtime once there is data for the corresponding
// plugin in the pipeline, a data pointer, length and a tag are passed to the plugin interface implementation.
//
//export FLBPluginFlush
//nolint:funlen,gocognit,gocyclo //ignore length requirement for this function, TODO: refactor into smaller functions.
func FLBPluginFlush(data unsafe.Pointer, clength C.int, ctag *C.char) int {
Expand Down Expand Up @@ -300,6 +306,7 @@ func FLBPluginFlush(data unsafe.Pointer, clength C.int, ctag *C.char) int {
}

// FLBPluginExit method is invoked once the plugin instance is exited from the fluent-bit context.
//
//export FLBPluginExit
func FLBPluginExit() int {
log.Printf("calling FLBPluginExit(): name=%q\n", theName)
Expand All @@ -324,15 +331,23 @@ type flbInputConfigLoader struct {
}

func (f *flbInputConfigLoader) String(key string) string {
return input.FLBPluginConfigKey(f.ptr, key)
s := input.FLBPluginConfigKey(f.ptr, key)
if tmp, err := strconv.Unquote(s); err == nil {
return tmp
}
return s
}

type flbOutputConfigLoader struct {
ptr unsafe.Pointer
}

func (f *flbOutputConfigLoader) String(key string) string {
return output.FLBPluginConfigKey(f.ptr, key)
s := output.FLBPluginConfigKey(f.ptr, key)
if tmp, err := strconv.Unquote(s); err == nil {
return tmp
}
return s
}

type flbInputLogger struct {
Expand Down
6 changes: 4 additions & 2 deletions examples/in_gdummy/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module github.com/fluent/fluent-bit-go/examples/gdummy

go 1.17
go 1.21

toolchain go1.21.0

require github.com/calyptia/plugin v0.1.6

require (
github.com/calyptia/cmetrics-go v0.1.7 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
)

replace github.com/calyptia/plugin => ../..
1 change: 1 addition & 0 deletions examples/in_gdummy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
Expand Down
4 changes: 3 additions & 1 deletion examples/out_gstdout/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/fluent/fluent-bit-go/examples/gstdout

go 1.14
go 1.21

toolchain go1.21.0

require github.com/fluent/fluent-bit-go v0.0.0-20200420155746-e125cab17963

Expand Down
Loading

0 comments on commit da513de

Please sign in to comment.