Skip to content

Commit 27daa22

Browse files
committed
Fix linter warnings
Signed-off-by: Marco Franssen <marco.franssen@gmail.com>
1 parent 06a9cbf commit 27daa22

File tree

89 files changed

+394
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+394
-376
lines changed

apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,11 @@ func (cfg ClusterFluentBitConfig) RenderNamespacedLuaScript(
550550
for _, f := range nsfilters.Items {
551551
for _, p := range f.Spec.FilterItems {
552552
if p.Lua != nil && p.Lua.Script.Key != "" {
553-
script, err := cl.LoadConfigMap(p.Lua.Script, f.ObjectMeta.Namespace)
553+
script, err := cl.LoadConfigMap(p.Lua.Script, f.Namespace)
554554
if err != nil {
555555
return nil, err
556556
}
557-
namespacedScriptName := fmt.Sprintf("%x-%s", md5.Sum([]byte(f.ObjectMeta.Namespace)), p.Lua.Script.Key)
557+
namespacedScriptName := fmt.Sprintf("%x-%s", md5.Sum([]byte(f.Namespace)), p.Lua.Script.Key)
558558
scripts = append(scripts, Script{Name: namespacedScriptName, Content: script})
559559
}
560560
}

apis/fluentbit/v1alpha2/collector_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,25 @@ type Collector struct {
114114

115115
// IsBeingDeleted returns true if a deletion timestamp is set
116116
func (co *Collector) IsBeingDeleted() bool {
117-
return !co.ObjectMeta.DeletionTimestamp.IsZero()
117+
return !co.DeletionTimestamp.IsZero()
118118
}
119119

120120
// CollectorFinalizerName is the name of the fluentbit finalizer
121121
const CollectorFinalizerName = "collector.fluent.io"
122122

123123
// HasFinalizer returns true if the item has the specified finalizer
124124
func (co *Collector) HasFinalizer(finalizerName string) bool {
125-
return slices.Contains(co.ObjectMeta.Finalizers, finalizerName)
125+
return slices.Contains(co.Finalizers, finalizerName)
126126
}
127127

128128
// AddFinalizer adds the specified finalizer
129129
func (co *Collector) AddFinalizer(finalizerName string) {
130-
co.ObjectMeta.Finalizers = append(co.ObjectMeta.Finalizers, finalizerName)
130+
co.Finalizers = append(co.Finalizers, finalizerName)
131131
}
132132

133133
// RemoveFinalizer removes the specified finalizer
134134
func (co *Collector) RemoveFinalizer(finalizerName string) {
135-
co.ObjectMeta.Finalizers = slices.DeleteFunc(co.ObjectMeta.Finalizers, func(s string) bool { return s == finalizerName })
135+
co.Finalizers = slices.DeleteFunc(co.Finalizers, func(s string) bool { return s == finalizerName })
136136
}
137137

138138
// +kubebuilder:object:root=true

apis/fluentbit/v1alpha2/fluentbit_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,25 +142,25 @@ type FluentBit struct {
142142

143143
// IsBeingDeleted returns true if a deletion timestamp is set
144144
func (fb *FluentBit) IsBeingDeleted() bool {
145-
return !fb.ObjectMeta.DeletionTimestamp.IsZero()
145+
return !fb.DeletionTimestamp.IsZero()
146146
}
147147

148148
// FluentBitFinalizerName is the name of the fluentbit finalizer
149149
const FluentBitFinalizerName = "fluentbit.fluent.io"
150150

151151
// HasFinalizer returns true if the item has the specified finalizer
152152
func (fb *FluentBit) HasFinalizer(finalizerName string) bool {
153-
return slices.Contains(fb.ObjectMeta.Finalizers, finalizerName)
153+
return slices.Contains(fb.Finalizers, finalizerName)
154154
}
155155

156156
// AddFinalizer adds the specified finalizer
157157
func (fb *FluentBit) AddFinalizer(finalizerName string) {
158-
fb.ObjectMeta.Finalizers = append(fb.ObjectMeta.Finalizers, finalizerName)
158+
fb.Finalizers = append(fb.Finalizers, finalizerName)
159159
}
160160

161161
// RemoveFinalizer removes the specified finalizer
162162
func (fb *FluentBit) RemoveFinalizer(finalizerName string) {
163-
fb.ObjectMeta.Finalizers = slices.DeleteFunc(fb.ObjectMeta.Finalizers, func(s string) bool { return s == finalizerName })
163+
fb.Finalizers = slices.DeleteFunc(fb.Finalizers, func(s string) bool { return s == finalizerName })
164164
}
165165

166166
// +kubebuilder:object:root=true

apis/fluentbit/v1alpha2/plugins/common_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ type CommonParams struct {
1212

1313
// Alias for the plugin
1414
Alias string `json:"alias,omitempty"`
15-
// 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.
15+
// 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.
16+
// nolint:misspell
1617
// +kubebuilder:validation:Pattern="^(((f|F)alse)|(no_limits)|(no_retries)|([1-9]+[0-9]*))$"
1718
RetryLimit string `json:"retryLimit,omitempty"`
1819
}

apis/fluentbit/v1alpha2/plugins/configmap_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package plugins
33
import (
44
"context"
55
"fmt"
6+
"strings"
7+
68
"github.com/go-openapi/errors"
7-
"k8s.io/api/core/v1"
9+
v1 "k8s.io/api/core/v1"
810
"sigs.k8s.io/controller-runtime/pkg/client"
9-
"strings"
1011
)
1112

1213
type ConfigMapLoader struct {
@@ -30,6 +31,6 @@ func (cl ConfigMapLoader) LoadConfigMap(selector v1.ConfigMapKeySelector, namesp
3031
if v, ok := configMap.Data[selector.Key]; !ok {
3132
return "", errors.NotFound(fmt.Sprintf("The key %s is not found.", selector.Key))
3233
} else {
33-
return strings.TrimSuffix(fmt.Sprintf("%s", v), "\n"), nil
34+
return strings.TrimSuffix(v, "\n"), nil
3435
}
3536
}

apis/fluentbit/v1alpha2/plugins/custom/custom_plugin_types.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,18 @@ func (c *CustomPlugin) MakeNamespaced(ns string) {
5858
}
5959

6060
func indentation(str string) string {
61-
splits := strings.Split(str, "\n")
6261
var buf bytes.Buffer
63-
for _, i := range splits {
64-
if i != "" {
65-
buf.WriteString(fmt.Sprintf(" %s\n", strings.TrimSpace(i)))
62+
for s := range strings.SplitSeq(str, "\n") {
63+
if s != "" {
64+
buf.WriteString(fmt.Sprintf(" %s\n", strings.TrimSpace(s)))
6665
}
6766
}
6867
return buf.String()
6968
}
7069

7170
func MakeCustomConfigNamespaced(customConfig string, namespace string) string {
7271
var buf bytes.Buffer
73-
sections := strings.Split(customConfig, "\n")
74-
for _, section := range sections {
72+
for section := range strings.SplitSeq(customConfig, "\n") {
7573
section = strings.TrimSpace(section)
7674
idx := strings.LastIndex(section, " ")
7775
if strings.HasPrefix(section, "Match_Regex") {

apis/fluentbit/v1alpha2/plugins/filter/aws_types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ type AWS struct {
1818
ImdsVersion string `json:"imdsVersion,omitempty"`
1919
// The availability zone; for example, "us-east-1a". Default is true.
2020
AZ *bool `json:"az,omitempty"`
21-
//The EC2 instance ID.Default is true.
21+
// The EC2 instance ID.Default is true.
2222
EC2InstanceID *bool `json:"ec2InstanceID,omitempty"`
23-
//The EC2 instance type.Default is false.
23+
// The EC2 instance type.Default is false.
2424
EC2InstanceType *bool `json:"ec2InstanceType,omitempty"`
25-
//The EC2 instance private ip.Default is false.
25+
// The EC2 instance private ip.Default is false.
2626
PrivateIP *bool `json:"privateIP,omitempty"`
27-
//The EC2 instance image id.Default is false.
27+
// The EC2 instance image id.Default is false.
2828
AmiID *bool `json:"amiID,omitempty"`
29-
//The account ID for current EC2 instance.Default is false.
29+
// The account ID for current EC2 instance.Default is false.
3030
AccountID *bool `json:"accountID,omitempty"`
31-
//The hostname for current EC2 instance.Default is false.
31+
// The hostname for current EC2 instance.Default is false.
3232
HostName *bool `json:"hostName,omitempty"`
33-
//The VPC ID for current EC2 instance.Default is false.
33+
// The VPC ID for current EC2 instance.Default is false.
3434
VpcID *bool `json:"vpcID,omitempty"`
3535
}
3636

37-
func (_ *AWS) Name() string {
37+
func (*AWS) Name() string {
3838
return "aws"
3939
}
4040

apis/fluentbit/v1alpha2/plugins/filter/grep_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Grep struct {
1919
Exclude string `json:"exclude,omitempty"`
2020
}
2121

22-
func (_ *Grep) Name() string {
22+
func (*Grep) Name() string {
2323
return "grep"
2424
}
2525

apis/fluentbit/v1alpha2/plugins/filter/kubernetes_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type Kubernetes struct {
109109
UseTagForMeta *bool `json:"useTagForMeta,omitempty"`
110110
}
111111

112-
func (_ *Kubernetes) Name() string {
112+
func (*Kubernetes) Name() string {
113113
return "kubernetes"
114114
}
115115

apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type LogToMetrics struct {
5151
DiscardLogs *bool `json:"discardLogs,omitempty"`
5252
}
5353

54-
func (_ *LogToMetrics) Name() string {
54+
func (*LogToMetrics) Name() string {
5555
return "log_to_metrics"
5656
}
5757

0 commit comments

Comments
 (0)