diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..1bf1b3a07 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: Lint + +on: + push: + pull_request: + +jobs: + lint: + name: Run on Ubuntu + runs-on: ubuntu-latest + steps: + - name: Clone the code + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + + - name: Setup Go + uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 + with: + go-version-file: go.mod + + - name: Run linter + uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 + with: + version: v2.1.0 diff --git a/Makefile b/Makefile index 5301f0320..c97f056e6 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,10 @@ lint: golangci-lint ## Run golangci-lint linter lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes $(GOLANGCI_LINT) run --fix +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + ##@ Build binary: @@ -197,7 +201,7 @@ KIND = $(LOCALBIN)/kind KUSTOMIZE_VERSION ?= v5.6.0 CONTROLLER_TOOLS_VERSION ?= v0.15.0 ENVTEST_VERSION ?= release-0.19 -GOLANGCI_LINT_VERSION ?= v1.59.1 +GOLANGCI_LINT_VERSION ?= v2.0.1 GINKGO_VERSION ?= v2.23.4 CODE_GENERATOR_VERSION ?= v0.32.3 KIND_VERSION ?= v0.17.0 @@ -220,7 +224,7 @@ $(ENVTEST): $(LOCALBIN) .PHONY: golangci-lint golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. $(GOLANGCI_LINT): $(LOCALBIN) - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION)) + $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION)) .PHONY: ginkgo ginkgo: $(GINKGO) ## Download ginkgo locally if necessary. diff --git a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go index 21060d32b..fa69b7407 100644 --- a/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go +++ b/apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go @@ -550,11 +550,11 @@ func (cfg ClusterFluentBitConfig) RenderNamespacedLuaScript( for _, f := range nsfilters.Items { for _, p := range f.Spec.FilterItems { if p.Lua != nil && p.Lua.Script.Key != "" { - script, err := cl.LoadConfigMap(p.Lua.Script, f.ObjectMeta.Namespace) + script, err := cl.LoadConfigMap(p.Lua.Script, f.Namespace) if err != nil { return nil, err } - namespacedScriptName := fmt.Sprintf("%x-%s", md5.Sum([]byte(f.ObjectMeta.Namespace)), p.Lua.Script.Key) + namespacedScriptName := fmt.Sprintf("%x-%s", md5.Sum([]byte(f.Namespace)), p.Lua.Script.Key) scripts = append(scripts, Script{Name: namespacedScriptName, Content: script}) } } diff --git a/apis/fluentbit/v1alpha2/collector_types.go b/apis/fluentbit/v1alpha2/collector_types.go index 5368ad05b..99c68791f 100644 --- a/apis/fluentbit/v1alpha2/collector_types.go +++ b/apis/fluentbit/v1alpha2/collector_types.go @@ -114,7 +114,7 @@ type Collector struct { // IsBeingDeleted returns true if a deletion timestamp is set func (co *Collector) IsBeingDeleted() bool { - return !co.ObjectMeta.DeletionTimestamp.IsZero() + return !co.DeletionTimestamp.IsZero() } // CollectorFinalizerName is the name of the fluentbit finalizer @@ -122,17 +122,17 @@ const CollectorFinalizerName = "collector.fluent.io" // HasFinalizer returns true if the item has the specified finalizer func (co *Collector) HasFinalizer(finalizerName string) bool { - return slices.Contains(co.ObjectMeta.Finalizers, finalizerName) + return slices.Contains(co.Finalizers, finalizerName) } // AddFinalizer adds the specified finalizer func (co *Collector) AddFinalizer(finalizerName string) { - co.ObjectMeta.Finalizers = append(co.ObjectMeta.Finalizers, finalizerName) + co.Finalizers = append(co.Finalizers, finalizerName) } // RemoveFinalizer removes the specified finalizer func (co *Collector) RemoveFinalizer(finalizerName string) { - co.ObjectMeta.Finalizers = slices.DeleteFunc(co.ObjectMeta.Finalizers, func(s string) bool { return s == finalizerName }) + co.Finalizers = slices.DeleteFunc(co.Finalizers, func(s string) bool { return s == finalizerName }) } // +kubebuilder:object:root=true diff --git a/apis/fluentbit/v1alpha2/fluentbit_types.go b/apis/fluentbit/v1alpha2/fluentbit_types.go index 83d63f90e..acc93584c 100644 --- a/apis/fluentbit/v1alpha2/fluentbit_types.go +++ b/apis/fluentbit/v1alpha2/fluentbit_types.go @@ -142,7 +142,7 @@ type FluentBit struct { // IsBeingDeleted returns true if a deletion timestamp is set func (fb *FluentBit) IsBeingDeleted() bool { - return !fb.ObjectMeta.DeletionTimestamp.IsZero() + return !fb.DeletionTimestamp.IsZero() } // FluentBitFinalizerName is the name of the fluentbit finalizer @@ -150,17 +150,17 @@ const FluentBitFinalizerName = "fluentbit.fluent.io" // HasFinalizer returns true if the item has the specified finalizer func (fb *FluentBit) HasFinalizer(finalizerName string) bool { - return slices.Contains(fb.ObjectMeta.Finalizers, finalizerName) + return slices.Contains(fb.Finalizers, finalizerName) } // AddFinalizer adds the specified finalizer func (fb *FluentBit) AddFinalizer(finalizerName string) { - fb.ObjectMeta.Finalizers = append(fb.ObjectMeta.Finalizers, finalizerName) + fb.Finalizers = append(fb.Finalizers, finalizerName) } // RemoveFinalizer removes the specified finalizer func (fb *FluentBit) RemoveFinalizer(finalizerName string) { - fb.ObjectMeta.Finalizers = slices.DeleteFunc(fb.ObjectMeta.Finalizers, func(s string) bool { return s == finalizerName }) + fb.Finalizers = slices.DeleteFunc(fb.Finalizers, func(s string) bool { return s == finalizerName }) } // +kubebuilder:object:root=true diff --git a/apis/fluentbit/v1alpha2/plugins/common_types.go b/apis/fluentbit/v1alpha2/plugins/common_types.go index d9ac7eae5..f3f66509e 100644 --- a/apis/fluentbit/v1alpha2/plugins/common_types.go +++ b/apis/fluentbit/v1alpha2/plugins/common_types.go @@ -12,7 +12,8 @@ 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 indefinetly. 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. + // 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"` } diff --git a/apis/fluentbit/v1alpha2/plugins/configmap_types.go b/apis/fluentbit/v1alpha2/plugins/configmap_types.go index 8745f273f..0d328f41b 100644 --- a/apis/fluentbit/v1alpha2/plugins/configmap_types.go +++ b/apis/fluentbit/v1alpha2/plugins/configmap_types.go @@ -3,10 +3,11 @@ package plugins import ( "context" "fmt" + "strings" + "github.com/go-openapi/errors" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "strings" ) type ConfigMapLoader struct { @@ -30,6 +31,6 @@ func (cl ConfigMapLoader) LoadConfigMap(selector v1.ConfigMapKeySelector, namesp if v, ok := configMap.Data[selector.Key]; !ok { return "", errors.NotFound(fmt.Sprintf("The key %s is not found.", selector.Key)) } else { - return strings.TrimSuffix(fmt.Sprintf("%s", v), "\n"), nil + return strings.TrimSuffix(v, "\n"), nil } } diff --git a/apis/fluentbit/v1alpha2/plugins/custom/custom_plugin_types.go b/apis/fluentbit/v1alpha2/plugins/custom/custom_plugin_types.go index 9b7d81bc9..ae41f6c7b 100644 --- a/apis/fluentbit/v1alpha2/plugins/custom/custom_plugin_types.go +++ b/apis/fluentbit/v1alpha2/plugins/custom/custom_plugin_types.go @@ -58,11 +58,10 @@ func (c *CustomPlugin) MakeNamespaced(ns string) { } func indentation(str string) string { - splits := strings.Split(str, "\n") var buf bytes.Buffer - for _, i := range splits { - if i != "" { - buf.WriteString(fmt.Sprintf(" %s\n", strings.TrimSpace(i))) + for s := range strings.SplitSeq(str, "\n") { + if s != "" { + buf.WriteString(fmt.Sprintf(" %s\n", strings.TrimSpace(s))) } } return buf.String() @@ -70,8 +69,7 @@ func indentation(str string) string { func MakeCustomConfigNamespaced(customConfig string, namespace string) string { var buf bytes.Buffer - sections := strings.Split(customConfig, "\n") - for _, section := range sections { + for section := range strings.SplitSeq(customConfig, "\n") { section = strings.TrimSpace(section) idx := strings.LastIndex(section, " ") if strings.HasPrefix(section, "Match_Regex") { diff --git a/apis/fluentbit/v1alpha2/plugins/filter/aws_types.go b/apis/fluentbit/v1alpha2/plugins/filter/aws_types.go index 3916f953e..acc0d09c0 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/aws_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/aws_types.go @@ -18,23 +18,23 @@ type AWS struct { ImdsVersion string `json:"imdsVersion,omitempty"` // The availability zone; for example, "us-east-1a". Default is true. AZ *bool `json:"az,omitempty"` - //The EC2 instance ID.Default is true. + // The EC2 instance ID.Default is true. EC2InstanceID *bool `json:"ec2InstanceID,omitempty"` - //The EC2 instance type.Default is false. + // The EC2 instance type.Default is false. EC2InstanceType *bool `json:"ec2InstanceType,omitempty"` - //The EC2 instance private ip.Default is false. + // The EC2 instance private ip.Default is false. PrivateIP *bool `json:"privateIP,omitempty"` - //The EC2 instance image id.Default is false. + // The EC2 instance image id.Default is false. AmiID *bool `json:"amiID,omitempty"` - //The account ID for current EC2 instance.Default is false. + // The account ID for current EC2 instance.Default is false. AccountID *bool `json:"accountID,omitempty"` - //The hostname for current EC2 instance.Default is false. + // The hostname for current EC2 instance.Default is false. HostName *bool `json:"hostName,omitempty"` - //The VPC ID for current EC2 instance.Default is false. + // The VPC ID for current EC2 instance.Default is false. VpcID *bool `json:"vpcID,omitempty"` } -func (_ *AWS) Name() string { +func (*AWS) Name() string { return "aws" } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/grep_types.go b/apis/fluentbit/v1alpha2/plugins/filter/grep_types.go index 2dc6b2b33..6145558cd 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/grep_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/grep_types.go @@ -19,7 +19,7 @@ type Grep struct { Exclude string `json:"exclude,omitempty"` } -func (_ *Grep) Name() string { +func (*Grep) Name() string { return "grep" } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/kubernetes_types.go b/apis/fluentbit/v1alpha2/plugins/filter/kubernetes_types.go index 1f8e60fb4..9ba993b2b 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/kubernetes_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/kubernetes_types.go @@ -109,7 +109,7 @@ type Kubernetes struct { UseTagForMeta *bool `json:"useTagForMeta,omitempty"` } -func (_ *Kubernetes) Name() string { +func (*Kubernetes) Name() string { return "kubernetes" } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go b/apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go index 11d9c943b..ff35e48f7 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go @@ -51,7 +51,7 @@ type LogToMetrics struct { DiscardLogs *bool `json:"discardLogs,omitempty"` } -func (_ *LogToMetrics) Name() string { +func (*LogToMetrics) Name() string { return "log_to_metrics" } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/lua_types.go b/apis/fluentbit/v1alpha2/plugins/filter/lua_types.go index 44f2eae45..fa5b90eb6 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/lua_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/lua_types.go @@ -55,12 +55,13 @@ func (l *Lua) Params(_ plugins.SecretLoader) (*params.KVs, error) { } if l.Code != "" { - var singleLineLua string = "" + var singleLineLua = "" lineTrim := "" - for _, line := range strings.Split(strings.TrimSuffix(l.Code, "\n"), "\n") { + re := regexp.MustCompile(`^function |^if |^for |^else|^elseif |^end|--[[]+`) + for line := range strings.SplitSeq(strings.TrimSuffix(l.Code, "\n"), "\n") { lineTrim = strings.TrimSpace(line) if lineTrim != "" { - operator, _ := regexp.MatchString("^function |^if |^for |^else|^elseif |^end|--[[]+", lineTrim) + operator := re.MatchString(lineTrim) if operator { singleLineLua = singleLineLua + lineTrim + " " } else { @@ -77,11 +78,11 @@ func (l *Lua) Params(_ plugins.SecretLoader) (*params.KVs, error) { kvs.Insert("call", l.Call) - if l.TypeIntKey != nil && len(l.TypeIntKey) > 0 { + if len(l.TypeIntKey) > 0 { kvs.Insert("type_int_key", strings.Join(l.TypeIntKey, " ")) } - if l.TypeArrayKey != nil && len(l.TypeArrayKey) > 0 { + if len(l.TypeArrayKey) > 0 { kvs.Insert("type_array_key", strings.Join(l.TypeArrayKey, " ")) } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/modify_types.go b/apis/fluentbit/v1alpha2/plugins/filter/modify_types.go index 9b1461822..be2395dc1 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/modify_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/modify_types.go @@ -82,36 +82,37 @@ func (mo *Modify) Params(_ plugins.SecretLoader) (*params.KVs, error) { if err != nil { return kvs, err } + const condition = "Condition" for _, c := range mo.Conditions { if c.KeyExists != "" { - kvs.Insert("Condition", fmt.Sprintf("Key_exists %s", c.KeyExists)) + kvs.Insert(condition, fmt.Sprintf("Key_exists %s", c.KeyExists)) } kvs.InsertStringMap(c.KeyDoesNotExist, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Key_does_not_exist %s %s", k, v) + return condition, fmt.Sprintf("Key_does_not_exist %s %s", k, v) }) if c.AKeyMatches != "" { - kvs.Insert("Condition", fmt.Sprintf("A_key_matches %s", c.AKeyMatches)) + kvs.Insert(condition, fmt.Sprintf("A_key_matches %s", c.AKeyMatches)) } if c.NoKeyMatches != "" { - kvs.Insert("Condition", fmt.Sprintf("No_key_matches %s", c.NoKeyMatches)) + kvs.Insert(condition, fmt.Sprintf("No_key_matches %s", c.NoKeyMatches)) } kvs.InsertStringMap(c.KeyValueEquals, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Key_value_equals %s %s", k, v) + return condition, fmt.Sprintf("Key_value_equals %s %s", k, v) }) kvs.InsertStringMap(c.KeyValueDoesNotEqual, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Key_value_does_not_equal %s %s", k, v) + return condition, fmt.Sprintf("Key_value_does_not_equal %s %s", k, v) }) kvs.InsertStringMap(c.KeyValueMatches, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Key_value_matches %s %s", k, v) + return condition, fmt.Sprintf("Key_value_matches %s %s", k, v) }) kvs.InsertStringMap(c.KeyValueDoesNotMatch, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Key_value_does_not_match %s %s", k, v) + return condition, fmt.Sprintf("Key_value_does_not_match %s %s", k, v) }) kvs.InsertStringMap(c.MatchingKeysHaveMatchingValues, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Matching_keys_have_matching_values %s %s", k, v) + return condition, fmt.Sprintf("Matching_keys_have_matching_values %s %s", k, v) }) kvs.InsertStringMap(c.MatchingKeysDoNotHaveMatchingValues, func(k, v string) (string, string) { - return "Condition", fmt.Sprintf("Matching_keys_do_not_have_matching_values %s %s", k, v) + return condition, fmt.Sprintf("Matching_keys_do_not_have_matching_values %s %s", k, v) }) } for _, r := range mo.Rules { diff --git a/apis/fluentbit/v1alpha2/plugins/filter/multiline_types.go b/apis/fluentbit/v1alpha2/plugins/filter/multiline_types.go index 82a2fcd61..7b70d7c2e 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/multiline_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/multiline_types.go @@ -19,10 +19,10 @@ type Multiline struct { type Multi struct { // Specify one or multiple Multiline Parsing definitions to apply to the content. - //You can specify multiple multiline parsers to detect different formats by separating them with a comma. + // You can specify multiple multiline parsers to detect different formats by separating them with a comma. Parser string `json:"parser"` - //Key name that holds the content to process. - //Note that a Multiline Parser definition can already specify the key_content to use, but this option allows to overwrite that value for the purpose of the filter. + // Key name that holds the content to process. + // Note that a Multiline Parser definition can already specify the key_content to use, but this option allows to overwrite that value for the purpose of the filter. KeyContent string `json:"keyContent,omitempty"` // +kubebuilder:validation:Enum:=parser;partial_message Mode string `json:"mode,omitempty"` @@ -41,7 +41,7 @@ type Multi struct { EmitterMemBufLimit int `json:"emitterMemBufLimit,omitempty"` } -func (_ *Multiline) Name() string { +func (*Multiline) Name() string { return "multiline" } @@ -52,29 +52,29 @@ func (m *Multiline) Params(_ plugins.SecretLoader) (*params.KVs, error) { return kvs, err } if m.Multi != nil { - if m.Multi.Parser != "" { - kvs.Insert("multiline.parser", m.Multi.Parser) + if m.Parser != "" { + kvs.Insert("multiline.parser", m.Parser) } - if m.Multi.KeyContent != "" { - kvs.Insert("multiline.key_content", m.Multi.KeyContent) + if m.KeyContent != "" { + kvs.Insert("multiline.key_content", m.KeyContent) } - if m.Multi.Mode != "" { - kvs.Insert("mode", m.Multi.Mode) + if m.Mode != "" { + kvs.Insert("mode", m.Mode) } - if m.Multi.Buffer != false { - kvs.Insert("buffer", fmt.Sprint(m.Multi.Buffer)) + if m.Buffer { + kvs.Insert("buffer", fmt.Sprint(m.Buffer)) } - if m.Multi.FlushMS != 0 { - kvs.Insert("flush_ms", fmt.Sprint(m.Multi.FlushMS)) + if m.FlushMS != 0 { + kvs.Insert("flush_ms", fmt.Sprint(m.FlushMS)) } - if m.Multi.EmitterName != "" { - kvs.Insert("emitter_name", m.Multi.EmitterName) + if m.EmitterName != "" { + kvs.Insert("emitter_name", m.EmitterName) } - if m.Multi.EmitterType != "" { - kvs.Insert("emitter_storage.type", m.Multi.EmitterType) + if m.EmitterType != "" { + kvs.Insert("emitter_storage.type", m.EmitterType) } - if m.Multi.EmitterMemBufLimit != 0 { - kvs.Insert("emitter_mem_buf_limit", fmt.Sprintf("%dMB", m.Multi.EmitterMemBufLimit)) + if m.EmitterMemBufLimit != 0 { + kvs.Insert("emitter_mem_buf_limit", fmt.Sprintf("%dMB", m.EmitterMemBufLimit)) } } return kvs, nil diff --git a/apis/fluentbit/v1alpha2/plugins/filter/nest_types.go b/apis/fluentbit/v1alpha2/plugins/filter/nest_types.go index f34de22ca..6589ba13a 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/nest_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/nest_types.go @@ -26,7 +26,7 @@ type Nest struct { RemovePrefix string `json:"removePrefix,omitempty"` } -func (_ *Nest) Name() string { +func (*Nest) Name() string { return "nest" } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/parser_types.go b/apis/fluentbit/v1alpha2/plugins/filter/parser_types.go index e317c4de6..fa860a1ab 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/parser_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/parser_types.go @@ -30,7 +30,7 @@ type Parser struct { UnescapeKey *bool `json:"unescapeKey,omitempty"` } -func (_ *Parser) Name() string { +func (*Parser) Name() string { return "parser" } @@ -44,8 +44,7 @@ func (p *Parser) Params(_ plugins.SecretLoader) (*params.KVs, error) { kvs.Insert("Key_Name", p.KeyName) } if p.Parser != "" { - parsers := strings.Split(p.Parser, ",") - for _, parser := range parsers { + for parser := range strings.SplitSeq(p.Parser, ",") { kvs.Insert("Parser", strings.Trim(parser, " ")) } } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/record_modifier_types.go b/apis/fluentbit/v1alpha2/plugins/filter/record_modifier_types.go index 71a7f9a23..0c6cc6a4f 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/record_modifier_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/record_modifier_types.go @@ -24,7 +24,7 @@ type RecordModifier struct { UUIDKeys []string `json:"uuidKeys,omitempty"` } -func (_ *RecordModifier) Name() string { +func (*RecordModifier) Name() string { return "record_modifier" } diff --git a/apis/fluentbit/v1alpha2/plugins/filter/rewrite_tag_types.go b/apis/fluentbit/v1alpha2/plugins/filter/rewrite_tag_types.go index bd68a7519..a0506f34d 100644 --- a/apis/fluentbit/v1alpha2/plugins/filter/rewrite_tag_types.go +++ b/apis/fluentbit/v1alpha2/plugins/filter/rewrite_tag_types.go @@ -27,7 +27,7 @@ type RewriteTag struct { EmitterStorageType string `json:"emitterStorageType,omitempty"` } -func (_ *RewriteTag) Name() string { +func (*RewriteTag) Name() string { return "rewrite_tag" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/collectd.go b/apis/fluentbit/v1alpha2/plugins/input/collectd.go index 5647bb5fc..380e2893e 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/collectd.go +++ b/apis/fluentbit/v1alpha2/plugins/input/collectd.go @@ -22,7 +22,7 @@ type Collectd struct { TypesDB string `json:"typesDB,omitempty"` } -func (_ *Collectd) Name() string { +func (*Collectd) Name() string { return "collectd" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/dummy_types.go b/apis/fluentbit/v1alpha2/plugins/input/dummy_types.go index 31ed85060..821b42528 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/dummy_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/dummy_types.go @@ -13,7 +13,7 @@ import ( // It is useful for testing, debugging, benchmarking and getting started with Fluent Bit.
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/dummy** type Dummy struct { - // Tag name associated to all records comming from this plugin. + // Tag name associated to all records coming from this plugin. Tag string `json:"tag,omitempty"` // Dummy JSON record. Dummy string `json:"dummy,omitempty"` @@ -23,7 +23,7 @@ type Dummy struct { Samples *int32 `json:"samples,omitempty"` } -func (_ *Dummy) Name() string { +func (*Dummy) Name() string { return "dummy" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go b/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go index ac52ba4af..0e2291ecb 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/exec_wasi_types.go @@ -34,7 +34,7 @@ type ExecWasi struct { Threaded *bool `json:"threaded,omitempty"` } -func (_ *ExecWasi) Name() string { +func (*ExecWasi) Name() string { return "exec_wasi" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/fluentbit_metrics_types.go b/apis/fluentbit/v1alpha2/plugins/input/fluentbit_metrics_types.go index 024b01181..c5bb63a86 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/fluentbit_metrics_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/fluentbit_metrics_types.go @@ -24,7 +24,7 @@ type FluentbitMetrics struct { ScrapeOnStart *bool `json:"scrapeOnStart,omitempty"` } -func (_ *FluentbitMetrics) Name() string { +func (*FluentbitMetrics) Name() string { return "fluentbit_metrics" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/forward.go b/apis/fluentbit/v1alpha2/plugins/input/forward.go index e54ab5853..56e9f94c6 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/forward.go +++ b/apis/fluentbit/v1alpha2/plugins/input/forward.go @@ -9,7 +9,7 @@ import ( // +kubebuilder:object:generate:=true -// Forward defines the in_forward Input plugin that listens to TCP socket to recieve the event stream. +// Forward defines the in_forward Input plugin that listens to TCP socket to receive the event stream. // **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/forward** type Forward struct { // Port for forward plugin instance. @@ -22,11 +22,11 @@ type Forward struct { Tag string `json:"tag,omitempty"` // Adds the prefix to incoming event's tag TagPrefix string `json:"tagPrefix,omitempty"` - // Specify the path to unix socket to recieve a forward message. If set, Listen and port are ignnored. + // Specify the path to unix socket to receive a forward message. If set, Listen and port are ignnored. UnixPath string `json:"unixPath,omitempty"` // Set the permission of unix socket file. UnixPerm string `json:"unixPerm,omitempty"` - // Specify maximum buffer memory size used to recieve a forward message. + // Specify maximum buffer memory size used to receive a forward message. // The value must be according to the Unit Size specification. // +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$" BufferMaxSize string `json:"bufferMaxSize,omitempty"` @@ -39,7 +39,7 @@ type Forward struct { Threaded string `json:"threaded,omitempty"` } -func (_ *Forward) Name() string { +func (*Forward) Name() string { return "forward" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/http.go b/apis/fluentbit/v1alpha2/plugins/input/http.go index e0daf32c1..627b07de7 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/http.go +++ b/apis/fluentbit/v1alpha2/plugins/input/http.go @@ -34,7 +34,7 @@ type HTTP struct { *plugins.TLS `json:"tls,omitempty"` } -func (_ *HTTP) Name() string { +func (*HTTP) Name() string { return "http" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/kubernetes_events_types.go b/apis/fluentbit/v1alpha2/plugins/input/kubernetes_events_types.go index 65342ae9c..46bac7ccf 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/kubernetes_events_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/kubernetes_events_types.go @@ -12,7 +12,7 @@ import ( // The KubernetesEvents input plugin allows you to collect kubernetes cluster events from kube-api server // **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/kubernetes-events* type KubernetesEvents struct { - // Tag name associated to all records comming from this plugin. + // Tag name associated to all records coming from this plugin. Tag string `json:"tag,omitempty"` // Set a database file to keep track of recorded Kubernetes events DB string `json:"db,omitempty"` @@ -47,7 +47,7 @@ type KubernetesEvents struct { TLSVhost string `json:"tlsVhost,omitempty"` } -func (_ *KubernetesEvents) Name() string { +func (*KubernetesEvents) Name() string { return "kubernetes_events" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/mqtt.go b/apis/fluentbit/v1alpha2/plugins/input/mqtt.go index 9e40430de..51c0b47ef 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/mqtt.go +++ b/apis/fluentbit/v1alpha2/plugins/input/mqtt.go @@ -21,7 +21,7 @@ type MQTT struct { Port *int32 `json:"port,omitempty"` } -func (_ *MQTT) Name() string { +func (*MQTT) Name() string { return "mqtt" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/nginx.go b/apis/fluentbit/v1alpha2/plugins/input/nginx.go index 3c16339f6..99aa0ebdb 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/nginx.go +++ b/apis/fluentbit/v1alpha2/plugins/input/nginx.go @@ -24,7 +24,7 @@ type Nginx struct { NginxPlus *bool `json:"nginxPlus,omitempty"` } -func (_ *Nginx) Name() string { +func (*Nginx) Name() string { return "nginx_metrics" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/node_exporter_metrics_types.go b/apis/fluentbit/v1alpha2/plugins/input/node_exporter_metrics_types.go index 15b3a2bd5..e03b19464 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/node_exporter_metrics_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/node_exporter_metrics_types.go @@ -12,7 +12,7 @@ import ( // This plugin is currently only supported on Linux based operating systems.
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/node-exporter-metrics** type NodeExporterMetrics struct { - // Tag name associated to all records comming from this plugin. + // Tag name associated to all records coming from this plugin. Tag string `json:"tag,omitempty"` // The rate at which metrics are collected from the host operating system, default is 5 seconds. ScrapeInterval string `json:"scrapeInterval,omitempty"` @@ -26,7 +26,7 @@ type Path struct { Sysfs string `json:"sysfs,omitempty"` } -func (_ *NodeExporterMetrics) Name() string { +func (*NodeExporterMetrics) Name() string { return "node_exporter_metrics" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go b/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go index a36b63b94..213320002 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go @@ -29,7 +29,7 @@ type OpenTelemetry struct { // This sets the chunk size for incoming incoming JSON messages. These chunks are then stored/managed in the space available by buffer_max_size(default 512K). // +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$" BufferChunkSize string `json:"bufferChunkSize,omitempty"` - //It allows to set successful response code. 200, 201 and 204 are supported(default 201). + // It allows to set successful response code. 200, 201 and 204 are supported(default 201). SuccessfulResponseCode *int32 `json:"successfulResponseCode,omitempty"` // opentelemetry uses the tag value for incoming metrics. Tag string `json:"tag,omitempty"` @@ -37,7 +37,7 @@ type OpenTelemetry struct { TagFromURI *bool `json:"tagFromURI,omitempty"` } -func (_ *OpenTelemetry) Name() string { +func (*OpenTelemetry) Name() string { return "opentelemetry" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/prometheus_scrape_metrics_types.go b/apis/fluentbit/v1alpha2/plugins/input/prometheus_scrape_metrics_types.go index 124b3be7d..4f6ee679e 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/prometheus_scrape_metrics_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/prometheus_scrape_metrics_types.go @@ -15,7 +15,7 @@ import ( // endpoint at a set interval. These metrics can be routed to metric supported endpoints such as Prometheus Exporter, InfluxDB, or Prometheus Remote Write.
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/prometheus-scrape-metrics** type PrometheusScrapeMetrics struct { - // Tag name associated to all records comming from this plugin + // Tag name associated to all records coming from this plugin Tag string `json:"tag,omitempty"` // The host of the prometheus metric endpoint that you want to scrape Host string `json:"host,omitempty"` @@ -29,7 +29,7 @@ type PrometheusScrapeMetrics struct { MetricsPath string `json:"metricsPath,omitempty"` } -func (_ *PrometheusScrapeMetrics) Name() string { +func (*PrometheusScrapeMetrics) Name() string { return "prometheus_scrape" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/statsd.go b/apis/fluentbit/v1alpha2/plugins/input/statsd.go index 7e5dc2653..6a25cadae 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/statsd.go +++ b/apis/fluentbit/v1alpha2/plugins/input/statsd.go @@ -20,7 +20,7 @@ type StatsD struct { Port *int32 `json:"port,omitempty"` } -func (_ *StatsD) Name() string { +func (*StatsD) Name() string { return "statsd" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/syslog.go b/apis/fluentbit/v1alpha2/plugins/input/syslog.go index c9aff9dad..fac0b5f00 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/syslog.go +++ b/apis/fluentbit/v1alpha2/plugins/input/syslog.go @@ -45,7 +45,7 @@ type Syslog struct { *plugins.TLS `json:"tls,omitempty"` } -func (_ *Syslog) Name() string { +func (*Syslog) Name() string { return "syslog" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/systemd_types.go b/apis/fluentbit/v1alpha2/plugins/input/systemd_types.go index 288a1a0a8..f4b5c4796 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/systemd_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/systemd_types.go @@ -52,7 +52,7 @@ type Systemd struct { PauseOnChunksOverlimit string `json:"pauseOnChunksOverlimit,omitempty"` } -func (_ *Systemd) Name() string { +func (*Systemd) Name() string { return "systemd" } @@ -77,7 +77,7 @@ func (s *Systemd) Params(_ plugins.SecretLoader) (*params.KVs, error) { if s.MaxEntries > 0 { kvs.Insert("Max_Entries", string(rune(s.MaxEntries))) } - if s.SystemdFilter != nil && len(s.SystemdFilter) > 0 { + if len(s.SystemdFilter) > 0 { for _, v := range s.SystemdFilter { kvs.Insert("Systemd_Filter", v) } diff --git a/apis/fluentbit/v1alpha2/plugins/input/tail_types.go b/apis/fluentbit/v1alpha2/plugins/input/tail_types.go index 63a227099..ef250f5ea 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/tail_types.go +++ b/apis/fluentbit/v1alpha2/plugins/input/tail_types.go @@ -96,7 +96,7 @@ type Tail struct { // DisableInotifyWatcher will disable inotify and use the file stat watcher instead. DisableInotifyWatcher *bool `json:"disableInotifyWatcher,omitempty"` // This will help to reassembly multiline messages originally split by Docker or CRI - //Specify one or Multiline Parser definition to apply to the content. + // Specify one or Multiline Parser definition to apply to the content. MultilineParser string `json:"multilineParser,omitempty"` // Specify the buffering mechanism to use. It can be memory or filesystem // +kubebuilder:validation:Enum:=filesystem;memory @@ -104,13 +104,13 @@ type Tail struct { // Specifies if the input plugin should be paused (stop ingesting new data) when the storage.max_chunks_up value is reached. // +kubebuilder:validation:Enum:=on;off PauseOnChunksOverlimit string `json:"pauseOnChunksOverlimit,omitempty"` - //Skips empty lines in the log file from any further processing or output. + // Skips empty lines in the log file from any further processing or output. SkipEmptyLines *bool `json:"skipEmptyLines,omitempty"` // Threaded mechanism allows input plugin to run in a separate thread which helps to desaturate the main pipeline. Threaded *string `json:"threaded,omitempty"` } -func (_ *Tail) Name() string { +func (*Tail) Name() string { return "tail" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/tcp.go b/apis/fluentbit/v1alpha2/plugins/input/tcp.go index 03a1ca28e..20b84f4f1 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/tcp.go +++ b/apis/fluentbit/v1alpha2/plugins/input/tcp.go @@ -32,7 +32,7 @@ type TCP struct { Separator string `json:"separator,omitempty"` } -func (_ *TCP) Name() string { +func (*TCP) Name() string { return "tcp" } diff --git a/apis/fluentbit/v1alpha2/plugins/input/udp.go b/apis/fluentbit/v1alpha2/plugins/input/udp.go index 18f0601d1..dabcc73ec 100644 --- a/apis/fluentbit/v1alpha2/plugins/input/udp.go +++ b/apis/fluentbit/v1alpha2/plugins/input/udp.go @@ -40,7 +40,7 @@ type UDP struct { Threaded *string `json:"threaded,omitempty"` } -func (_ *UDP) Name() string { +func (*UDP) Name() string { return "udp" } diff --git a/apis/fluentbit/v1alpha2/plugins/multilineparser/multiline_parser_types.go b/apis/fluentbit/v1alpha2/plugins/multilineparser/multiline_parser_types.go index 00844ef8f..bb579eb65 100644 --- a/apis/fluentbit/v1alpha2/plugins/multilineparser/multiline_parser_types.go +++ b/apis/fluentbit/v1alpha2/plugins/multilineparser/multiline_parser_types.go @@ -32,7 +32,7 @@ type Rule struct { Next string `json:"next"` } -func (_ *MultilineParser) Name() string { +func (*MultilineParser) Name() string { return "multilineparser" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/azure_blob_types.go b/apis/fluentbit/v1alpha2/plugins/output/azure_blob_types.go index 5985f88ab..3be14ad47 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/azure_blob_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/azure_blob_types.go @@ -36,7 +36,7 @@ type AzureBlob struct { } // Name implement Section() method -func (_ *AzureBlob) Name() string { +func (*AzureBlob) Name() string { return "azure_blob" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/azure_log_analytics_types.go b/apis/fluentbit/v1alpha2/plugins/output/azure_log_analytics_types.go index f3785f702..020bfcc34 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/azure_log_analytics_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/azure_log_analytics_types.go @@ -27,7 +27,7 @@ type AzureLogAnalytics struct { } // Name implement Section() method -func (_ *AzureLogAnalytics) Name() string { +func (*AzureLogAnalytics) Name() string { return "azure" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/cloud_watch_types.go b/apis/fluentbit/v1alpha2/plugins/output/cloud_watch_types.go index 4a646fba5..ef3d95cfb 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/cloud_watch_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/cloud_watch_types.go @@ -51,7 +51,7 @@ type CloudWatch struct { } // Name implement Section() method -func (_ *CloudWatch) Name() string { +func (*CloudWatch) Name() string { return "cloudwatch_logs" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/data_dog_types.go b/apis/fluentbit/v1alpha2/plugins/output/data_dog_types.go index f7ac27339..0a214aea3 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/data_dog_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/data_dog_types.go @@ -44,7 +44,7 @@ type DataDog struct { // *plugins.HTTP `json:"tls,omitempty"` } -func (_ *DataDog) Name() string { +func (*DataDog) Name() string { return "datadog" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/elasticsearch_types.go b/apis/fluentbit/v1alpha2/plugins/output/elasticsearch_types.go index ad9339370..e2a019202 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/elasticsearch_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/elasticsearch_types.go @@ -111,7 +111,7 @@ type Elasticsearch struct { } // Name implement Section() method -func (_ *Elasticsearch) Name() string { +func (*Elasticsearch) Name() string { return "es" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/file_types.go b/apis/fluentbit/v1alpha2/plugins/output/file_types.go index 388df8d3f..385ba0634 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/file_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/file_types.go @@ -25,7 +25,7 @@ type File struct { Template string `json:"template,omitempty"` } -func (_ *File) Name() string { +func (*File) Name() string { return "file" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/firehose_types.go b/apis/fluentbit/v1alpha2/plugins/output/firehose_types.go index 46c06e8a1..bc8deef46 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/firehose_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/firehose_types.go @@ -39,7 +39,7 @@ type Firehose struct { } // implement Section() method -func (_ *Firehose) Name() string { +func (*Firehose) Name() string { return "kinesis_firehose" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/forward_types.go b/apis/fluentbit/v1alpha2/plugins/output/forward_types.go index cac9cc0f7..99000f1ce 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/forward_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/forward_types.go @@ -45,7 +45,7 @@ type Forward struct { *plugins.Networking `json:"networking,omitempty"` } -func (_ *Forward) Name() string { +func (*Forward) Name() string { return "forward" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/gelf_types.go b/apis/fluentbit/v1alpha2/plugins/output/gelf_types.go index 5c88660ae..4181ed6ea 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/gelf_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/gelf_types.go @@ -40,7 +40,7 @@ type Gelf struct { *plugins.Networking `json:"networking,omitempty"` } -func (_ *Gelf) Name() string { +func (*Gelf) Name() string { return "gelf" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/influxdb_types.go b/apis/fluentbit/v1alpha2/plugins/output/influxdb_types.go index ba58b7e63..9cd239845 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/influxdb_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/influxdb_types.go @@ -47,7 +47,7 @@ type InfluxDB struct { } // Name implement Section() method -func (_ *InfluxDB) Name() string { +func (*InfluxDB) Name() string { return "influxdb" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/loki_types.go b/apis/fluentbit/v1alpha2/plugins/output/loki_types.go index 4886fa4f6..56724683a 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/loki_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/loki_types.go @@ -74,7 +74,7 @@ type Loki struct { } // implement Section() method -func (_ *Loki) Name() string { +func (*Loki) Name() string { return "loki" } @@ -118,7 +118,7 @@ func (l *Loki) Params(sl plugins.SecretLoader) (*params.KVs, error) { } kvs.Insert("tenant_id", id) } - if l.Labels != nil && len(l.Labels) > 0 { + if len(l.Labels) > 0 { // Sort labels to ensure deterministic output sortedLabels := make([]string, len(l.Labels)) copy(sortedLabels, l.Labels) @@ -142,13 +142,13 @@ func (l *Loki) Params(sl plugins.SecretLoader) (*params.KVs, error) { kvs.Insert("labels", strings.Join(sortedLabels, ",")) } - if l.LabelKeys != nil && len(l.LabelKeys) > 0 { + if len(l.LabelKeys) > 0 { kvs.Insert("label_keys", strings.Join(l.LabelKeys, ",")) } if l.LabelMapPath != "" { kvs.Insert("label_map_path", l.LabelMapPath) } - if l.RemoveKeys != nil && len(l.RemoveKeys) > 0 { + if len(l.RemoveKeys) > 0 { kvs.Insert("remove_keys", strings.Join(l.RemoveKeys, ",")) } if l.DropSingleKey != "" { @@ -164,7 +164,7 @@ func (l *Loki) Params(sl plugins.SecretLoader) (*params.KVs, error) { kvs.Insert("tenant_id_key", l.TenantIDKey) } // Handle structured metadata - if l.StructuredMetadata != nil && len(l.StructuredMetadata) > 0 { + if len(l.StructuredMetadata) > 0 { var metadataPairs []string for k, v := range l.StructuredMetadata { metadataPairs = append(metadataPairs, fmt.Sprintf("%s=%s", k, v)) @@ -175,7 +175,7 @@ func (l *Loki) Params(sl plugins.SecretLoader) (*params.KVs, error) { } } // Handle structured metadata keys - if l.StructuredMetadataKeys != nil && len(l.StructuredMetadataKeys) > 0 { + if len(l.StructuredMetadataKeys) > 0 { kvs.Insert("structured_metadata_keys", strings.Join(l.StructuredMetadataKeys, ",")) } if l.TLS != nil { diff --git a/apis/fluentbit/v1alpha2/plugins/output/null_types.go b/apis/fluentbit/v1alpha2/plugins/output/null_types.go index 980dafaaf..1eae4766d 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/null_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/null_types.go @@ -10,11 +10,11 @@ import ( // The null output plugin just throws away events. type Null struct{} -func (_ *Null) Name() string { +func (*Null) Name() string { return "null" } // implement Section() method -func (_ *Null) Params(_ plugins.SecretLoader) (*params.KVs, error) { +func (*Null) Params(_ plugins.SecretLoader) (*params.KVs, error) { return nil, nil } diff --git a/apis/fluentbit/v1alpha2/plugins/output/open_search_types.go b/apis/fluentbit/v1alpha2/plugins/output/open_search_types.go index 182176fd6..dcf02ee16 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/open_search_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/open_search_types.go @@ -104,7 +104,7 @@ type OpenSearch struct { } // Name implement Section() method -func (_ *OpenSearch) Name() string { +func (*OpenSearch) Name() string { return "opensearch" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types.go b/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types.go index 2f6361898..3be7bcb07 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types.go @@ -47,7 +47,7 @@ type OpenTelemetry struct { } // Name implement Section() method -func (_ *OpenTelemetry) Name() string { +func (*OpenTelemetry) Name() string { return "opentelemetry" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types_test.go b/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types_test.go index 80902d14f..734e80c87 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types_test.go +++ b/apis/fluentbit/v1alpha2/plugins/output/open_telemetry_types_test.go @@ -1,13 +1,14 @@ 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" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "testing" ) func TestOpenTelemetry_Params(t *testing.T) { diff --git a/apis/fluentbit/v1alpha2/plugins/output/prometheus_exporter.go b/apis/fluentbit/v1alpha2/plugins/output/prometheus_exporter.go index b6d0c05aa..105541a36 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/prometheus_exporter.go +++ b/apis/fluentbit/v1alpha2/plugins/output/prometheus_exporter.go @@ -20,12 +20,12 @@ type PrometheusExporter struct { // +kubebuilder:validation:Minimum:=1 // +kubebuilder:validation:Maximum:=65535 Port *int32 `json:"port,omitempty"` - //This allows you to add custom labels to all metrics exposed through the prometheus exporter. You may have multiple of these fields + // This allows you to add custom labels to all metrics exposed through the prometheus exporter. You may have multiple of these fields AddLabels map[string]string `json:"addLabels,omitempty"` } // implement Section() method -func (_ *PrometheusExporter) Name() string { +func (*PrometheusExporter) Name() string { return "prometheus_exporter" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/prometheus_remote_write_types.go b/apis/fluentbit/v1alpha2/plugins/output/prometheus_remote_write_types.go index 260550131..cdd8a7e70 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/prometheus_remote_write_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/prometheus_remote_write_types.go @@ -27,15 +27,15 @@ type PrometheusRemoteWrite struct { Port *int32 `json:"port,omitempty"` // Specify an HTTP Proxy. The expected format of this value is http://HOST:PORT. Proxy string `json:"proxy,omitempty"` - //Specify an optional HTTP URI for the target web server, e.g: /something ,default: / + // Specify an optional HTTP URI for the target web server, e.g: /something ,default: / URI string `json:"uri,omitempty"` - //Add a HTTP header key/value pair. Multiple headers can be set. + // Add a HTTP header key/value pair. Multiple headers can be set. Headers map[string]string `json:"headers,omitempty"` - //Log the response payload within the Fluent Bit log,default: false + // Log the response payload within the Fluent Bit log,default: false LogResponsePayload *bool `json:"logResponsePayload,omitempty"` - //This allows you to add custom labels to all metrics exposed through the prometheus exporter. You may have multiple of these fields + // This allows you to add custom labels to all metrics exposed through the prometheus exporter. You may have multiple of these fields AddLabels map[string]string `json:"addLabels,omitempty"` - //Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0,default : 2 + // Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0,default : 2 Workers *int32 `json:"workers,omitempty"` *plugins.TLS `json:"tls,omitempty"` @@ -44,7 +44,7 @@ type PrometheusRemoteWrite struct { } // implement Section() method -func (_ *PrometheusRemoteWrite) Name() string { +func (*PrometheusRemoteWrite) Name() string { return "prometheus_remote_write" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/s3_types.go b/apis/fluentbit/v1alpha2/plugins/output/s3_types.go index d2a836edc..fb857a116 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/s3_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/s3_types.go @@ -72,7 +72,7 @@ type S3 struct { } // Name implement Section() method -func (_ *S3) Name() string { +func (*S3) Name() string { return "s3" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/splunk_types.go b/apis/fluentbit/v1alpha2/plugins/output/splunk_types.go index 23a58f3a3..4910e3871 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/splunk_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/splunk_types.go @@ -38,13 +38,13 @@ type Splunk struct { // When enabled, the record keys and values are set in the top level of the map instead of under the event key. Refer to // the Sending Raw Events section from the docs more details to make this option work properly. SplunkSendRaw *bool `json:"splunkSendRaw,omitempty"` - //Specify the key name that will be used to send a single value as part of the record. + // Specify the key name that will be used to send a single value as part of the record. EventKey string `json:"eventKey,omitempty"` - //Specify the key name that contains the host value. This option allows a record accessors pattern. + // Specify the key name that contains the host value. This option allows a record accessors pattern. EventHost string `json:"eventHost,omitempty"` - //Set the source value to assign to the event data. + // Set the source value to assign to the event data. EventSource string `json:"eventSource,omitempty"` - //Set the sourcetype value to assign to the event data. + // Set the sourcetype value to assign to the event data. EventSourcetype string `json:"eventSourcetype,omitempty"` // Set a record key that will populate 'sourcetype'. If the key is found, it will have precedence // over the value set in event_sourcetype. @@ -54,7 +54,7 @@ type Splunk struct { // Set a record key that will populate the index field. If the key is found, it will have precedence // over the value set in event_index. EventIndexKey string `json:"eventIndexKey,omitempty"` - //Set event fields for the record. This option is an array and the format is "key_name + // Set event fields for the record. This option is an array and the format is "key_name // record_accessor_pattern". EventFields []string `json:"eventFields,omitempty"` @@ -66,7 +66,7 @@ type Splunk struct { } // Name implement Section() method -func (_ *Splunk) Name() string { +func (*Splunk) Name() string { return "splunk" } @@ -136,7 +136,7 @@ func (o *Splunk) Params(sl plugins.SecretLoader) (*params.KVs, error) { if o.EventIndexKey != "" { kvs.Insert("event_index_key", o.EventIndexKey) } - if o.EventFields != nil && len(o.EventFields) > 0 { + if len(o.EventFields) > 0 { for _, v := range o.EventFields { kvs.Insert("event_field", v) } diff --git a/apis/fluentbit/v1alpha2/plugins/output/stackdriver_types.go b/apis/fluentbit/v1alpha2/plugins/output/stackdriver_types.go index 9db25c898..bb1ff2aa0 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/stackdriver_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/stackdriver_types.go @@ -55,12 +55,12 @@ type Stackdriver struct { Workers *int32 `json:"workers,omitempty"` // A custom regex to extract fields from the local_resource_id of the logs CustomK8sRegex string `json:"customK8sRegex,omitempty"` - // Optional list of comma seperated strings. Setting these fields overrides the Stackdriver monitored resource API values + // Optional list of comma separated strings. Setting these fields overrides the Stackdriver monitored resource API values ResourceLabels []string `json:"resourceLabels,omitempty"` } // Name implement Section() method -func (_ *Stackdriver) Name() string { +func (*Stackdriver) Name() string { return "stackdriver" } @@ -117,7 +117,7 @@ func (o *Stackdriver) Params(sl plugins.SecretLoader) (*params.KVs, error) { if o.LabelsKey != "" { kvs.Insert("labels_key", o.LabelsKey) } - if o.Labels != nil && len(o.Labels) > 0 { + if len(o.Labels) > 0 { kvs.Insert("labels", strings.Join(o.Labels, ",")) } if o.LogNameKey != "" { @@ -138,7 +138,7 @@ func (o *Stackdriver) Params(sl plugins.SecretLoader) (*params.KVs, error) { if o.CustomK8sRegex != "" { kvs.Insert("custom_k8s_regex", o.CustomK8sRegex) } - if o.ResourceLabels != nil && len(o.ResourceLabels) > 0 { + if len(o.ResourceLabels) > 0 { kvs.Insert("resource_labels", strings.Join(o.ResourceLabels, ",")) } return kvs, nil diff --git a/apis/fluentbit/v1alpha2/plugins/output/stdout_types.go b/apis/fluentbit/v1alpha2/plugins/output/stdout_types.go index 84ff6a1d5..635686575 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/stdout_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/stdout_types.go @@ -20,7 +20,7 @@ type Stdout struct { JsonDateFormat string `json:"jsonDateFormat,omitempty"` } -func (_ *Stdout) Name() string { +func (*Stdout) Name() string { return "stdout" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/syslog_types.go b/apis/fluentbit/v1alpha2/plugins/output/syslog_types.go index 5d7abad5f..883a33e5e 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/syslog_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/syslog_types.go @@ -49,7 +49,7 @@ type Syslog struct { TotalLimitSize string `json:"totalLimitSize,omitempty"` } -func (_ *Syslog) Name() string { +func (*Syslog) Name() string { return "syslog" } diff --git a/apis/fluentbit/v1alpha2/plugins/output/tcp_types.go b/apis/fluentbit/v1alpha2/plugins/output/tcp_types.go index b86ea8db5..0b9316c2f 100644 --- a/apis/fluentbit/v1alpha2/plugins/output/tcp_types.go +++ b/apis/fluentbit/v1alpha2/plugins/output/tcp_types.go @@ -34,7 +34,7 @@ type TCP struct { *plugins.Networking `json:"networking,omitempty"` } -func (_ *TCP) Name() string { +func (*TCP) Name() string { return "tcp" } diff --git a/apis/fluentbit/v1alpha2/plugins/parser/json_types.go b/apis/fluentbit/v1alpha2/plugins/parser/json_types.go index 4bb3981b8..de819befc 100644 --- a/apis/fluentbit/v1alpha2/plugins/parser/json_types.go +++ b/apis/fluentbit/v1alpha2/plugins/parser/json_types.go @@ -20,7 +20,7 @@ type JSON struct { TimeKeep *bool `json:"timeKeep,omitempty"` } -func (_ *JSON) Name() string { +func (*JSON) Name() string { return "json" } diff --git a/apis/fluentbit/v1alpha2/plugins/parser/logfmt_types.go b/apis/fluentbit/v1alpha2/plugins/parser/logfmt_types.go index 316bb69ba..98af4fa8f 100644 --- a/apis/fluentbit/v1alpha2/plugins/parser/logfmt_types.go +++ b/apis/fluentbit/v1alpha2/plugins/parser/logfmt_types.go @@ -20,7 +20,7 @@ type Logfmt struct { TimeKeep *bool `json:"timeKeep,omitempty"` } -func (_ *Logfmt) Name() string { +func (*Logfmt) Name() string { return "logfmt" } diff --git a/apis/fluentbit/v1alpha2/plugins/parser/lstv_types.go b/apis/fluentbit/v1alpha2/plugins/parser/lstv_types.go index c7eccb262..f33e5b297 100644 --- a/apis/fluentbit/v1alpha2/plugins/parser/lstv_types.go +++ b/apis/fluentbit/v1alpha2/plugins/parser/lstv_types.go @@ -21,7 +21,7 @@ type LSTV struct { Types string `json:"types,omitempty"` } -func (_ *LSTV) Name() string { +func (*LSTV) Name() string { return "ltsv" } diff --git a/apis/fluentbit/v1alpha2/plugins/parser/regex_types.go b/apis/fluentbit/v1alpha2/plugins/parser/regex_types.go index ce98e1553..f08113328 100644 --- a/apis/fluentbit/v1alpha2/plugins/parser/regex_types.go +++ b/apis/fluentbit/v1alpha2/plugins/parser/regex_types.go @@ -24,7 +24,7 @@ type Regex struct { Types string `json:"types,omitempty"` } -func (_ *Regex) Name() string { +func (*Regex) Name() string { return "regex" } diff --git a/apis/fluentbit/v1alpha2/plugins/secret_types.go b/apis/fluentbit/v1alpha2/plugins/secret_types.go index 1e8db3769..ed185538c 100644 --- a/apis/fluentbit/v1alpha2/plugins/secret_types.go +++ b/apis/fluentbit/v1alpha2/plugins/secret_types.go @@ -45,6 +45,6 @@ func (sl SecretLoader) LoadSecret(s Secret) (string, error) { if v, ok := secret.Data[s.ValueFrom.SecretKeyRef.Key]; !ok { return "", errors.NotFound(fmt.Sprintf("The key %s is not found.", s.ValueFrom.SecretKeyRef.Key)) } else { - return strings.TrimSuffix(fmt.Sprintf("%s", v), "\n"), nil + return strings.TrimSuffix(string(v), "\n"), nil } } diff --git a/apis/fluentd/v1alpha1/fluentd_types.go b/apis/fluentd/v1alpha1/fluentd_types.go index 6ae45338d..7bf728fdf 100644 --- a/apis/fluentd/v1alpha1/fluentd_types.go +++ b/apis/fluentd/v1alpha1/fluentd_types.go @@ -172,7 +172,7 @@ type Fluentd struct { // IsBeingDeleted returns true if a deletion timestamp is set func (fd *Fluentd) IsBeingDeleted() bool { - return !fd.ObjectMeta.DeletionTimestamp.IsZero() + return !fd.DeletionTimestamp.IsZero() } // FluentBitFinalizerName is the name of the fluentbit finalizer @@ -180,17 +180,17 @@ const FluentdFinalizerName = "fluentd.fluent.io" // HasFinalizer returns true if the item has the specified finalizer func (fd *Fluentd) HasFinalizer(finalizerName string) bool { - return slices.Contains(fd.ObjectMeta.Finalizers, finalizerName) + return slices.Contains(fd.Finalizers, finalizerName) } // AddFinalizer adds the specified finalizer func (fd *Fluentd) AddFinalizer(finalizerName string) { - fd.ObjectMeta.Finalizers = append(fd.ObjectMeta.Finalizers, finalizerName) + fd.Finalizers = append(fd.Finalizers, finalizerName) } // RemoveFinalizer removes the specified finalizer func (fd *Fluentd) RemoveFinalizer(finalizerName string) { - fd.ObjectMeta.Finalizers = slices.DeleteFunc(fd.ObjectMeta.Finalizers, func(s string) bool { return s == finalizerName }) + fd.Finalizers = slices.DeleteFunc(fd.Finalizers, func(s string) bool { return s == finalizerName }) } // +kubebuilder:object:root=true diff --git a/apis/fluentd/v1alpha1/helper.go b/apis/fluentd/v1alpha1/helper.go index 88eb2cda8..ef9b6bfab 100644 --- a/apis/fluentd/v1alpha1/helper.go +++ b/apis/fluentd/v1alpha1/helper.go @@ -212,7 +212,7 @@ func (r *CfgResources) filterForInputs( ) error { for n, input := range inputs { inputId := fmt.Sprintf("%s::%s::%s::%s-%d", cfgId, namespace, crdtype, name, n) - input.InputCommon.Id = &inputId + input.Id = &inputId // if input.InputCommon.Tag == nil { // input.InputCommon.Tag = ¶ms.DefaultTag // } @@ -241,9 +241,9 @@ func (r *CfgResources) filterForFilters( ) error { for n, filter := range filters { filterId := fmt.Sprintf("%s::%s::%s::%s-%d", cfgId, namespace, crdtype, name, n) - filter.FilterCommon.Id = &filterId - if filter.FilterCommon.Tag == nil { - filter.FilterCommon.Tag = ¶ms.DefaultTag + filter.Id = &filterId + if filter.Tag == nil { + filter.Tag = ¶ms.DefaultTag } ps, err := filter.Params(sl) @@ -270,9 +270,9 @@ func (r *CfgResources) filterForOutputs( ) error { for n, output := range outputs { outputId := fmt.Sprintf("%s::%s::%s::%s-%d", cfgId, namespace, crdtype, name, n) - output.OutputCommon.Id = &outputId - if output.OutputCommon.Tag == nil { - output.OutputCommon.Tag = ¶ms.DefaultTag + output.Id = &outputId + if output.Tag == nil { + output.Tag = ¶ms.DefaultTag } ps, err := output.Params(sl) diff --git a/apis/fluentd/v1alpha1/plugins/common/buffer_types.go b/apis/fluentd/v1alpha1/plugins/common/buffer_types.go index 61abf81f1..08accd86d 100644 --- a/apis/fluentd/v1alpha1/plugins/common/buffer_types.go +++ b/apis/fluentd/v1alpha1/plugins/common/buffer_types.go @@ -165,16 +165,16 @@ func (b *Buffer) Params(_ plugins.SecretLoader) (*params.PluginStore, error) { ps.InsertPairs("@log_level", fmt.Sprint(*b.LogLevel)) } - if b.FileBuffer != nil && b.FileBuffer.PathSuffix != nil { - ps.InsertPairs("path_suffix", *b.FileBuffer.PathSuffix) + if b.FileBuffer != nil && b.PathSuffix != nil { + ps.InsertPairs("path_suffix", *b.PathSuffix) } if b.FileSingleBuffer != nil { - if b.FileSingleBuffer.CalcNumRecords != nil { - ps.InsertPairs("calc_num_records", *b.FileSingleBuffer.CalcNumRecords) + if b.CalcNumRecords != nil { + ps.InsertPairs("calc_num_records", *b.CalcNumRecords) } - if b.FileSingleBuffer.ChunkFormat != nil { - ps.InsertPairs("chunk_format", *b.FileSingleBuffer.ChunkFormat) + if b.ChunkFormat != nil { + ps.InsertPairs("chunk_format", *b.ChunkFormat) } } diff --git a/apis/fluentd/v1alpha1/plugins/common/common_types.go b/apis/fluentd/v1alpha1/plugins/common/common_types.go index 2ca4e2100..23dedd731 100644 --- a/apis/fluentd/v1alpha1/plugins/common/common_types.go +++ b/apis/fluentd/v1alpha1/plugins/common/common_types.go @@ -75,7 +75,7 @@ type User struct { // Transport defines the commont parameters for the transport plugin type Transport struct { - // The protocal name of this plugin, i.e: tls + // The protocol name of this plugin, i.e: tls Protocol *string `json:"protocol,omitempty"` Version *string `json:"version,omitempty"` @@ -251,7 +251,7 @@ func (s *Security) Params(loader plugins.SecretLoader) (*params.PluginStore, err ps.InsertPairs("allow_anonymous_source", fmt.Sprint(*s.AllowAnonymousSource)) } if s.User != nil { - if s.User.Username != nil && s.User.Password != nil { + if s.Username != nil && s.Password != nil { subchild, _ := s.User.Params(loader) ps.InsertChilds(subchild) } @@ -460,32 +460,32 @@ func (sd *ServiceDiscovery) Params(loader plugins.SecretLoader) (*params.PluginS } if sd.FileServiceDiscovery != nil { - if sd.FileServiceDiscovery.Path != nil { - ps.InsertPairs("path", fmt.Sprint(*sd.FileServiceDiscovery.Path)) + if sd.Path != nil { + ps.InsertPairs("path", fmt.Sprint(*sd.Path)) } - if sd.FileServiceDiscovery.ConfEncoding != nil { - ps.InsertPairs("conf_encoding", fmt.Sprint(*sd.FileServiceDiscovery.ConfEncoding)) + if sd.ConfEncoding != nil { + ps.InsertPairs("conf_encoding", fmt.Sprint(*sd.ConfEncoding)) } } if sd.SrvServiceDiscovery != nil { - if sd.SrvServiceDiscovery.Service != nil { - ps.InsertPairs("service", fmt.Sprint(*sd.SrvServiceDiscovery.Service)) + if sd.Service != nil { + ps.InsertPairs("service", fmt.Sprint(*sd.Service)) } - if sd.SrvServiceDiscovery.Proto != nil { - ps.InsertPairs("proto", fmt.Sprint(*sd.SrvServiceDiscovery.Proto)) + if sd.Proto != nil { + ps.InsertPairs("proto", fmt.Sprint(*sd.Proto)) } - if sd.SrvServiceDiscovery.Hostname != nil { - ps.InsertPairs("hostname", fmt.Sprint(*sd.SrvServiceDiscovery.Hostname)) + if sd.Hostname != nil { + ps.InsertPairs("hostname", fmt.Sprint(*sd.Hostname)) } - if sd.SrvServiceDiscovery.DnsServerHost != nil { - ps.InsertPairs("dns_server_host", fmt.Sprint(*sd.SrvServiceDiscovery.DnsServerHost)) + if sd.DnsServerHost != nil { + ps.InsertPairs("dns_server_host", fmt.Sprint(*sd.DnsServerHost)) } - if sd.SrvServiceDiscovery.Interval != nil { - ps.InsertPairs("interval", fmt.Sprint(*sd.SrvServiceDiscovery.Interval)) + if sd.Interval != nil { + ps.InsertPairs("interval", fmt.Sprint(*sd.Interval)) } - if sd.SrvServiceDiscovery.DnsLookup != nil { - ps.InsertPairs("dns_lookup", fmt.Sprint(*sd.SrvServiceDiscovery.DnsLookup)) + if sd.DnsLookup != nil { + ps.InsertPairs("dns_lookup", fmt.Sprint(*sd.DnsLookup)) } } ps.InsertChilds(childs...) diff --git a/apis/fluentd/v1alpha1/plugins/configmap_types.go b/apis/fluentd/v1alpha1/plugins/configmap_types.go index b7342bf4d..c407340c7 100644 --- a/apis/fluentd/v1alpha1/plugins/configmap_types.go +++ b/apis/fluentd/v1alpha1/plugins/configmap_types.go @@ -31,6 +31,6 @@ func (cl ConfigMapLoader) LoadConfigMap(selector v1.ConfigMapKeySelector) (strin if v, ok := configMap.Data[selector.Key]; !ok { return "", errors.NotFound(fmt.Sprintf("The key %s is not found.", selector.Key)) } else { - return strings.TrimSuffix(fmt.Sprintf("%s", v), "\n"), nil + return strings.TrimSuffix(v, "\n"), nil } } diff --git a/apis/fluentd/v1alpha1/plugins/custom/custom_types.go b/apis/fluentd/v1alpha1/plugins/custom/custom_types.go index 5d390fb0a..fdf0609c4 100644 --- a/apis/fluentd/v1alpha1/plugins/custom/custom_types.go +++ b/apis/fluentd/v1alpha1/plugins/custom/custom_types.go @@ -24,9 +24,8 @@ func (c *CustomPlugin) Params(_ plugins.SecretLoader) (*params.PluginStore, erro } func indentation(config string) string { - splits := strings.Split(config, "\n") var buf bytes.Buffer - for _, split := range splits { + for split := range strings.SplitSeq(config, "\n") { if split != "" { buf.WriteString(fmt.Sprintf(" %s\n", split)) } diff --git a/apis/fluentd/v1alpha1/plugins/filter/types.go b/apis/fluentd/v1alpha1/plugins/filter/types.go index e4e3dd385..99510ae33 100644 --- a/apis/fluentd/v1alpha1/plugins/filter/types.go +++ b/apis/fluentd/v1alpha1/plugins/filter/types.go @@ -148,7 +148,7 @@ func (f *Filter) grepPlugin(parent *params.PluginStore, loader plugins.SecretLoa return parent } -func (f *Filter) recordTransformerPlugin(parent *params.PluginStore, loader plugins.SecretLoader) *params.PluginStore { +func (f *Filter) recordTransformerPlugin(parent *params.PluginStore, _ plugins.SecretLoader) *params.PluginStore { childs := make([]*params.PluginStore, 0) if f.RecordTransformer != nil { if len(f.RecordTransformer.Records) > 0 { diff --git a/apis/fluentd/v1alpha1/plugins/input/types.go b/apis/fluentd/v1alpha1/plugins/input/types.go index 5b2073289..bacb784e2 100644 --- a/apis/fluentd/v1alpha1/plugins/input/types.go +++ b/apis/fluentd/v1alpha1/plugins/input/types.go @@ -352,7 +352,7 @@ func (i *Input) httpPlugin(parent *params.PluginStore, loader plugins.SecretLoad return parent } -func (i *Input) samplePlugin(parent *params.PluginStore, loader plugins.SecretLoader) *params.PluginStore { +func (i *Input) samplePlugin(parent *params.PluginStore, _ plugins.SecretLoader) *params.PluginStore { sampleModel := i.Sample if sampleModel.Tag != nil { parent.InsertPairs("tag", fmt.Sprint(*sampleModel.Tag)) @@ -372,7 +372,7 @@ func (i *Input) samplePlugin(parent *params.PluginStore, loader plugins.SecretLo return parent } -func (i *Input) monitorAgentPlugin(parent *params.PluginStore, loader plugins.SecretLoader) *params.PluginStore { +func (i *Input) monitorAgentPlugin(parent *params.PluginStore, _ plugins.SecretLoader) *params.PluginStore { monitorAgentModel := i.MonitorAgent if monitorAgentModel.Port != nil { parent.InsertPairs("port", fmt.Sprint(*monitorAgentModel.Port)) diff --git a/apis/fluentd/v1alpha1/plugins/output/types.go b/apis/fluentd/v1alpha1/plugins/output/types.go index 574d0f19d..703604c94 100644 --- a/apis/fluentd/v1alpha1/plugins/output/types.go +++ b/apis/fluentd/v1alpha1/plugins/output/types.go @@ -93,16 +93,16 @@ func (o *Output) Params(loader plugins.SecretLoader) (*params.PluginStore, error ps.InsertPairs("tag", fmt.Sprint(*o.Tag)) } - if o.BufferSection.Buffer != nil { - child, _ := o.BufferSection.Buffer.Params(loader) + if o.Buffer != nil { + child, _ := o.Buffer.Params(loader) childs = append(childs, child) } - if o.BufferSection.Inject != nil { - child, _ := o.BufferSection.Inject.Params(loader) + if o.Inject != nil { + child, _ := o.Inject.Params(loader) childs = append(childs, child) } - if o.BufferSection.Format != nil { - child, _ := o.BufferSection.Format.Params(loader) + if o.Format != nil { + child, _ := o.Format.Params(loader) childs = append(childs, child) } @@ -128,7 +128,7 @@ func (o *Output) Params(loader plugins.SecretLoader) (*params.PluginStore, error Type: ¶ms.DefaultFormatType, }, } - child, _ := o.BufferSection.Format.Params(loader) + child, _ := o.Format.Params(loader) ps.InsertChilds(child) } return o.kafka2Plugin(ps, loader), nil @@ -653,7 +653,7 @@ func (o *Output) opensearchPlugin(parent *params.PluginStore, loader plugins.Sec return parent, nil } -func (o *Output) kafka2Plugin(parent *params.PluginStore, loader plugins.SecretLoader) *params.PluginStore { +func (o *Output) kafka2Plugin(parent *params.PluginStore, _ plugins.SecretLoader) *params.PluginStore { if o.Kafka.Brokers != nil { parent.InsertPairs("brokers", fmt.Sprint(*o.Kafka.Brokers)) } @@ -771,7 +771,7 @@ func (o *Output) lokiPlugin(parent *params.PluginStore, loader plugins.SecretLoa } parent.InsertPairs("tenant", id) } - if o.Loki.Labels != nil && len(o.Loki.Labels) > 0 { + if len(o.Loki.Labels) > 0 { labels := make(map[string]string) for _, l := range o.Loki.Labels { key, value, found := strings.Cut(l, "=") @@ -789,10 +789,10 @@ func (o *Output) lokiPlugin(parent *params.PluginStore, loader plugins.SecretLoa } } } - if o.Loki.RemoveKeys != nil && len(o.Loki.RemoveKeys) > 0 { + if len(o.Loki.RemoveKeys) > 0 { parent.InsertPairs("remove_keys", strings.Join(o.Loki.RemoveKeys, ",")) } - if o.Loki.LabelKeys != nil && len(o.Loki.LabelKeys) > 0 { + if len(o.Loki.LabelKeys) > 0 { ps := params.NewPluginStore("label") for _, n := range o.Loki.LabelKeys { ps.InsertPairs(n, n) @@ -1086,14 +1086,14 @@ func (o *Output) datadogPlugin(parent *params.PluginStore, sl plugins.SecretLoad return parent } -func (o *Output) copyPlugin(parent *params.PluginStore, sl plugins.SecretLoader) *params.PluginStore { +func (o *Output) copyPlugin(parent *params.PluginStore, _ plugins.SecretLoader) *params.PluginStore { if o.Copy.CopyMode != nil { parent.InsertPairs("copy_mode", fmt.Sprint(*o.Copy.CopyMode)) } return parent } -func (o *Output) nullPlugin(parent *params.PluginStore, sl plugins.SecretLoader) *params.PluginStore { +func (o *Output) nullPlugin(parent *params.PluginStore, _ plugins.SecretLoader) *params.PluginStore { if o.Null.NeverFlush != nil { parent.InsertPairs("never_flush", fmt.Sprint(*o.Null.NeverFlush)) } diff --git a/apis/fluentd/v1alpha1/plugins/params/model.go b/apis/fluentd/v1alpha1/plugins/params/model.go index 258bde471..8761e54d6 100644 --- a/apis/fluentd/v1alpha1/plugins/params/model.go +++ b/apis/fluentd/v1alpha1/plugins/params/model.go @@ -194,7 +194,7 @@ func (ps *PluginStore) processBody(buf *bytes.Buffer) { // write the tail directive to the buffer, i.e.: func (ps *PluginStore) processTail(buf *bytes.Buffer) { - buf.WriteString(fmt.Sprintf("%s\n", ps.PrefixWhitespaces, ps.Name)) + fmt.Fprintf(buf, "%s\n", ps.PrefixWhitespaces, ps.Name) } // decide to return the head directive with our without a filter - or diff --git a/apis/fluentd/v1alpha1/plugins/secret_types.go b/apis/fluentd/v1alpha1/plugins/secret_types.go index d633158ce..6a2609031 100644 --- a/apis/fluentd/v1alpha1/plugins/secret_types.go +++ b/apis/fluentd/v1alpha1/plugins/secret_types.go @@ -48,6 +48,6 @@ func (sl SecretLoaderStruct) LoadSecret(s Secret) (string, error) { if v, ok := secret.Data[s.ValueFrom.SecretKeyRef.Key]; !ok { return "", errors.NotFound(fmt.Sprintf("The key %s is not found.", s.ValueFrom.SecretKeyRef.Key)) } else { - return strings.TrimSuffix(fmt.Sprintf("%s", v), "\n"), nil + return strings.TrimSuffix(string(v), "\n"), nil } } diff --git a/apis/fluentd/v1alpha1/tests/helper_test.go b/apis/fluentd/v1alpha1/tests/helper_test.go index 148680f2f..c113c0d9e 100644 --- a/apis/fluentd/v1alpha1/tests/helper_test.go +++ b/apis/fluentd/v1alpha1/tests/helper_test.go @@ -164,10 +164,11 @@ func Test_ClusterCfgOutput2CopyESDataStream(t *testing.T) { clusterOutputs := []fluentdv1alpha1.ClusterOutput{FluentdclusterOutput2CopyESDataStream} clustercfgResources, _ := psr.PatchAndFilterClusterLevelResources(sl, FluentdClusterFluentdConfig1.GetCfgId(), []fluentdv1alpha1.ClusterInput{}, clusterFilters, clusterOutputs) err = psr.IdentifyCopyAndPatchOutput(clustercfgResources) + g.Expect(err).NotTo(HaveOccurred()) err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources) g.Expect(err).NotTo(HaveOccurred()) - for i := 0; i < maxRuntimes; i++ { + for range maxRuntimes { config, errs := psr.RenderMainConfig(false) g.Expect(errs).NotTo(HaveOccurred()) g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-copy-es-data-stream.cfg"))).To(Equal(config)) @@ -210,9 +211,9 @@ func Test_ClusterCfgOutput2OpenSearch(t *testing.T) { err = psr.WithCfgResources(*clustercfgRouter.Label, clustercfgResources) g.Expect(err).NotTo(HaveOccurred()) - for i := 0; i < maxRuntimes; i++ { + for range maxRuntimes { config, errs := psr.RenderMainConfig(false) - //fmt.Println(config) + // fmt.Println(config) g.Expect(errs).NotTo(HaveOccurred()) g.Expect(string(getExpectedCfg("./expected/fluentd-cluster-cfg-output-opensearch.cfg"))).To(Equal(config)) } @@ -700,7 +701,7 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) { Name: "filter1", Namespace: "testnamespace", }, - Spec: fluentdv1alpha1.FilterSpec(filterspec1), + Spec: filterspec1, }, { TypeMeta: metav1.TypeMeta{ @@ -711,7 +712,7 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) { Name: "filter2", Namespace: "testnamespace", }, - Spec: fluentdv1alpha1.FilterSpec(filterspec2), + Spec: filterspec2, }, { TypeMeta: metav1.TypeMeta{ @@ -722,7 +723,7 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) { Name: "filter3", Namespace: "testnamespace", }, - Spec: fluentdv1alpha1.FilterSpec(filterspec3), + Spec: filterspec3, }, } @@ -736,7 +737,7 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) { Name: "output1", Namespace: "testnamespace", }, - Spec: fluentdv1alpha1.OutputSpec(outputspec1), + Spec: outputspec1, }, { TypeMeta: metav1.TypeMeta{ @@ -747,7 +748,7 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) { Name: "output2", Namespace: "testnamespace", }, - Spec: fluentdv1alpha1.OutputSpec(outputspec2), + Spec: outputspec2, }, { TypeMeta: metav1.TypeMeta{ @@ -758,7 +759,7 @@ func Test_DuplicateRemovalCRSpecs(t *testing.T) { Name: "output3", Namespace: "testnamespace", }, - Spec: fluentdv1alpha1.OutputSpec(outputspec3), + Spec: outputspec3, }, } @@ -860,6 +861,6 @@ func (sl SecretLoaderStruct) LoadSecret(s plugins.Secret) (string, error) { if v, ok := secret.StringData[s.ValueFrom.SecretKeyRef.Key]; !ok { return "", errors.NotFound(fmt.Sprintf("The key %s is not found.", s.ValueFrom.SecretKeyRef.Key)) } else { - return strings.TrimSuffix(fmt.Sprintf("%s", v), "\n"), nil + return strings.TrimSuffix(v, "\n"), nil } } diff --git a/apis/fluentd/v1alpha1/tests/tools.go b/apis/fluentd/v1alpha1/tests/tools.go index 3dec6e13c..0c2840559 100644 --- a/apis/fluentd/v1alpha1/tests/tools.go +++ b/apis/fluentd/v1alpha1/tests/tools.go @@ -27,12 +27,12 @@ metadata: app.kubernetes.io/name: fluentd spec: globalInputs: - - forward: - bind: 0.0.0.0 + - forward: + bind: 0.0.0.0 port: 24224 replicas: 1 image: ghcr.io/fluent/fluent-operator/fluentd:v1.17.1 - fluentdCfgSelector: + fluentdCfgSelector: matchLabels: config.fluentd.fluent.io/enabled: "true" ` @@ -97,7 +97,7 @@ metadata: app.kubernetes.io/name: fluentd spec: globalInputs: - - tail: + - tail: tag: "foo.bar" path: /var/log/test.log emitUnmatchedLines: true @@ -133,7 +133,7 @@ spec: - /var/log/bar replicas: 1 image: ghcr.io/fluent/fluent-operator/fluentd:v1.17.1 - fluentdCfgSelector: + fluentdCfgSelector: matchLabels: config.fluentd.fluent.io/enabled: "true" ` @@ -147,7 +147,7 @@ metadata: labels: config.fluentd.fluent.io/enabled: "true" spec: - watchedNamespaces: + watchedNamespaces: - kube-system - default clusterFilterSelector: @@ -167,7 +167,7 @@ metadata: labels: config.fluentd.fluent.io/enabled: "true" spec: - watchedNamespaces: + watchedNamespaces: - kube-system - default clusterOutputSelector: @@ -240,8 +240,8 @@ metadata: name: fluentd-filter labels: filter.fluentd.fluent.io/enabled: "true" -spec: - filters: +spec: + filters: - recordTransformer: enableRuby: true records: @@ -258,8 +258,8 @@ metadata: namespace: fluent labels: filter.fluentd.fluent.io/enabled: "true" -spec: - filters: +spec: + filters: - recordTransformer: records: - key: loki-tenant @@ -297,8 +297,8 @@ metadata: name: fluentd-output labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - stdout: {} buffer: type: file @@ -321,8 +321,8 @@ metadata: name: fluentd-output labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - stdout: {} buffer: type: memory @@ -344,8 +344,8 @@ metadata: name: fluentd-output-stdout labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - stdout: {} tag: foo.* ` @@ -358,8 +358,8 @@ metadata: name: fluentd-output-es labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - elasticsearch: host: elasticsearch-logging-data.kubesphere-logging-system.svc port: 9200 @@ -375,8 +375,8 @@ metadata: name: fluentd-output-es labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - elasticsearchDataStream: host: elasticsearch-logging-data.kubesphere-logging-system.svc port: 9200 @@ -443,7 +443,7 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "es" -spec: +spec: outputs: - copy: copyMode: no_copy @@ -479,7 +479,7 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "es" -spec: +spec: outputs: - copy: copyMode: no_copy @@ -508,7 +508,7 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "es" -spec: +spec: outputs: - elasticsearch: host: elasticsearch-logging-data.kubesphere-logging-system.svc @@ -534,7 +534,7 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "es" -spec: +spec: outputs: - elasticsearch: host: elasticsearch-logging-data.kubesphere-logging-system.svc @@ -552,8 +552,8 @@ metadata: name: fluentd-output-opensearch labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - opensearch: host: opensearch-logging-data.kubesphere-logging-system.svc port: 9200 @@ -569,8 +569,8 @@ metadata: name: fluentd-output-kafka labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - kafka: brokers: my-cluster-kafka-bootstrap.default.svc:9091,my-cluster-kafka-bootstrap.default.svc:9092,my-cluster-kafka-bootstrap.default.svc:9093 useEventTime: true @@ -584,8 +584,8 @@ metadata: name: fluentd-output-loki labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - loki: url: http://loki-logging-data.kubesphere-logging-system.svc:3100 extractKubernetesLabels: true @@ -655,8 +655,8 @@ metadata: name: fluentd-output-loki labels: output.fluentd.fluent.io/enabled: "loki" -spec: - outputs: +spec: + outputs: - loki: url: http://loki-logging-data.kubesphere-logging-system.svc:3100 extractKubernetesLabels: true @@ -684,8 +684,8 @@ metadata: labels: output.fluentd.fluent.io/enabled: "true" output.fluentd.fluent.io/role: "log-operator" -spec: - outputs: +spec: + outputs: - elasticsearch: host: elasticsearch-logging-data.kubesphere-logging-system.svc port: 9200 @@ -702,8 +702,8 @@ metadata: labels: output.fluentd.fluent.io/enabled: "true" output.fluentd.fluent.io/scope: "cluster" -spec: - outputs: +spec: + outputs: - elasticsearch: host: elasticsearch-logging-data.kubesphere-logging-system.svc port: 9200 @@ -719,8 +719,8 @@ metadata: labels: output.fluentd.fluent.io/scope: "cluster" output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - customPlugin: config: | @@ -759,7 +759,7 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "es" -spec: +spec: outputs: - copy: copyMode: no_copy @@ -784,7 +784,7 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "es" -spec: +spec: outputs: - copy: copyMode: no_copy @@ -853,8 +853,8 @@ metadata: name: fluentd-output-datadog labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - datadog: host: http-intake.logs.datadoghq.com port: 443 @@ -870,8 +870,8 @@ metadata: namespace: fluent labels: output.fluentd.fluent.io/enabled: "true" -spec: - outputs: +spec: + outputs: - nullPlugin: neverFlush: false ` @@ -884,7 +884,7 @@ metadata: labels: output.fluentd.fluent.io/enabled: "true" spec: - outputs: + outputs: - copy: copyMode: no_copy - stdout: {} @@ -1034,50 +1034,57 @@ var ( func init() { once.Do( func() { - ParseIntoObject(FluentdRaw, &Fluentd) - ParseIntoObject(FluentdInputTailRaw, &FluentdInputTail) - ParseIntoObject(FluentdInputSampleRaw, &FluentdInputSample) - ParseIntoObject(FluentdInputMonitorAgentRaw, &FluentdInputMonitorAgent) - ParseIntoObject(FluentdClusterOutputTagRaw, &FluentdClusterOutputTag) - ParseIntoObject(FluentdClusterFluentdConfig1Raw, &FluentdClusterFluentdConfig1) - ParseIntoObject(FluentdClusterFluentdConfig2Raw, &FluentdClusterFluentdConfig2) - ParseIntoObject(FluentdConfigUser1Raw, &FluentdConfigUser1) - ParseIntoObject(FluentdConfig1Raw, &FluentdConfig1) - ParseIntoObject(FluentdConfig2Raw, &FluentdConfig2) - ParseIntoObject(FluentdClusterFilter1Raw, &FluentdClusterFilter1) - ParseIntoObject(FluentdFilterRaw, &FluentdFilter) - ParseIntoObject(FluentdClusterRecordTransformerRaw, &FluentdClusterRecordTransformerFilter) - ParseIntoObject(FluentdClusterOutputClusterRaw, &FluentdClusterOutputCluster) - ParseIntoObject(FluentdClusterOutputLogOperatorRaw, &FluentdClusterOutputLogOperator) - ParseIntoObject(FluentdClusterOutputBufferRaw, &FluentdClusterOutputBuffer) - ParseIntoObject(FluentdClusterOutputMemoryBufferRaw, &FluentdClusterOutputMemoryBuffer) - ParseIntoObject(FluentdclusterOutput2ESRaw, &FluentdclusterOutput2ES) - ParseIntoObject(FluentdclusterOutput2ESDataStreamRaw, &FluentdclusterOutput2ESDataStream) - ParseIntoObject(FluentdclusterOutput2CopyESDataStreamRaw, &FluentdclusterOutput2CopyESDataStream) - ParseIntoObject(FluentdOutput2ES1Raw, &FluentdOutput2ES1) - ParseIntoObject(FluentdOutput2ES2Raw, &FluentdOutput2ES2) - ParseIntoObject(FluentdOutput2ES3Raw, &FluentdOutput2ES3) - ParseIntoObject(FluentdOutput2ES4Raw, &FluentdOutput2ES4) - ParseIntoObject(FluentdclusterOutput2OpenSearchRaw, &FluentdclusterOutput2OpenSearch) - ParseIntoObject(FluentdClusterOutput2kafkaRaw, &FluentdClusterOutput2kafka) - ParseIntoObject(FluentdClusterOutput2LokiRaw, &FluentdClusterOutput2Loki) - ParseIntoObject(FluentdClusterOutput2Loki1Raw, &FluentdClusterOutput2Loki1) - ParseIntoObject(FluentdOutputUser1Raw, &FluentdOutputUser1) - ParseIntoObject(FluentdClusterOutputCustomRaw, &FluentdClusterOutputCustom) - ParseIntoObject(FluentdClusterOutput2CloudWatchRaw, &FluentdClusterOutput2CloudWatch) - ParseIntoObject(FluentdClusterOutput2DatadogRaw, &FluentdClusterOutput2Datadog) - ParseIntoObject(FluentdClusterOutput2NullRaw, &FluentdClusterOutput2Null) - ParseIntoObject(FluentdClusterOutputCopy2StdoutAndLokiRaw, &FluentdClusterOutputCopy2StdoutAndLoki) - ParseIntoObject(FluentdOutputMixedCopy1Raw, &FluentdOutputMixedCopy1) - ParseIntoObject(FluentdOutputMixedCopy2Raw, &FluentdOutputMixedCopy2) - ParseIntoObject(FluentdOutputMixedCopy3Raw, &FluentdOutputMixedCopy3) - ParseIntoObject(esCredentialsRaw, &esCredentials) - ParseIntoObject(lokiHttpCredentialsRaw, &lokiHttpCredentials) - ParseIntoObject(lokiTenantNameRaw, &lokiTenantName) + MustParseIntoObject(FluentdRaw, &Fluentd) + MustParseIntoObject(FluentdInputTailRaw, &FluentdInputTail) + MustParseIntoObject(FluentdInputSampleRaw, &FluentdInputSample) + MustParseIntoObject(FluentdInputMonitorAgentRaw, &FluentdInputMonitorAgent) + MustParseIntoObject(FluentdClusterOutputTagRaw, &FluentdClusterOutputTag) + MustParseIntoObject(FluentdClusterFluentdConfig1Raw, &FluentdClusterFluentdConfig1) + MustParseIntoObject(FluentdClusterFluentdConfig2Raw, &FluentdClusterFluentdConfig2) + MustParseIntoObject(FluentdConfigUser1Raw, &FluentdConfigUser1) + MustParseIntoObject(FluentdConfig1Raw, &FluentdConfig1) + MustParseIntoObject(FluentdConfig2Raw, &FluentdConfig2) + MustParseIntoObject(FluentdClusterFilter1Raw, &FluentdClusterFilter1) + MustParseIntoObject(FluentdFilterRaw, &FluentdFilter) + MustParseIntoObject(FluentdClusterRecordTransformerRaw, &FluentdClusterRecordTransformerFilter) + MustParseIntoObject(FluentdClusterOutputClusterRaw, &FluentdClusterOutputCluster) + MustParseIntoObject(FluentdClusterOutputLogOperatorRaw, &FluentdClusterOutputLogOperator) + MustParseIntoObject(FluentdClusterOutputBufferRaw, &FluentdClusterOutputBuffer) + MustParseIntoObject(FluentdClusterOutputMemoryBufferRaw, &FluentdClusterOutputMemoryBuffer) + MustParseIntoObject(FluentdclusterOutput2ESRaw, &FluentdclusterOutput2ES) + MustParseIntoObject(FluentdclusterOutput2ESDataStreamRaw, &FluentdclusterOutput2ESDataStream) + MustParseIntoObject(FluentdclusterOutput2CopyESDataStreamRaw, &FluentdclusterOutput2CopyESDataStream) + MustParseIntoObject(FluentdOutput2ES1Raw, &FluentdOutput2ES1) + MustParseIntoObject(FluentdOutput2ES2Raw, &FluentdOutput2ES2) + MustParseIntoObject(FluentdOutput2ES3Raw, &FluentdOutput2ES3) + MustParseIntoObject(FluentdOutput2ES4Raw, &FluentdOutput2ES4) + MustParseIntoObject(FluentdclusterOutput2OpenSearchRaw, &FluentdclusterOutput2OpenSearch) + MustParseIntoObject(FluentdClusterOutput2kafkaRaw, &FluentdClusterOutput2kafka) + MustParseIntoObject(FluentdClusterOutput2LokiRaw, &FluentdClusterOutput2Loki) + MustParseIntoObject(FluentdClusterOutput2Loki1Raw, &FluentdClusterOutput2Loki1) + MustParseIntoObject(FluentdOutputUser1Raw, &FluentdOutputUser1) + MustParseIntoObject(FluentdClusterOutputCustomRaw, &FluentdClusterOutputCustom) + MustParseIntoObject(FluentdClusterOutput2CloudWatchRaw, &FluentdClusterOutput2CloudWatch) + MustParseIntoObject(FluentdClusterOutput2DatadogRaw, &FluentdClusterOutput2Datadog) + MustParseIntoObject(FluentdClusterOutput2NullRaw, &FluentdClusterOutput2Null) + MustParseIntoObject(FluentdClusterOutputCopy2StdoutAndLokiRaw, &FluentdClusterOutputCopy2StdoutAndLoki) + MustParseIntoObject(FluentdOutputMixedCopy1Raw, &FluentdOutputMixedCopy1) + MustParseIntoObject(FluentdOutputMixedCopy2Raw, &FluentdOutputMixedCopy2) + MustParseIntoObject(FluentdOutputMixedCopy3Raw, &FluentdOutputMixedCopy3) + MustParseIntoObject(esCredentialsRaw, &esCredentials) + MustParseIntoObject(lokiHttpCredentialsRaw, &lokiHttpCredentials) + MustParseIntoObject(lokiTenantNameRaw, &lokiTenantName) }, ) } +func MustParseIntoObject(data string, obj interface{}) { + err := ParseIntoObject(data, obj) + if err != nil { + panic(err) + } +} + func ParseIntoObject(data string, obj interface{}) error { body, err := yaml.YAMLToJSON([]byte(data)) if err != nil { diff --git a/cmd/doc-gen/main.go b/cmd/doc-gen/main.go index 7a63e73dc..0f0462116 100644 --- a/cmd/doc-gen/main.go +++ b/cmd/doc-gen/main.go @@ -88,7 +88,7 @@ func plugins(docsLocations []DocumentsLocation) { return err } if strings.HasSuffix(path, ".go") { - var flag bool = true + var flag = true for _, keyword := range unincludedKeyWords { flag = flag && !strings.Contains(path, keyword) } @@ -114,7 +114,7 @@ func plugins(docsLocations []DocumentsLocation) { buffer.WriteString("| Field | Description | Scheme |\n") buffer.WriteString("| ----- | ----------- | ------ |\n") - fields := t[1:(len(t))] + fields := t[1:] for _, f := range fields { buffer.WriteString(fmt.Sprintf("| %s | %s | %s |\n", f.Name, f.Doc, f.Type)) } @@ -140,7 +140,7 @@ func plugins(docsLocations []DocumentsLocation) { fmt.Printf("Error while generating documentation: %s\n", err.Error()) } - f.WriteString(buffer.String()) + _, _ = f.WriteString(buffer.String()) } } } @@ -180,7 +180,7 @@ func crds(docsLocations []DocumentsLocation) { buffer.WriteString("| Field | Description | Scheme |\n") buffer.WriteString("| ----- | ----------- | ------ |\n") - fields := t[1:(len(t))] + fields := t[1:] for _, f := range fields { buffer.WriteString(fmt.Sprintf("| %s | %s | %s |\n", f.Name, f.Doc, f.Type)) } @@ -190,7 +190,7 @@ func crds(docsLocations []DocumentsLocation) { } f, _ := os.Create(fmt.Sprintf("./docs/%s.md", dl.name)) - f.WriteString(fmt.Sprintf(firstParagraph, dl.name) + buffer.String()) + _, _ = f.WriteString(fmt.Sprintf(firstParagraph, dl.name) + buffer.String()) } } @@ -204,7 +204,7 @@ func genDocDirs(docPath string) error { func toSectionLink(name string) string { name = strings.ToLower(name) - name = strings.Replace(name, " ", "-", -1) + name = strings.ReplaceAll(name, " ", "-") return name } @@ -231,7 +231,18 @@ type KubeTypes []Pair func ParseDocumentationFrom(src string, dl_name string, shouldSort bool) []KubeTypes { var docForTypes []KubeTypes - pkg := astFrom(src) + fset := token.NewFileSet() + f, err := parser.ParseFile(fset, src, nil, parser.ParseComments) + if err != nil { + fmt.Println(err) + return nil + } + + pkg, err := doc.NewFromFiles(fset, []*ast.File{f}, "") + if err != nil { + fmt.Println(err) + return nil + } var types []*doc.Type for _, kubType := range pkg.Types { @@ -266,22 +277,6 @@ func ParseDocumentationFrom(src string, dl_name string, shouldSort bool) []KubeT return docForTypes } -func astFrom(filePath string) *doc.Package { - fset := token.NewFileSet() - m := make(map[string]*ast.File) - - f, err := parser.ParseFile(fset, filePath, nil, parser.ParseComments) - if err != nil { - fmt.Println(err) - return nil - } - - m[filePath] = f - apkg, _ := ast.NewPackage(fset, m, nil, nil) - - return doc.New(apkg, "", 0) -} - func fmtRawDoc(rawDoc string) string { var buffer bytes.Buffer delPrevChar := func() { @@ -290,7 +285,7 @@ func fmtRawDoc(rawDoc string) string { } } - for _, line := range strings.Split(rawDoc, "\n") { + for line := range strings.SplitSeq(rawDoc, "\n") { line = strings.TrimRight(line, " ") leading := strings.TrimLeft(line, " ") switch { @@ -305,11 +300,11 @@ func fmtRawDoc(rawDoc string) string { } postDoc := strings.TrimRight(buffer.String(), "\n") - postDoc = strings.Replace(postDoc, "\\\"", "\"", -1) // replace user's \" to " - postDoc = strings.Replace(postDoc, "\"", "\\\"", -1) // Escape " - postDoc = strings.Replace(postDoc, "\n", "\\n", -1) - postDoc = strings.Replace(postDoc, "\t", "\\t", -1) - postDoc = strings.Replace(postDoc, "|", "\\|", -1) + postDoc = strings.ReplaceAll(postDoc, "\\\"", "\"") // replace user's \" to " + postDoc = strings.ReplaceAll(postDoc, "\"", "\\\"") // Escape " + postDoc = strings.ReplaceAll(postDoc, "\n", "\\n") + postDoc = strings.ReplaceAll(postDoc, "\t", "\\t") + postDoc = strings.ReplaceAll(postDoc, "|", "\\|") return postDoc } @@ -403,21 +398,19 @@ func fieldName(field *ast.Field) string { } func fieldType(typ ast.Expr, dl_name string) string { - switch typ.(type) { + switch typ := typ.(type) { case *ast.Ident: - return toLink(typ.(*ast.Ident).Name, dl_name) + return toLink(typ.Name, dl_name) case *ast.StarExpr: - return "*" + fieldType(typ.(*ast.StarExpr).X, dl_name) + return "*" + fieldType(typ.X, dl_name) case *ast.SelectorExpr: - e := typ.(*ast.SelectorExpr) - pkg := e.X.(*ast.Ident) - t := e.Sel + pkg := typ.X.(*ast.Ident) + t := typ.Sel return toLink(pkg.Name+"."+t.Name, dl_name) case *ast.ArrayType: - return "[]" + fieldType(typ.(*ast.ArrayType).Elt, dl_name) + return "[]" + fieldType(typ.Elt, dl_name) case *ast.MapType: - mapType := typ.(*ast.MapType) - return "map[" + toLink(fieldType(mapType.Key, dl_name), dl_name) + "]" + toLink(fieldType(mapType.Value, dl_name), dl_name) + return "map[" + toLink(fieldType(typ.Key, dl_name), dl_name) + "]" + toLink(fieldType(typ.Value, dl_name), dl_name) default: return "" } diff --git a/cmd/fluent-manager/main.go b/cmd/fluent-manager/main.go index 7035fad7e..ea6e7e6ac 100644 --- a/cmd/fluent-manager/main.go +++ b/cmd/fluent-manager/main.go @@ -103,10 +103,9 @@ func main() { if watchNamespaces != "" { config := cache.Config{} namespacedController = true - namespaces := strings.Split(watchNamespaces, ",") ctrlOpts.Cache.DefaultNamespaces = make(map[string]cache.Config) - for _, namespace := range namespaces { + for namespace := range strings.SplitSeq(watchNamespaces, ",") { ctrlOpts.Cache.DefaultNamespaces[namespace] = config } } @@ -119,11 +118,12 @@ func main() { fluentBitEnabled, fluentdEnabled := true, true if disabledControllers != "" { - if disabledControllers == fluentBitName { + switch disabledControllers { + case fluentBitName: fluentBitEnabled = false - } else if disabledControllers == fluentdName { + case fluentdName: fluentdEnabled = false - } else { + default: setupLog.Error(errors.New("incorrect value for `-disable-component-controllers` and it will not be proceeded (possible values are: fluent-bit, fluentd)"), "") } } diff --git a/cmd/fluent-watcher/fluentbit/main.go b/cmd/fluent-watcher/fluentbit/main.go index bedb7728f..b585e4d6a 100644 --- a/cmd/fluent-watcher/fluentbit/main.go +++ b/cmd/fluent-watcher/fluentbit/main.go @@ -58,18 +58,18 @@ func main() { // check the config file format _, err := os.Stat(defaultSecretYamlPath) if os.IsNotExist(err) { - level.Info(logger).Log("msg", "No fluent-bit secret yaml found, using classic one.") + _ = level.Info(logger).Log("msg", "No fluent-bit secret yaml found, using classic one.") flag.StringVar(&configPath, "c", defaultCfgPath, "The classic config file path.") } else { - level.Info(logger).Log("msg", "fluent-bit secret yaml found, using yaml one.") + _ = level.Info(logger).Log("msg", "fluent-bit secret yaml found, using yaml one.") flag.StringVar(&configPath, "c", defaultYamlCfgPath, "The yaml config file path.") } if exitOnFailure { - level.Warn(logger).Log("--exit-on-failure is deprecated. The process will exit no matter what if fluent-bit exits so this can safely be removed.") + _ = level.Warn(logger).Log("--exit-on-failure is deprecated. The process will exit no matter what if fluent-bit exits so this can safely be removed.") } if flbTerminationTimeout > 0 { - level.Warn(logger).Log("--flb-timeout is deprecated. Consider setting the terminationGracePeriod field on the `(Cluster)FluentBit` instance.") + _ = level.Warn(logger).Log("--flb-timeout is deprecated. Consider setting the terminationGracePeriod field on the `(Cluster)FluentBit` instance.") } flag.Parse() diff --git a/cmd/fluent-watcher/fluentd/main.go b/cmd/fluent-watcher/fluentd/main.go index d4ab793f5..f919f7ee1 100644 --- a/cmd/fluent-watcher/fluentd/main.go +++ b/cmd/fluent-watcher/fluentd/main.go @@ -14,8 +14,8 @@ import ( "github.com/fluent/fluent-operator/v3/pkg/filenotify" "github.com/fsnotify/fsnotify" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" + "github.com/go-kit/log" + "github.com/go-kit/log/level" "github.com/oklog/run" ) diff --git a/controllers/fluentd_controller.go b/controllers/fluentd_controller.go index 40f2c6ef0..2b8db8b8f 100644 --- a/controllers/fluentd_controller.go +++ b/controllers/fluentd_controller.go @@ -35,6 +35,11 @@ import ( "github.com/fluent/fluent-operator/v3/pkg/operator" ) +const ( + fluentdLowercase = "fluentd" + fluentd = "Fluentd" +) + // FluentdReconciler reconciles a Fluentd object type FluentdReconciler struct { client.Client @@ -56,7 +61,7 @@ type FluentdReconciler struct { // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.8.3/pkg/reconcile func (r *FluentdReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = r.Log.WithValues("fluentd", req.NamespacedName) + _ = r.Log.WithValues(fluentdLowercase, req.NamespacedName) var fd fluentdv1alpha1.Fluentd if err := r.Get(ctx, req.NamespacedName, &fd); err != nil { @@ -85,13 +90,13 @@ func (r *FluentdReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct secName := fmt.Sprintf("%s-config", fd.Name) if err := r.Get(ctx, client.ObjectKey{Namespace: fd.Namespace, Name: secName}, &sec); err != nil { if errors.IsNotFound(err) { - return ctrl.Result{Requeue: true, RequeueAfter: time.Duration(time.Second)}, nil + return ctrl.Result{Requeue: true, RequeueAfter: time.Second}, nil } return ctrl.Result{}, err } // Install RBAC resources for the filter plugin kubernetes - cr, sa, crb := operator.MakeRBACObjects(fd.Name, fd.Namespace, "fluentd", fd.Spec.RBACRules, fd.Spec.ServiceAccountAnnotations) + cr, sa, crb := operator.MakeRBACObjects(fd.Name, fd.Namespace, fluentdLowercase, fd.Spec.RBACRules, fd.Spec.ServiceAccountAnnotations) // Deploy Fluentd ClusterRole if _, err := controllerutil.CreateOrPatch(ctx, r.Client, cr, r.mutate(cr, &fd)); err != nil { return ctrl.Result{}, err @@ -106,7 +111,7 @@ func (r *FluentdReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } var err error - if fd.Spec.Mode == "agent" { + if fd.Spec.Mode == fluentdAgentMode { // Deploy Fluentd DaemonSet ds := operator.MakeFluentdDaemonSet(fd) _, err = controllerutil.CreateOrPatch(ctx, r.Client, ds, r.mutate(ds, &fd)) @@ -161,7 +166,7 @@ func (r *FluentdReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil } - if owner.APIVersion != fluentdApiGVStr || owner.Kind != "Fluentd" { + if owner.APIVersion != fluentdApiGVStr || owner.Kind != fluentd { return nil } return []string{owner.Name} @@ -177,7 +182,7 @@ func (r *FluentdReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil } - if owner.APIVersion != fluentdApiGVStr || owner.Kind != "Fluentd" { + if owner.APIVersion != fluentdApiGVStr || owner.Kind != fluentd { return nil } return []string{owner.Name} @@ -193,7 +198,7 @@ func (r *FluentdReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil } - if owner.APIVersion != fluentdApiGVStr || owner.Kind != "Fluentd" { + if owner.APIVersion != fluentdApiGVStr || owner.Kind != fluentd { return nil } return []string{owner.Name} @@ -209,7 +214,7 @@ func (r *FluentdReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil } - if owner.APIVersion != fluentdApiGVStr || owner.Kind != "Fluentd" { + if owner.APIVersion != fluentdApiGVStr || owner.Kind != fluentd { return nil } return []string{owner.Name} diff --git a/docs/best-practice/forwarding-logs-via-http/main.go b/docs/best-practice/forwarding-logs-via-http/main.go index 2f1e893c8..728407f74 100644 --- a/docs/best-practice/forwarding-logs-via-http/main.go +++ b/docs/best-practice/forwarding-logs-via-http/main.go @@ -17,7 +17,7 @@ type Message struct { func main() { h := func(w http.ResponseWriter, req *http.Request) { b, err := io.ReadAll(req.Body) - defer req.Body.Close() + defer func() { _ = req.Body.Close() }() if err != nil { log.Print(err.Error()) return diff --git a/docs/plugins/fluentbit/common.md b/docs/plugins/fluentbit/common.md index 540e41c63..1d9d742a2 100644 --- a/docs/plugins/fluentbit/common.md +++ b/docs/plugins/fluentbit/common.md @@ -6,4 +6,4 @@ | Field | Description | Scheme | | ----- | ----------- | ------ | | alias | Alias for the plugin | string | -| retryLimit | RetryLimit describes how many times fluent-bit should retry to send data to a specific output. If set to false fluent-bit will try indefinetly. 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. | string | +| retryLimit | 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 | string | diff --git a/docs/plugins/fluentbit/input/dummy.md b/docs/plugins/fluentbit/input/dummy.md index 77b90e7a6..60c05b708 100644 --- a/docs/plugins/fluentbit/input/dummy.md +++ b/docs/plugins/fluentbit/input/dummy.md @@ -5,7 +5,7 @@ The dummy input plugin, generates dummy events.
It is useful for testing, | Field | Description | Scheme | | ----- | ----------- | ------ | -| tag | Tag name associated to all records comming from this plugin. | string | +| tag | Tag name associated to all records coming from this plugin. | string | | dummy | Dummy JSON record. | string | | rate | Events number generated per second. | *int32 | | samples | Sample events to generate. | *int32 | diff --git a/docs/plugins/fluentbit/input/forward.md b/docs/plugins/fluentbit/input/forward.md index 03b70f5a3..069dd329a 100644 --- a/docs/plugins/fluentbit/input/forward.md +++ b/docs/plugins/fluentbit/input/forward.md @@ -1,6 +1,6 @@ # Forward -Forward defines the in_forward Input plugin that listens to TCP socket to recieve the event stream. **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/forward** +Forward defines the in_forward Input plugin that listens to TCP socket to receive the event stream. **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/forward** | Field | Description | Scheme | @@ -9,8 +9,8 @@ Forward defines the in_forward Input plugin that listens to TCP socket to reciev | listen | Listener network interface. | string | | tag | in_forward uses the tag value for incoming logs. If not set it uses tag from incoming log. | string | | tagPrefix | Adds the prefix to incoming event's tag | string | -| unixPath | Specify the path to unix socket to recieve a forward message. If set, Listen and port are ignnored. | string | +| unixPath | Specify the path to unix socket to receive a forward message. If set, Listen and port are ignnored. | string | | unixPerm | Set the permission of unix socket file. | string | -| bufferMaxSize | Specify maximum buffer memory size used to recieve a forward message. The value must be according to the Unit Size specification. | string | +| bufferMaxSize | Specify maximum buffer memory size used to receive a forward message. The value must be according to the Unit Size specification. | string | | bufferchunkSize | Set the initial buffer size to store incoming data. This value is used too to increase buffer size as required. The value must be according to the Unit Size specification. | string | | threaded | Threaded mechanism allows input plugin to run in a separate thread which helps to desaturate the main pipeline. | string | diff --git a/docs/plugins/fluentbit/input/kubernetes_events.md b/docs/plugins/fluentbit/input/kubernetes_events.md index 9ae2c9f14..f4ae39307 100644 --- a/docs/plugins/fluentbit/input/kubernetes_events.md +++ b/docs/plugins/fluentbit/input/kubernetes_events.md @@ -5,7 +5,7 @@ The KubernetesEvents input plugin allows you to collect kubernetes cluster event | Field | Description | Scheme | | ----- | ----------- | ------ | -| tag | Tag name associated to all records comming from this plugin. | string | +| tag | Tag name associated to all records coming from this plugin. | string | | db | Set a database file to keep track of recorded Kubernetes events | string | | dbSync | Set a database sync method. values: extra, full, normal and off | string | | intervalSec | Set the polling interval for each channel. | *int32 | diff --git a/docs/plugins/fluentbit/input/node_exporter_metrics.md b/docs/plugins/fluentbit/input/node_exporter_metrics.md index d7bef10ee..560919132 100644 --- a/docs/plugins/fluentbit/input/node_exporter_metrics.md +++ b/docs/plugins/fluentbit/input/node_exporter_metrics.md @@ -5,7 +5,7 @@ A plugin based on Prometheus Node Exporter to collect system / host level metric | Field | Description | Scheme | | ----- | ----------- | ------ | -| tag | Tag name associated to all records comming from this plugin. | string | +| tag | Tag name associated to all records coming from this plugin. | string | | scrapeInterval | The rate at which metrics are collected from the host operating system, default is 5 seconds. | string | | path | | *[Path](#path) | # Path diff --git a/docs/plugins/fluentbit/input/prometheus_scrape_metrics.md b/docs/plugins/fluentbit/input/prometheus_scrape_metrics.md index 619dd7957..3f73b1dcb 100644 --- a/docs/plugins/fluentbit/input/prometheus_scrape_metrics.md +++ b/docs/plugins/fluentbit/input/prometheus_scrape_metrics.md @@ -5,7 +5,7 @@ Fluent Bit 1.9 includes additional metrics features to allow you to collect both | Field | Description | Scheme | | ----- | ----------- | ------ | -| tag | Tag name associated to all records comming from this plugin | string | +| tag | Tag name associated to all records coming from this plugin | string | | host | The host of the prometheus metric endpoint that you want to scrape | string | | port | The port of the promethes metric endpoint that you want to scrape | *int32 | | scrapeInterval | The interval to scrape metrics, default: 10s | string | diff --git a/docs/plugins/fluentbit/output/stackdriver.md b/docs/plugins/fluentbit/output/stackdriver.md index 3abb46d07..7a7d9091d 100644 --- a/docs/plugins/fluentbit/output/stackdriver.md +++ b/docs/plugins/fluentbit/output/stackdriver.md @@ -26,4 +26,4 @@ Stackdriver is the Stackdriver output plugin, allows you to ingest your records | autoformatStackdriverTrace | Rewrite the trace field to be formatted for use with GCP Cloud Trace | *bool | | workers | Number of dedicated threads for the Stackdriver Output Plugin | *int32 | | customK8sRegex | A custom regex to extract fields from the local_resource_id of the logs | string | -| resourceLabels | Optional list of comma seperated strings. Setting these fields overrides the Stackdriver monitored resource API values | []string | +| resourceLabels | Optional list of comma separated strings. Setting these fields overrides the Stackdriver monitored resource API values | []string | diff --git a/docs/plugins/fluentd/common/common.md b/docs/plugins/fluentd/common/common.md index 970ef23f7..cb8084f63 100644 --- a/docs/plugins/fluentd/common/common.md +++ b/docs/plugins/fluentd/common/common.md @@ -61,7 +61,7 @@ Transport defines the commont parameters for the transport plugin | Field | Description | Scheme | | ----- | ----------- | ------ | -| protocol | The protocal name of this plugin, i.e: tls | *string | +| protocol | The protocol name of this plugin, i.e: tls | *string | | version | | *string | | ciphers | | *string | | insecure | | *bool | diff --git a/pkg/filenotify/poller.go b/pkg/filenotify/poller.go index abc34799c..34805e120 100644 --- a/pkg/filenotify/poller.go +++ b/pkg/filenotify/poller.go @@ -118,7 +118,10 @@ func (w *filePoller) Close() error { w.closed = true close(w.done) for name := range w.watches { - w.remove(name) + err := w.remove(name) + if err != nil { + return err + } } return nil @@ -215,7 +218,7 @@ func (r *recording) record(filename string) error { } return err } - defer f.Close() + defer func() { _ = f.Close() }() fis, err := f.Readdir(-1) if err != nil { @@ -271,7 +274,7 @@ func (item *itemToWatch) checkForChanges() ([]fsnotify.Event, error) { dirOp := checkChange(item.left.FileInfo, item.right.FileInfo) if dirOp != 0 { - evs := []fsnotify.Event{fsnotify.Event{Op: dirOp, Name: item.filename}} + evs := []fsnotify.Event{{Op: dirOp, Name: item.filename}} return evs, nil } diff --git a/pkg/operator/collector-service.go b/pkg/operator/collector-service.go index ffcddbd4a..5d824ed6d 100644 --- a/pkg/operator/collector-service.go +++ b/pkg/operator/collector-service.go @@ -62,7 +62,7 @@ func MakeCollectorService(co fluentbitv1alpha2.Collector) *corev1.Service { } if len(co.Spec.Service.Annotations) != 0 { - svc.ObjectMeta.Annotations = co.Spec.Service.Annotations + svc.Annotations = co.Spec.Service.Annotations } return &svc diff --git a/pkg/operator/fluent-bit-service.go b/pkg/operator/fluent-bit-service.go index dc1b096a7..1be91807f 100644 --- a/pkg/operator/fluent-bit-service.go +++ b/pkg/operator/fluent-bit-service.go @@ -73,7 +73,7 @@ func MakeFluentbitService(fb fluentbitv1alpha2.FluentBit) *corev1.Service { } if len(fb.Spec.Service.Annotations) != 0 { - svc.ObjectMeta.Annotations = fb.Spec.Service.Annotations + svc.Annotations = fb.Spec.Service.Annotations } return &svc diff --git a/pkg/operator/fluentd-service.go b/pkg/operator/fluentd-service.go index 3e907958c..75aff2a8e 100644 --- a/pkg/operator/fluentd-service.go +++ b/pkg/operator/fluentd-service.go @@ -86,7 +86,7 @@ func MakeFluentdService(fd fluentdv1alpha1.Fluentd) *corev1.Service { } if len(fd.Spec.Service.Annotations) != 0 { - svc.ObjectMeta.Annotations = fd.Spec.Service.Annotations + svc.Annotations = fd.Spec.Service.Annotations } return &svc diff --git a/tests/e2e/fluentd/cfgrender_suite_test.go b/tests/e2e/fluentd/cfgrender_suite_test.go index f39e1d980..6f7619172 100644 --- a/tests/e2e/fluentd/cfgrender_suite_test.go +++ b/tests/e2e/fluentd/cfgrender_suite_test.go @@ -45,7 +45,7 @@ func TestCompareFluentdMainAppConfig(t *testing.T) { k8sClient = kc Expect(k8sClient).NotTo(BeNil()) - fmt.Fprintf(GinkgoWriter, "%s: Info: Setup Suite Execution\n", time.Now().Format(time.StampMilli)) + _, _ = fmt.Fprintf(GinkgoWriter, "%s: Info: Setup Suite Execution\n", time.Now().Format(time.StampMilli)) }, 60) AfterSuite(func() { diff --git a/tests/utils/utils.go b/tests/utils/utils.go index 693a76893..451231705 100644 --- a/tests/utils/utils.go +++ b/tests/utils/utils.go @@ -21,14 +21,22 @@ var ( func init() { once.Do(func() { - ExpectedFluentdClusterCfgOutputES = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-es.cfg") - ExpectedFluentdClusterCfgOutputKafka = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-kafka.cfg") - ExpectedFluentdClusterCfgOutputWithBuffer = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-buffer-example.cfg") - ExpectedFluentdMixedCfgsMultiTenant = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-mixed-cfgs-multi-tenant-output.cfg") - ExpectedFluentdMixedCfgsOutputES = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-mixed-cfgs-output-es.cfg") - ExpectedFluentdNamespacedCfgOutputES = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-namespaced-cfg-output-es.cfg") - ExpectedDuplicateRemovalCRSPECS = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/duplicate-removal-cr-specs.cfg") - ExpectedFluentdClusterCfgOutputCustom = getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-custom.cfg") + ExpectedFluentdClusterCfgOutputES = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-es.cfg") + ExpectedFluentdClusterCfgOutputKafka = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-kafka.cfg") + ExpectedFluentdClusterCfgOutputWithBuffer = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-buffer-example.cfg") + ExpectedFluentdMixedCfgsMultiTenant = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-mixed-cfgs-multi-tenant-output.cfg") + ExpectedFluentdMixedCfgsOutputES = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-mixed-cfgs-output-es.cfg") + ExpectedFluentdNamespacedCfgOutputES = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-namespaced-cfg-output-es.cfg") + ExpectedDuplicateRemovalCRSPECS = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/duplicate-removal-cr-specs.cfg") + ExpectedFluentdClusterCfgOutputCustom = + getExpectedCfg("./apis/fluentd/v1alpha1/tests/expected/fluentd-cluster-cfg-output-custom.cfg") }) }