Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/parser/json_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type JSON struct {
TimeFormat string `json:"timeFormat,omitempty"`
// Time_Keep
TimeKeep *bool `json:"timeKeep,omitempty"`
// Time_Strict
TimeStrict *bool `json:"timeStrict,omitempty"`
}

func (*JSON) Name() string {
Expand All @@ -35,5 +37,8 @@ func (j *JSON) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if j.TimeKeep != nil {
kvs.Insert("Time_Keep", fmt.Sprint(*j.TimeKeep))
}
if j.TimeStrict != nil {
kvs.Insert("Time_Strict", fmt.Sprint(*j.TimeStrict))
}
return kvs, nil
}
5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/parser/logfmt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type Logfmt struct {
TimeFormat string `json:"timeFormat,omitempty"`
// Time_Keep
TimeKeep *bool `json:"timeKeep,omitempty"`
// Time_Strict
TimeStrict *bool `json:"timeStrict,omitempty"`
}

func (*Logfmt) Name() string {
Expand All @@ -35,5 +37,8 @@ func (l *Logfmt) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if l.TimeKeep != nil {
kvs.Insert("Time_Keep", fmt.Sprint(*l.TimeKeep))
}
if l.TimeStrict != nil {
kvs.Insert("Time_Strict", fmt.Sprint(*l.TimeStrict))
}
return kvs, nil
}
9 changes: 7 additions & 2 deletions apis/fluentbit/v1alpha2/plugins/parser/lstv_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ type LSTV struct {
// Time_Format, eg. %Y-%m-%dT%H:%M:%S %z
TimeFormat string `json:"timeFormat,omitempty"`
// Time_Keep
TimeKeep *bool `json:"timeKeep,omitempty"`
Types string `json:"types,omitempty"`
TimeKeep *bool `json:"timeKeep,omitempty"`
// Time_Strict
TimeStrict *bool `json:"timeStrict,omitempty"`
Types string `json:"types,omitempty"`
}

func (*LSTV) Name() string {
Expand All @@ -36,6 +38,9 @@ func (l *LSTV) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if l.TimeKeep != nil {
kvs.Insert("Time_Format", fmt.Sprint(*l.TimeKeep))
}
if l.TimeStrict != nil {
kvs.Insert("Time_Strict", fmt.Sprint(*l.TimeStrict))
}
if l.Types != "" {
kvs.Insert("Types", l.Types)
}
Expand Down
5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/parser/regex_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Regex struct {
TimeFormat string `json:"timeFormat,omitempty"`
// Time_Keep
TimeKeep *bool `json:"timeKeep,omitempty"`
// Time_Strict
TimeStrict *bool `json:"timeStrict,omitempty"`
// Time_Offset, eg. +0200
TimeOffset string `json:"timeOffset,omitempty"`
Types string `json:"types,omitempty"`
Expand All @@ -42,6 +44,9 @@ func (re *Regex) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if re.TimeKeep != nil {
kvs.Insert("Time_Keep", fmt.Sprint(*re.TimeKeep))
}
if re.TimeStrict != nil {
kvs.Insert("Time_Strict", fmt.Sprint(*re.TimeStrict))
}
if re.TimeOffset != "" {
kvs.Insert("Time_Offset", re.TimeOffset)
}
Expand Down
46 changes: 46 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/parser/time_strict_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package parser

import (
"testing"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
. "github.com/onsi/gomega"
)

func TestParsers_TimeStrict(t *testing.T) {
strict := false

tests := []struct {
name string
plugin plugins.Plugin
}{
{"json", &JSON{TimeStrict: &strict}},
{"logfmt", &Logfmt{TimeStrict: &strict}},
{"ltsv", &LSTV{TimeStrict: &strict}},
{"regex", &Regex{Regex: "^(?<log>.*)$", TimeStrict: &strict}},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewGomegaWithT(t)

kvs, err := tt.plugin.Params(plugins.NewSecretLoader(nil, "test"))
g.Expect(err).NotTo(HaveOccurred())
out, err := kvs.String()
g.Expect(err).NotTo(HaveOccurred())
g.Expect(out).To(MatchRegexp(`Time_Strict\s+false\n`))
})
}
}

func TestParsers_TimeStrictUnset(t *testing.T) {
g := NewGomegaWithT(t)

for _, p := range []plugins.Plugin{&JSON{}, &Logfmt{}, &LSTV{}, &Regex{}} {
kvs, err := p.Params(plugins.NewSecretLoader(nil, "test"))
g.Expect(err).NotTo(HaveOccurred())
out, err := kvs.String()
g.Expect(err).NotTo(HaveOccurred())
g.Expect(out).NotTo(ContainSubstring("Time_Strict"))
}
}
20 changes: 20 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/parser/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
logfmt:
description: Logfmt defines logfmt parser configuration.
Expand All @@ -85,6 +88,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
x-kubernetes-validations:
- message: logfmt must not be null
Expand All @@ -101,6 +107,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand All @@ -121,6 +130,9 @@ spec:
timeOffset:
description: Time_Offset, eg. +0200
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
logfmt:
description: Logfmt defines logfmt parser configuration.
Expand All @@ -85,6 +88,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
x-kubernetes-validations:
- message: logfmt must not be null
Expand All @@ -101,6 +107,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand All @@ -121,6 +130,9 @@ spec:
timeOffset:
description: Time_Offset, eg. +0200
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
logfmt:
description: Logfmt defines logfmt parser configuration.
Expand All @@ -83,6 +86,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
x-kubernetes-validations:
- message: logfmt must not be null
Expand All @@ -99,6 +105,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand All @@ -119,6 +128,9 @@ spec:
timeOffset:
description: Time_Offset, eg. +0200
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand Down
12 changes: 12 additions & 0 deletions charts/fluent-operator/crds/fluentbit.fluent.io_parsers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
logfmt:
description: Logfmt defines logfmt parser configuration.
Expand All @@ -83,6 +86,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
x-kubernetes-validations:
- message: logfmt must not be null
Expand All @@ -99,6 +105,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand All @@ -119,6 +128,9 @@ spec:
timeOffset:
description: Time_Offset, eg. +0200
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterparsers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
logfmt:
description: Logfmt defines logfmt parser configuration.
Expand All @@ -84,6 +87,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
type: object
x-kubernetes-validations:
- message: logfmt must not be null
Expand All @@ -100,6 +106,9 @@ spec:
timeKey:
description: Time_Key
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand All @@ -120,6 +129,9 @@ spec:
timeOffset:
description: Time_Offset, eg. +0200
type: string
timeStrict:
description: Time_Strict
type: boolean
types:
type: string
type: object
Expand Down
Loading
Loading