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
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ func Test_FluentBitConfig_RenderMainConfig(t *testing.T) {
i++
}
}

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

Expand Down
16 changes: 8 additions & 8 deletions apis/fluentbit/v1alpha2/clusteroutput_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ func TestClusterOutputList_Load(t *testing.T) {
}

headers := map[string]string{
"Authorization": "foo:bar",
"X-Log-Header-App-Name": "app_name",
"X-Log-Header-0": "testing",
"X-Log-Header-App-ID": "9780495d9db3",
"Authorization": authorization,
"X-Log-Header-App-Name": xLogHeaderAppName,
"X-Log-Header-0": xLogHeader0,
"X-Log-Header-App-ID": xLogHeaderAppID,
}

httpOutput := ClusterOutput{
Expand Down Expand Up @@ -304,10 +304,10 @@ func TestClusterOutputList_Load_As_Yaml(t *testing.T) {
}

headers := map[string]string{
"Authorization": "foo:bar",
"X-Log-Header-App-Name": "app_name",
"X-Log-Header-0": "testing",
"X-Log-Header-App-ID": "9780495d9db3",
"Authorization": authorization,
"X-Log-Header-App-Name": xLogHeaderAppName,
"X-Log-Header-0": xLogHeader0,
"X-Log-Header-App-ID": xLogHeaderAppID,
}

httpOutput := ClusterOutput{
Expand Down
1 change: 0 additions & 1 deletion apis/fluentbit/v1alpha2/plugins/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type CommonParams struct {
// Alias for the plugin
Alias string `json:"alias,omitempty"`
// RetryLimit describes how many times fluent-bit should retry to send data to a specific output. If set to false fluent-bit will try indefinitely. If set to any integer N>0 it will try at most N+1 times. Leading zeros are not allowed (values such as 007, 0150, 01 do not work). If this property is not defined fluent-bit will use the default value: 1.
// nolint:misspell
// +kubebuilder:validation:Pattern="^(((f|F)alse)|(no_limits)|(no_retries)|([1-9]+[0-9]*))$"
RetryLimit string `json:"retryLimit,omitempty"`
}
Expand Down
147 changes: 39 additions & 108 deletions apis/fluentbit/v1alpha2/plugins/filter/kubernetes_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,114 +119,45 @@ func (k *Kubernetes) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if err != nil {
return kvs, err
}
if k.BufferSize != "" {
kvs.Insert("Buffer_Size", k.BufferSize)
}
if k.KubeURL != "" {
kvs.Insert("Kube_URL", k.KubeURL)
}
if k.KubeCAFile != "" {
kvs.Insert("Kube_CA_File", k.KubeCAFile)
}
if k.KubeCAPath != "" {
kvs.Insert("Kube_CA_Path", k.KubeCAPath)
}
if k.KubeTokenFile != "" {
kvs.Insert("Kube_Token_File", k.KubeTokenFile)
}
if k.KubeTagPrefix != "" {
kvs.Insert("Kube_Tag_Prefix", k.KubeTagPrefix)
}
if k.MergeLog != nil {
kvs.Insert("Merge_Log", fmt.Sprint(*k.MergeLog))
}
if k.MergeLogKey != "" {
kvs.Insert("Merge_Log_Key", k.MergeLogKey)
}
if k.MergeLogTrim != nil {
kvs.Insert("Merge_Log_Trim", fmt.Sprint(*k.MergeLogTrim))
}
if k.MergeParser != "" {
kvs.Insert("Merge_Parser", k.MergeParser)
}
if k.KeepLog != nil {
kvs.Insert("Keep_Log", fmt.Sprint(*k.KeepLog))
}
if k.TLSDebug != nil {
kvs.Insert("tls.debug", fmt.Sprint(*k.TLSDebug))
}
if k.TLSVerify != nil {
kvs.Insert("tls.verify", fmt.Sprint(*k.TLSVerify))
}
if k.UseJournal != nil {
kvs.Insert("Use_Journal", fmt.Sprint(*k.UseJournal))
}
if k.CacheUseDockerId != nil {
kvs.Insert("Cache_Use_Docker_Id", fmt.Sprint(*k.CacheUseDockerId))
}
if k.RegexParser != "" {
kvs.Insert("Regex_Parser", k.RegexParser)
}
if k.K8SLoggingParser != nil {
kvs.Insert("K8S-Logging.Parser", fmt.Sprint(*k.K8SLoggingParser))
}
if k.K8SLoggingExclude != nil {
kvs.Insert("K8S-Logging.Exclude", fmt.Sprint(*k.K8SLoggingExclude))
}
if k.Labels != nil {
kvs.Insert("Labels", fmt.Sprint(*k.Labels))
}
if k.Annotations != nil {
kvs.Insert("Annotations", fmt.Sprint(*k.Annotations))
}
if k.KubeMetaPreloadCacheDir != "" {
kvs.Insert("Kube_meta_preload_cache_dir", k.KubeMetaPreloadCacheDir)
}
if k.DummyMeta != nil {
kvs.Insert("Dummy_Meta", fmt.Sprint(*k.DummyMeta))
}
if k.DNSRetries != nil {
kvs.Insert("DNS_Retries", fmt.Sprint(*k.DNSRetries))
}
if k.DNSWaitTime != nil {
kvs.Insert("DNS_Wait_Time", fmt.Sprint(*k.DNSWaitTime))
}
if k.UseKubelet != nil {
kvs.Insert("Use_Kubelet", fmt.Sprint(*k.UseKubelet))
}
if k.KubeletPort != nil {
kvs.Insert("Kubelet_Port", fmt.Sprint(*k.KubeletPort))
}
if k.KubeletHost != "" {
kvs.Insert("Kubelet_Host", k.KubeletHost)
}
if k.KubeMetaCacheTTL != "" {
kvs.Insert("Kube_Meta_Cache_TTL", k.KubeMetaCacheTTL)
}
if k.KubeTokenTTL != "" {
kvs.Insert("Kube_Token_TTL", k.KubeTokenTTL)
}
if k.KubeTokenCommand != "" {
kvs.Insert("Kube_Token_Command", fmt.Sprint(k.KubeTokenCommand))
}
if k.KubeMetaNamespaceCacheTTL != nil {
kvs.Insert("Kube_Meta_Namespace_Cache_TTL", fmt.Sprint(*k.KubeMetaNamespaceCacheTTL))
}
if k.NamespaceLabels != nil {
kvs.Insert("Namespace_Labels", fmt.Sprint(*k.NamespaceLabels))
}
if k.NamespaceAnnotations != nil {
kvs.Insert("Namespace_Annotations", fmt.Sprint(*k.NamespaceAnnotations))
}
if k.NamespaceMetadataOnly != nil {
kvs.Insert("Namespace_Metadata_Only", fmt.Sprint(*k.NamespaceMetadataOnly))
}
if k.OwnerReferences != nil {
kvs.Insert("Owner_References", fmt.Sprint(*k.OwnerReferences))
}
if k.UseTagForMeta != nil {
kvs.Insert("Use_Tag_For_Meta", fmt.Sprint(*k.UseTagForMeta))
}

plugins.InsertKVString(kvs, "Buffer_Size", k.BufferSize)
plugins.InsertKVString(kvs, "Kube_URL", k.KubeURL)
plugins.InsertKVString(kvs, "Kube_CA_File", k.KubeCAFile)
plugins.InsertKVString(kvs, "Kube_CA_Path", k.KubeCAPath)
plugins.InsertKVString(kvs, "Kube_Token_File", k.KubeTokenFile)
plugins.InsertKVString(kvs, "Kube_Tag_Prefix", k.KubeTagPrefix)
plugins.InsertKVString(kvs, "Merge_Log_Key", k.MergeLogKey)
plugins.InsertKVString(kvs, "Merge_Parser", k.MergeParser)
plugins.InsertKVString(kvs, "Regex_Parser", k.RegexParser)
plugins.InsertKVString(kvs, "Kube_meta_preload_cache_dir", k.KubeMetaPreloadCacheDir)
plugins.InsertKVString(kvs, "Kubelet_Host", k.KubeletHost)
plugins.InsertKVString(kvs, "Kube_Token_TTL", k.KubeTokenTTL)
plugins.InsertKVString(kvs, "Kube_Token_Command", k.KubeTokenCommand)

plugins.InsertKVField(kvs, "Merge_Log", k.MergeLog)
plugins.InsertKVField(kvs, "Merge_Log_Trim", k.MergeLogTrim)
plugins.InsertKVField(kvs, "Keep_Log", k.KeepLog)
plugins.InsertKVField(kvs, "tls.debug", k.TLSDebug)
plugins.InsertKVField(kvs, "tls.verify", k.TLSVerify)
plugins.InsertKVField(kvs, "Use_Journal", k.UseJournal)
plugins.InsertKVField(kvs, "Cache_Use_Docker_Id", k.CacheUseDockerId)
plugins.InsertKVField(kvs, "K8S-Logging.Parser", k.K8SLoggingParser)
plugins.InsertKVField(kvs, "K8S-Logging.Exclude", k.K8SLoggingExclude)
plugins.InsertKVField(kvs, "Labels", k.Labels)
plugins.InsertKVField(kvs, "Annotations", k.Annotations)
plugins.InsertKVField(kvs, "Dummy_Meta", k.DummyMeta)
plugins.InsertKVField(kvs, "DNS_Retries", k.DNSRetries)
plugins.InsertKVField(kvs, "DNS_Wait_Time", k.DNSWaitTime)
plugins.InsertKVField(kvs, "Use_Kubelet", k.UseKubelet)
plugins.InsertKVField(kvs, "Kubelet_Port", k.KubeletPort)
plugins.InsertKVString(kvs, "Kube_Meta_Cache_TTL", k.KubeMetaCacheTTL)
plugins.InsertKVField(kvs, "Kube_Meta_Namespace_Cache_TTL", k.KubeMetaNamespaceCacheTTL)
plugins.InsertKVField(kvs, "Namespace_Labels", k.NamespaceLabels)
plugins.InsertKVField(kvs, "Namespace_Annotations", k.NamespaceAnnotations)
plugins.InsertKVField(kvs, "Namespace_Metadata_Only", k.NamespaceMetadataOnly)
plugins.InsertKVField(kvs, "Owner_References", k.OwnerReferences)
plugins.InsertKVField(kvs, "Use_Tag_For_Meta", k.UseTagForMeta)

return kvs, nil
}

Expand Down
17 changes: 6 additions & 11 deletions apis/fluentbit/v1alpha2/plugins/input/collectd.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package input

import (
"fmt"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params"
)
Expand All @@ -29,14 +27,11 @@ func (*Collectd) Name() string {
// implement Section() method
func (c *Collectd) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if c.Listen != "" {
kvs.Insert("Listen", c.Listen)
}
if c.Port != nil {
kvs.Insert("Port", fmt.Sprint(*c.Port))
}
if c.TypesDB != "" {
kvs.Insert("TypesDB", c.TypesDB)
}

plugins.InsertKVString(kvs, "Listen", c.Listen)
plugins.InsertKVString(kvs, "TypesDB", c.TypesDB)

plugins.InsertKVField(kvs, "Port", c.Port)

return kvs, nil
}
21 changes: 7 additions & 14 deletions apis/fluentbit/v1alpha2/plugins/input/dummy_types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package input

import (
"fmt"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params"
)
Expand Down Expand Up @@ -30,17 +28,12 @@ func (*Dummy) Name() string {
// implement Section() method
func (d *Dummy) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if d.Tag != "" {
kvs.Insert("Tag", d.Tag)
}
if d.Dummy != "" {
kvs.Insert("Dummy", d.Dummy)
}
if d.Rate != nil {
kvs.Insert("Rate", fmt.Sprint(*d.Rate))
}
if d.Samples != nil {
kvs.Insert("Samples", fmt.Sprint(*d.Samples))
}

plugins.InsertKVString(kvs, "Tag", d.Tag)
plugins.InsertKVString(kvs, "Dummy", d.Dummy)

plugins.InsertKVField(kvs, "Rate", d.Rate)
plugins.InsertKVField(kvs, "Samples", d.Samples)

return kvs, nil
}
37 changes: 11 additions & 26 deletions apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package input

import (
"fmt"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params"
)
Expand Down Expand Up @@ -42,32 +40,19 @@ func (*ExecWasi) Name() string {
func (w *ExecWasi) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()

if w.WASIPath != "" {
kvs.Insert("WASI_Path", w.WASIPath)
}
if w.Parser != "" {
kvs.Insert("Parser", w.Parser)
}
plugins.InsertKVString(kvs, "WASI_Path", w.WASIPath)
plugins.InsertKVString(kvs, "Parser", w.Parser)
plugins.InsertKVString(kvs, "Wasm_Heap_Size", w.WasmHeapSize)
plugins.InsertKVString(kvs, "Wasm_Stack_Size", w.WasmStackSize)
plugins.InsertKVString(kvs, "Buf_Size", w.BufSize)

plugins.InsertKVField(kvs, "Interval_Sec", w.IntervalSec)
plugins.InsertKVField(kvs, "Interval_NSec", w.IntervalNSec)
plugins.InsertKVField(kvs, "Threaded", w.Threaded)

for _, p := range w.AccessiblePaths {
kvs.Insert("Accessible_Paths", p)
}
if w.IntervalSec != nil {
kvs.Insert("Interval_Sec", fmt.Sprint(*w.IntervalSec))
}
if w.IntervalNSec != nil {
kvs.Insert("Interval_NSec", fmt.Sprint(*w.IntervalNSec))
}
if w.WasmHeapSize != "" {
kvs.Insert("Wasm_Heap_Size", w.WasmHeapSize)
}
if w.WasmStackSize != "" {
kvs.Insert("Wasm_Stack_Size", w.WasmStackSize)
}
if w.BufSize != "" {
kvs.Insert("Buf_Size", w.BufSize)
}
if w.Threaded != nil {
kvs.Insert("Threaded", fmt.Sprint(*w.Threaded))
}

return kvs, nil
}
17 changes: 6 additions & 11 deletions apis/fluentbit/v1alpha2/plugins/input/fluentbit_metrics_types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package input

import (
"fmt"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params"
)
Expand Down Expand Up @@ -30,14 +28,11 @@ func (*FluentbitMetrics) Name() string {

func (f *FluentbitMetrics) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if f.Tag != "" {
kvs.Insert("Tag", f.Tag)
}
if f.ScrapeInterval != "" {
kvs.Insert("scrape_interval", f.ScrapeInterval)
}
if f.ScrapeOnStart != nil {
kvs.Insert("scrape_on_start", fmt.Sprint(*f.ScrapeOnStart))
}

plugins.InsertKVString(kvs, "Tag", f.Tag)
plugins.InsertKVString(kvs, "scrape_interval", f.ScrapeInterval)

plugins.InsertKVField(kvs, "scrape_on_start", f.ScrapeOnStart)

return kvs, nil
}
40 changes: 11 additions & 29 deletions apis/fluentbit/v1alpha2/plugins/input/forward.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package input

import (
"fmt"

"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v3/apis/fluentbit/v1alpha2/plugins/params"
)
Expand Down Expand Up @@ -46,32 +44,16 @@ func (*Forward) Name() string {
// Params implement Section() method
func (f *Forward) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if f.Port != nil {
kvs.Insert("Port", fmt.Sprint(*f.Port))
}
if f.Listen != "" {
kvs.Insert("Listen", f.Listen)
}
if f.Tag != "" {
kvs.Insert("Tag", f.Tag)
}
if f.TagPrefix != "" {
kvs.Insert("Tag_Prefix", f.TagPrefix)
}
if f.UnixPath != "" {
kvs.Insert("Unix_Path", f.UnixPath)
}
if f.UnixPerm != "" {
kvs.Insert("Unix_Perm", f.UnixPerm)
}
if f.BufferChunkSize != "" {
kvs.Insert("Buffer_Chunk_Size", f.BufferChunkSize)
}
if f.BufferMaxSize != "" {
kvs.Insert("Buffer_Max_Size", f.BufferMaxSize)
}
if f.Threaded != "" {
kvs.Insert("threaded", f.Threaded)
}

plugins.InsertKVField(kvs, "Port", f.Port)
plugins.InsertKVString(kvs, "Listen", f.Listen)
plugins.InsertKVString(kvs, "Tag", f.Tag)
plugins.InsertKVString(kvs, "Tag_Prefix", f.TagPrefix)
plugins.InsertKVString(kvs, "Unix_Path", f.UnixPath)
plugins.InsertKVString(kvs, "Unix_Perm", f.UnixPerm)
plugins.InsertKVString(kvs, "Buffer_Chunk_Size", f.BufferChunkSize)
plugins.InsertKVString(kvs, "Buffer_Max_Size", f.BufferMaxSize)
plugins.InsertKVString(kvs, "threaded", f.Threaded)

return kvs, nil
}
Loading
Loading