Skip to content

Commit 5eccc43

Browse files
Merge pull request #1704 from marcofranssen/golangci
Add golang-ci configuration matching with latest operator SDK
2 parents a28d570 + 98ee2a0 commit 5eccc43

File tree

17 files changed

+169
-111
lines changed

17 files changed

+169
-111
lines changed

.golangci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: "2"
2+
run:
3+
allow-parallel-runners: true
4+
5+
linters:
6+
default: none
7+
enable:
8+
- copyloopvar
9+
- dupl
10+
- errcheck
11+
- ginkgolinter
12+
- goconst
13+
- gocyclo
14+
- govet
15+
- ineffassign
16+
- lll
17+
- misspell
18+
- nakedret
19+
- prealloc
20+
- revive
21+
- staticcheck
22+
- unconvert
23+
- unparam
24+
- unused
25+
26+
settings:
27+
revive:
28+
rules:
29+
- name: comment-spacings
30+
- name: import-shadowing
31+
exclusions:
32+
generated: lax
33+
rules:
34+
- linters:
35+
- lll
36+
path: api/*
37+
- linters:
38+
- dupl
39+
- lll
40+
path: internal/*
41+
- linters:
42+
- misspell
43+
path: apis/fluentbit/v1alpha2/plugins/common_types.go
44+
paths:
45+
- third_party$
46+
- builtin$
47+
- examples$
48+
49+
formatters:
50+
enable:
51+
- gofmt
52+
- goimports
53+
exclusions:
54+
generated: lax
55+
paths:
56+
- third_party$
57+
- builtin$
58+
- examples$

apis/fluentbit/v1alpha2/plugins/input/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type HTTP struct {
2424
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
2525
BufferMaxSize string `json:"bufferMaxSize,omitempty"`
2626
// This sets the chunk size for incoming incoming JSON messages.
27-
//These chunks are then stored/managed in the space available by buffer_max_size,default 512K.
27+
// These chunks are then stored/managed in the space available by buffer_max_size,default 512K.
2828
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
2929
BufferChunkSize string `json:"bufferChunkSize,omitempty"`
3030
// It allows to set successful response code. 200, 201 and 204 are supported,default 201.

apis/fluentbit/v1alpha2/plugins/input/syslog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Syslog struct {
2929
// If your syslog messages have fractional seconds set this Parser value to syslog-rfc5424 instead.
3030
Parser string `json:"parser,omitempty"`
3131
// By default the buffer to store the incoming Syslog messages, do not allocate the maximum memory allowed, instead it allocate memory when is required.
32-
//The rounds of allocations are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size is equal to 32000 bytes (32KB).
32+
// The rounds of allocations are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size is equal to 32000 bytes (32KB).
3333
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
3434
BufferChunkSize string `json:"bufferChunkSize,omitempty"`
3535
// Specify the maximum buffer size to receive a Syslog message. If not set, the default size will be the value of Buffer_Chunk_Size.

apis/fluentbit/v1alpha2/plugins/input/tcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type TCP struct {
2222
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
2323
BufferSize string `json:"bufferSize,omitempty"`
2424
// By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed, instead it allocate memory when is required.
25-
//The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB).
25+
// The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB).
2626
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
2727
ChunkSize string `json:"chunkSize,omitempty"`
2828
// Specify the expected payload format. It support the options json and none.

apis/fluentbit/v1alpha2/plugins/output/kafka_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ type Kafka struct {
3636
TopicKey string `json:"topicKey,omitempty"`
3737
// {property} can be any librdkafka properties
3838
Rdkafka map[string]string `json:"rdkafka,omitempty"`
39-
//adds unknown topics (found in Topic_Key) to Topics. So in Topics only a default topic needs to be configured
39+
// Adds unknown topics (found in Topic_Key) to Topics. So in Topics only a default topic needs to be configured
4040
DynamicTopic *bool `json:"dynamicTopic,omitempty"`
41-
//Fluent Bit queues data into rdkafka library,
42-
//if for some reason the underlying library cannot flush the records the queue might fills up blocking new addition of records.
43-
//The queue_full_retries option set the number of local retries to enqueue the data.
44-
//The default value is 10 times, the interval between each retry is 1 second.
45-
//Setting the queue_full_retries value to 0 set's an unlimited number of retries.
41+
// Fluent Bit queues data into rdkafka library,
42+
// if for some reason the underlying library cannot flush the records the queue might fills up blocking new addition of records.
43+
// The queue_full_retries option set the number of local retries to enqueue the data.
44+
// The default value is 10 times, the interval between each retry is 1 second.
45+
// Setting the queue_full_retries value to 0 set's an unlimited number of retries.
4646
QueueFullRetries *int64 `json:"queueFullRetries,omitempty"`
4747
// Limit the maximum number of Chunks in the filesystem for the current output logical destination.
4848
TotalLimitSize string `json:"totalLimitSize,omitempty"`

apis/fluentbit/v1alpha2/plugins/output/splunk_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Splunk struct {
2121
Port *int32 `json:"port,omitempty"`
2222
// Specify the Authentication Token for the HTTP Event Collector interface.
2323
SplunkToken *plugins.Secret `json:"splunkToken,omitempty"`
24-
//Buffer size used to receive Splunk HTTP responses: Default `2M`
24+
// Buffer size used to receive Splunk HTTP responses: Default `2M`
2525
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
2626
HTTPBufferSize string `json:"httpBufferSize,omitempty"`
2727
// Set payload compression mechanism. The only available option is gzip.

apis/fluentd/v1alpha1/helper.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ func (r *CfgResources) filterForInputs(
210210
sl plugins.SecretLoader,
211211
inputs []input.Input,
212212
) error {
213-
for n, input := range inputs {
213+
for n, in := range inputs {
214214
inputId := fmt.Sprintf("%s::%s::%s::%s-%d", cfgId, namespace, crdtype, name, n)
215-
input.Id = &inputId
216-
// if input.InputCommon.Tag == nil {
217-
// input.InputCommon.Tag = &params.DefaultTag
215+
in.Id = &inputId
216+
// if in.InputCommon.Tag == nil {
217+
// in.InputCommon.Tag = &params.DefaultTag
218218
// }
219219

220-
ps, err := input.Params(sl)
220+
ps, err := in.Params(sl)
221221
if err != nil {
222222
return err
223223
}
@@ -239,14 +239,14 @@ func (r *CfgResources) filterForFilters(
239239
sl plugins.SecretLoader,
240240
filters []filter.Filter,
241241
) error {
242-
for n, filter := range filters {
242+
for n, f := range filters {
243243
filterId := fmt.Sprintf("%s::%s::%s::%s-%d", cfgId, namespace, crdtype, name, n)
244-
filter.Id = &filterId
245-
if filter.Tag == nil {
246-
filter.Tag = &params.DefaultTag
244+
f.Id = &filterId
245+
if f.Tag == nil {
246+
f.Tag = &params.DefaultTag
247247
}
248248

249-
ps, err := filter.Params(sl)
249+
ps, err := f.Params(sl)
250250
if err != nil {
251251
return err
252252
}
@@ -268,14 +268,14 @@ func (r *CfgResources) filterForOutputs(
268268
sl plugins.SecretLoader,
269269
outputs []output.Output,
270270
) error {
271-
for n, output := range outputs {
271+
for n, o := range outputs {
272272
outputId := fmt.Sprintf("%s::%s::%s::%s-%d", cfgId, namespace, crdtype, name, n)
273-
output.Id = &outputId
274-
if output.Tag == nil {
275-
output.Tag = &params.DefaultTag
273+
o.Id = &outputId
274+
if o.Tag == nil {
275+
o.Tag = &params.DefaultTag
276276
}
277277

278-
ps, err := output.Params(sl)
278+
ps, err := o.Params(sl)
279279
if err != nil {
280280
return err
281281
}
@@ -312,19 +312,19 @@ func (pgr *PluginResources) IdentifyCopyAndPatchOutput(cfgResources *CfgResource
312312
}
313313

314314
// Patch the outputs
315-
for k, output := range outputs {
315+
for k, o := range outputs {
316316
// Does it exist a copy output for this tag ?
317317
if c, ok := copyOutputs[k]; ok {
318318
// Yes, so we patch
319-
for _, id := range output {
319+
for _, id := range o {
320320
o := cfgResources.OutputPlugins[id]
321321
o.Name = "store"
322322
cfgResources.OutputPlugins[c].InsertChilds(&o)
323323
}
324324
patchedOutputPlugins = append(patchedOutputPlugins, cfgResources.OutputPlugins[c])
325325
} else {
326326
// No, we don't patch
327-
for _, id := range output {
327+
for _, id := range o {
328328
o := cfgResources.OutputPlugins[id]
329329
patchedOutputPlugins = append(patchedOutputPlugins, o)
330330
}
@@ -347,14 +347,14 @@ func (pgr *PluginResources) WithCfgResources(cfgRouteLabel string, r *CfgResourc
347347
cfgLabelPlugin.InsertPairs("tag", cfgRouteLabel)
348348

349349
// insert filter plugins of this fluentd config
350-
for _, filter := range r.FilterPlugins {
351-
childFilter := filter
350+
for _, f := range r.FilterPlugins {
351+
childFilter := f
352352
cfgLabelPlugin.InsertChilds(&childFilter)
353353
}
354354

355355
// insert output plugins of this fluentd config
356-
for _, output := range r.OutputPlugins {
357-
childOutput := output
356+
for _, o := range r.OutputPlugins {
357+
childOutput := o
358358
cfgLabelPlugin.InsertChilds(&childOutput)
359359
}
360360

0 commit comments

Comments
 (0)