Skip to content

Commit 98ee2a0

Browse files
committed
Resolve import-shadowing linter warnings
Signed-off-by: Marco Franssen <[email protected]>
1 parent e9c9753 commit 98ee2a0

File tree

4 files changed

+92
-92
lines changed

4 files changed

+92
-92
lines changed

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

apis/fluentd/v1alpha1/plugins/output/types.go

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -401,141 +401,141 @@ func (o *Output) httpPlugin(parent *params.PluginStore, loader plugins.SecretLoa
401401
return parent
402402
}
403403

404-
func (o *Output) elasticsearchPluginCommon(common *ElasticsearchCommon, parent *params.PluginStore, loader plugins.SecretLoader) (*params.PluginStore, error) {
405-
if common.Host != nil {
406-
parent.InsertPairs("host", fmt.Sprint(*common.Host))
404+
func (o *Output) elasticsearchPluginCommon(cmn *ElasticsearchCommon, parent *params.PluginStore, loader plugins.SecretLoader) (*params.PluginStore, error) {
405+
if cmn.Host != nil {
406+
parent.InsertPairs("host", fmt.Sprint(*cmn.Host))
407407
}
408408

409-
if common.Port != nil {
410-
parent.InsertPairs("port", fmt.Sprint(*common.Port))
409+
if cmn.Port != nil {
410+
parent.InsertPairs("port", fmt.Sprint(*cmn.Port))
411411
}
412412

413-
if common.Hosts != nil {
414-
parent.InsertPairs("hosts", fmt.Sprint(*common.Hosts))
413+
if cmn.Hosts != nil {
414+
parent.InsertPairs("hosts", fmt.Sprint(*cmn.Hosts))
415415
}
416416

417-
if common.User != nil {
418-
user, err := loader.LoadSecret(*common.User)
417+
if cmn.User != nil {
418+
user, err := loader.LoadSecret(*cmn.User)
419419
if err != nil {
420420
return nil, err
421421
}
422422
parent.InsertPairs("user", user)
423423
}
424424

425-
if common.Password != nil {
426-
pwd, err := loader.LoadSecret(*common.Password)
425+
if cmn.Password != nil {
426+
pwd, err := loader.LoadSecret(*cmn.Password)
427427
if err != nil {
428428
return nil, err
429429
}
430430
parent.InsertPairs("password", pwd)
431431
}
432432

433-
if common.SslVerify != nil {
434-
parent.InsertPairs("ssl_verify", fmt.Sprint(*common.SslVerify))
433+
if cmn.SslVerify != nil {
434+
parent.InsertPairs("ssl_verify", fmt.Sprint(*cmn.SslVerify))
435435
}
436436

437-
if common.CAFile != nil {
438-
parent.InsertPairs("ca_file", fmt.Sprint(*common.CAFile))
437+
if cmn.CAFile != nil {
438+
parent.InsertPairs("ca_file", fmt.Sprint(*cmn.CAFile))
439439
}
440440

441-
if common.CloudAuth != nil {
442-
cloudauth, err := loader.LoadSecret(*common.CloudAuth)
441+
if cmn.CloudAuth != nil {
442+
cloudauth, err := loader.LoadSecret(*cmn.CloudAuth)
443443
if err != nil {
444444
return nil, err
445445
}
446446
parent.InsertPairs("cloud_auth", cloudauth)
447447
}
448448

449-
if common.CloudId != nil {
450-
cloudid, err := loader.LoadSecret(*common.CloudId)
449+
if cmn.CloudId != nil {
450+
cloudid, err := loader.LoadSecret(*cmn.CloudId)
451451
if err != nil {
452452
return nil, err
453453
}
454454
parent.InsertPairs("cloud_id", cloudid)
455455
}
456456

457-
if common.ClientCert != nil {
458-
parent.InsertPairs("client_cert", fmt.Sprint(*common.ClientCert))
457+
if cmn.ClientCert != nil {
458+
parent.InsertPairs("client_cert", fmt.Sprint(*cmn.ClientCert))
459459
}
460460

461-
if common.ClientKey != nil {
462-
parent.InsertPairs("client_key", fmt.Sprint(*common.ClientKey))
461+
if cmn.ClientKey != nil {
462+
parent.InsertPairs("client_key", fmt.Sprint(*cmn.ClientKey))
463463
}
464464

465-
if common.ClientKeyPassword != nil {
466-
pwd, err := loader.LoadSecret(*common.ClientKeyPassword)
465+
if cmn.ClientKeyPassword != nil {
466+
pwd, err := loader.LoadSecret(*cmn.ClientKeyPassword)
467467
if err != nil {
468468
return nil, err
469469
}
470470
parent.InsertPairs("client_key_pass", pwd)
471471
}
472472

473-
if common.Scheme != nil {
474-
parent.InsertPairs("scheme", fmt.Sprint(*common.Scheme))
473+
if cmn.Scheme != nil {
474+
parent.InsertPairs("scheme", fmt.Sprint(*cmn.Scheme))
475475
}
476476

477-
if common.Path != nil {
478-
parent.InsertPairs("path", fmt.Sprint(*common.Path))
477+
if cmn.Path != nil {
478+
parent.InsertPairs("path", fmt.Sprint(*cmn.Path))
479479
}
480480

481-
if common.TemplateOverwrite != nil {
482-
parent.InsertPairs("template_overwrite", fmt.Sprint(*common.TemplateOverwrite))
481+
if cmn.TemplateOverwrite != nil {
482+
parent.InsertPairs("template_overwrite", fmt.Sprint(*cmn.TemplateOverwrite))
483483
}
484484

485-
if common.MaxRetryPuttingTemplate != nil {
486-
parent.InsertPairs("max_retry_putting_template", fmt.Sprint(*common.MaxRetryPuttingTemplate))
485+
if cmn.MaxRetryPuttingTemplate != nil {
486+
parent.InsertPairs("max_retry_putting_template", fmt.Sprint(*cmn.MaxRetryPuttingTemplate))
487487
}
488488

489-
if common.FailOnPuttingTemplateRetryExceeded != nil {
490-
parent.InsertPairs("fail_on_putting_template_retry_exceed", fmt.Sprint(*common.FailOnPuttingTemplateRetryExceeded))
489+
if cmn.FailOnPuttingTemplateRetryExceeded != nil {
490+
parent.InsertPairs("fail_on_putting_template_retry_exceed", fmt.Sprint(*cmn.FailOnPuttingTemplateRetryExceeded))
491491
}
492492

493-
if common.ReconnectOnError != nil {
494-
parent.InsertPairs("reconnect_on_error", fmt.Sprint(*common.ReconnectOnError))
493+
if cmn.ReconnectOnError != nil {
494+
parent.InsertPairs("reconnect_on_error", fmt.Sprint(*cmn.ReconnectOnError))
495495
}
496496

497-
if common.ReloadAfter != nil {
498-
parent.InsertPairs("reload_after", fmt.Sprint(*common.ReloadAfter))
497+
if cmn.ReloadAfter != nil {
498+
parent.InsertPairs("reload_after", fmt.Sprint(*cmn.ReloadAfter))
499499
}
500500

501-
if common.ReloadConnections != nil {
502-
parent.InsertPairs("reload_connections", fmt.Sprint(*common.ReloadConnections))
501+
if cmn.ReloadConnections != nil {
502+
parent.InsertPairs("reload_connections", fmt.Sprint(*cmn.ReloadConnections))
503503
}
504504

505-
if common.ReloadOnFailure != nil {
506-
parent.InsertPairs("reload_on_failure", fmt.Sprint(*common.ReloadOnFailure))
505+
if cmn.ReloadOnFailure != nil {
506+
parent.InsertPairs("reload_on_failure", fmt.Sprint(*cmn.ReloadOnFailure))
507507
}
508508

509-
if common.RequestTimeout != nil {
510-
parent.InsertPairs("request_timeout", fmt.Sprint(*common.RequestTimeout))
509+
if cmn.RequestTimeout != nil {
510+
parent.InsertPairs("request_timeout", fmt.Sprint(*cmn.RequestTimeout))
511511
}
512512

513-
if common.SnifferClassName != nil {
514-
parent.InsertPairs("sniffer_class_name", fmt.Sprint(*common.SnifferClassName))
513+
if cmn.SnifferClassName != nil {
514+
parent.InsertPairs("sniffer_class_name", fmt.Sprint(*cmn.SnifferClassName))
515515
}
516516

517-
if common.SuppressTypeName != nil {
518-
parent.InsertPairs("suppress_type_name", fmt.Sprint(*common.SuppressTypeName))
517+
if cmn.SuppressTypeName != nil {
518+
parent.InsertPairs("suppress_type_name", fmt.Sprint(*cmn.SuppressTypeName))
519519
}
520520

521-
if common.EnableIlm != nil {
522-
parent.InsertPairs("enable_ilm", fmt.Sprint(*common.EnableIlm))
521+
if cmn.EnableIlm != nil {
522+
parent.InsertPairs("enable_ilm", fmt.Sprint(*cmn.EnableIlm))
523523
}
524524

525-
if common.IlmPolicyId != nil {
526-
parent.InsertPairs("ilm_policy_id", fmt.Sprint(*common.IlmPolicyId))
525+
if cmn.IlmPolicyId != nil {
526+
parent.InsertPairs("ilm_policy_id", fmt.Sprint(*cmn.IlmPolicyId))
527527
}
528528

529-
if common.IlmPolicy != nil {
530-
parent.InsertPairs("ilm_policy", fmt.Sprint(*common.IlmPolicy))
529+
if cmn.IlmPolicy != nil {
530+
parent.InsertPairs("ilm_policy", fmt.Sprint(*cmn.IlmPolicy))
531531
}
532532

533-
if common.IlmPolicyOverwrite != nil {
534-
parent.InsertPairs("ilm_policy_overwrite", fmt.Sprint(*common.IlmPolicyOverwrite))
533+
if cmn.IlmPolicyOverwrite != nil {
534+
parent.InsertPairs("ilm_policy_overwrite", fmt.Sprint(*cmn.IlmPolicyOverwrite))
535535
}
536536

537-
if common.LogEs400Reason != nil {
538-
parent.InsertPairs("log_es_400_reason", fmt.Sprint(*common.LogEs400Reason))
537+
if cmn.LogEs400Reason != nil {
538+
parent.InsertPairs("log_es_400_reason", fmt.Sprint(*cmn.LogEs400Reason))
539539
}
540540

541541
return parent, nil

cmd/doc-gen/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ type Pair struct {
229229
type KubeTypes []Pair
230230

231231
func ParseDocumentationFrom(src string, dl_name string, shouldSort bool) []KubeTypes {
232-
var docForTypes []KubeTypes
233-
234232
fset := token.NewFileSet()
235233
f, err := parser.ParseFile(fset, src, nil, parser.ParseComments)
236234
if err != nil {
@@ -258,6 +256,7 @@ func ParseDocumentationFrom(src string, dl_name string, shouldSort bool) []KubeT
258256
})
259257
}
260258

259+
docForTypes := make([]KubeTypes, 0, len(types))
261260
for _, kubType := range types {
262261
structType, _ := kubType.Decl.Specs[0].(*ast.TypeSpec).Type.(*ast.StructType)
263262

controllers/fluentbitconfig_controller.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,24 @@ func (r *FluentBitConfigReconciler) processNamespacedFluentBitCfgs(
247247
[]fluentbitv1alpha2.MultilineParserList, []fluentbitv1alpha2.ClusterMultilineParserList, []string, error,
248248
) {
249249
var nsCfgs fluentbitv1alpha2.FluentBitConfigList
250-
var filters []fluentbitv1alpha2.FilterList
251-
var outputs []fluentbitv1alpha2.OutputList
252-
var parsers []fluentbitv1alpha2.ParserList
253-
var clusterParsers []fluentbitv1alpha2.ClusterParserList
254-
var multilineParsers []fluentbitv1alpha2.MultilineParserList
255-
var clusterMultilineParsers []fluentbitv1alpha2.ClusterMultilineParserList
256-
var rewriteTagConfigs []string
257250
// set of rewrite_tag plugin configs to mutate tags for log records coming out of a namespace
258251
selector, err := metav1.LabelSelectorAsSelector(&fb.Spec.NamespacedFluentBitCfgSelector)
259252
if err != nil {
260-
return filters, outputs, parsers, clusterParsers, multilineParsers, clusterMultilineParsers, nil, err
253+
return nil, nil, nil, nil, nil, nil, nil, err
261254
}
262255

263256
if err := r.List(ctx, &nsCfgs, client.MatchingLabelsSelector{Selector: selector}); err != nil {
264-
return filters, outputs, parsers, clusterParsers, multilineParsers, clusterMultilineParsers, nil, err
257+
return nil, nil, nil, nil, nil, nil, nil, err
265258
}
266259

260+
filters := make([]fluentbitv1alpha2.FilterList, 0, len(nsCfgs.Items))
261+
outputs := make([]fluentbitv1alpha2.OutputList, 0, len(nsCfgs.Items))
262+
parsers := make([]fluentbitv1alpha2.ParserList, 0, len(nsCfgs.Items))
263+
clusterParsers := make([]fluentbitv1alpha2.ClusterParserList, 0, len(nsCfgs.Items))
264+
multilineParsers := make([]fluentbitv1alpha2.MultilineParserList, 0, len(nsCfgs.Items))
265+
clusterMultilineParsers := make([]fluentbitv1alpha2.ClusterMultilineParserList, 0, len(nsCfgs.Items))
266+
rewriteTagConfigs := make([]string, 0, len(nsCfgs.Items))
267+
267268
// Form a slice of list of resources per namespace
268269
for _, cfg := range nsCfgs.Items {
269270
filterList, outputList, parserList, clusterParserList, multilineParsersList, clusterMultilineParsersList, err := r.ListNamespacedResources(

0 commit comments

Comments
 (0)