Skip to content
Merged
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
3 changes: 3 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/output/file_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type File struct {
LabelDelimiter string `json:"labelDelimiter,omitempty"`
// The format string. Applicable only if format is template.
Template string `json:"template,omitempty"`
// Recursively create the output directory if it does not exist. The directories are created with permissions 0755.
Mkdir *bool `json:"mkdir,omitempty"`
}

func (*File) Name() string {
Expand All @@ -38,6 +40,7 @@ func (f *File) Params(_ plugins.SecretLoader) (*params.KVs, error) {
plugins.InsertKVString(kvs, "Delimiter", f.Delimiter)
plugins.InsertKVString(kvs, "Label_Delimiter", f.LabelDelimiter)
plugins.InsertKVString(kvs, "Template", f.Template)
plugins.InsertKVField(kvs, "Mkdir", f.Mkdir)

return kvs, nil
}
49 changes: 49 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/output/file_types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package output

import (
"testing"

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

func TestOutput_File_Params(t *testing.T) {
g := NewWithT(t)

sl := plugins.NewSecretLoader(nil, "test namespace")
enabled := true

file := File{
Path: "/var/log/out/app",
File: "records.log",
Mkdir: &enabled,
}

expected := params.NewKVs()
expected.Insert("Path", "/var/log/out/app")
expected.Insert("File", "records.log")
expected.Insert("Mkdir", "true")

kvs, err := file.Params(sl)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(kvs).To(Equal(expected))
}

func TestOutput_File_ParamsMkdirUnsetAndFalse(t *testing.T) {
g := NewWithT(t)

sl := plugins.NewSecretLoader(nil, "test namespace")
disabled := false

kvs, err := (&File{Path: "/out"}).Params(sl)
g.Expect(err).NotTo(HaveOccurred())
expected := params.NewKVs()
expected.Insert("Path", "/out")
g.Expect(kvs).To(Equal(expected))

kvs, err = (&File{Path: "/out", Mkdir: &disabled}).Params(sl)
g.Expect(err).NotTo(HaveOccurred())
expected.Insert("Mkdir", "false")
g.Expect(kvs).To(Equal(expected))
}

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

2 changes: 1 addition & 1 deletion apis/fluentbit/v1alpha2/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 @@ -1045,6 +1045,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
4 changes: 4 additions & 0 deletions charts/fluent-operator/crds/fluentbit.fluent.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
1 change: 1 addition & 0 deletions docs/plugins/fluentbit/output/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ The file output plugin allows to write the data received through the input plugi
| delimiter | The character to separate each pair. Applicable only if format is csv or ltsv. | string |
| labelDelimiter | The character to separate each pair. Applicable only if format is ltsv. | string |
| template | The format string. Applicable only if format is template. | string |
| mkdir | Recursively create the output directory if it does not exist. The directories are created with permissions 0755. | *bool |
8 changes: 8 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5270,6 +5270,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down Expand Up @@ -36913,6 +36917,10 @@ spec:
description: The character to separate each pair. Applicable only
if format is ltsv.
type: string
mkdir:
description: Recursively create the output directory if it does
not exist. The directories are created with permissions 0755.
type: boolean
path:
description: Absolute directory path to store files. If not set,
Fluent Bit will write the files on it's own positioned directory.
Expand Down
Loading