Skip to content

Commit 5bb2146

Browse files
PMaynardjotak
andauthored
Bumped golangci-lint from v1.56.2 to v1.61.0 (#748)
* Replace bingo with simpler bin management * Fix linter errors --------- Co-authored-by: Joel Takvorian <[email protected]>
1 parent 63d2a39 commit 5bb2146

File tree

27 files changed

+101
-94
lines changed

27 files changed

+101
-94
lines changed

.golangci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ linters:
55
- cyclop
66
- errname
77
- exhaustive
8-
- exportloopref
8+
- copyloopvar
99
- gocritic
1010
- gofmt
1111
- gosimple
@@ -16,15 +16,17 @@ linters:
1616
- stylecheck
1717
- typecheck
1818
- unused
19+
run:
20+
go: "1.22"
1921
linters-settings:
20-
stylecheck:
21-
go: "1.22"
2222
gocritic:
2323
enabled-checks:
2424
- hugeParam
2525
- rangeExprCopy
2626
- rangeValCopy
2727
- indexAlloc
28-
- deprecatedComment
28+
settings:
29+
ifElseChain:
30+
minThreshold: 3
2931
cyclop:
3032
max-complexity: 20

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ifneq ($(CLEAN_BUILD),)
3838
LDFLAGS ?= -X 'main.buildVersion=${VERSION}-${BUILD_SHA}' -X 'main.buildDate=${BUILD_DATE}'
3939
endif
4040

41-
GOLANGCI_LINT_VERSION = v1.56.2
41+
GOLANGCI_LINT_VERSION = v1.61.0
4242

4343
FLP_BIN_FILE=flowlogs-pipeline
4444
CG_BIN_FILE=confgenerator

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,10 +921,13 @@ Usage:
921921
922922
General
923923
help Display this help.
924+
prereqs Check if prerequisites are met, and install missing dependencies
925+
prereqs-kind Check if prerequisites are met for running kind, and install missing dependencies
924926
vendors Check go vendors
925927
926928
Develop
927929
lint Lint the code
930+
compile Compile main flowlogs-pipeline and config generator
928931
build Build flowlogs-pipeline executable and update the docs
929932
docs Update flowlogs-pipeline documentation
930933
clean Clean

cmd/apitodoc/main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ func iterate(output io.Writer, data interface{}, indent int) {
3636
if err != nil {
3737
dataTypeName = "(unknown)"
3838
}
39-
if dataType == reflect.Slice || dataType == reflect.Map {
39+
//nolint:exhaustive
40+
switch dataType {
41+
case reflect.Slice, reflect.Map:
4042
// DEBUG code: fmt.Fprintf(output, "%s %s <-- %s \n",strings.Repeat(" ",4*indent),dataTypeName,dataType )
4143
zeroElement := reflect.Zero(reflect.ValueOf(data).Type().Elem()).Interface()
4244
iterate(output, zeroElement, newIndent)
4345
return
44-
} else if dataType == reflect.Struct {
46+
case reflect.Struct:
4547
// DEBUG code: fmt.Fprintf(output,"%s %s <-- %s \n",strings.Repeat(" ",4*indent),dataTypeName,dataType )
4648
for i := 0; i < d.NumField(); i++ {
4749
val := reflect.Indirect(reflect.ValueOf(data))
@@ -63,16 +65,18 @@ func iterate(output io.Writer, data interface{}, indent int) {
6365
}
6466
}
6567
return
66-
} else if dataType == reflect.Ptr {
68+
case reflect.Ptr:
6769
// DEBUG code: fmt.Fprintf(output, "%s %s <-- %s \n", strings.Repeat(" ", 4*indent), dataTypeName, dataType)
6870
elemType := reflect.TypeOf(data).Elem()
6971
zeroElement := reflect.Zero(elemType).Interface()
7072
// Since we only "converted" Ptr to Struct and the actual output is done in the next iteration, we call
7173
// iterate() with the same `indent` as the current level
7274
iterate(output, zeroElement, indent)
73-
} else if strings.HasPrefix(dataTypeName, "api.") && strings.HasSuffix(dataTypeName, "Enum") {
74-
// set placeholder for enum
75-
fmt.Fprintf(output, "placeholder @%s:%d@\n", strings.TrimPrefix(dataTypeName, "api."), 4*newIndent)
75+
default:
76+
if strings.HasPrefix(dataTypeName, "api.") && strings.HasSuffix(dataTypeName, "Enum") {
77+
// set placeholder for enum
78+
fmt.Fprintf(output, "placeholder @%s:%d@\n", strings.TrimPrefix(dataTypeName, "api."), 4*newIndent)
79+
}
7680
}
7781
}
7882

docs/operational-metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Each table below provides documentation for an exported flowlogs-pipeline operat
148148
|:---|:---|
149149
| **Description** | Counter of hits per secondary network index for Kubernetes enrichment |
150150
| **Type** | counter |
151-
| **Labels** | kind, network, warning |
151+
| **Labels** | kind, namespace, network, warning |
152152

153153

154154
### stage_duration_ms

pkg/api/encode_s3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ type EncodeS3 struct {
2828
Secure bool `yaml:"secure,omitempty" json:"secure,omitempty" doc:"true for https, false for http (default: false)"`
2929
ObjectHeaderParameters map[string]interface{} `yaml:"objectHeaderParameters,omitempty" json:"objectHeaderParameters,omitempty" doc:"parameters to include in object header (key/value pairs)"`
3030
// TBD: (TLS?) security parameters
31-
//TLS *ClientTLS `yaml:"tls" json:"tls" doc:"TLS client configuration (optional)"`
31+
// TLS *ClientTLS `yaml:"tls" json:"tls" doc:"TLS client configuration (optional)"`
3232
}

pkg/confgen/confgen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (cg *ConfGen) ParseDefinition(name string, bytes []byte) error {
161161
return err
162162
}
163163

164-
//skip if their skip tag match
164+
// skip if their skip tag match
165165
for _, skipTag := range cg.opts.SkipWithTags {
166166
for _, tag := range defFile.Tags {
167167
if skipTag == tag {

pkg/confgen/doc.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (cg *ConfGen) generateVisualizeText(vgs []VisualizationGrafana) string {
3131
for _, vs := range vgs {
3232
title := vs.Title
3333
dashboard := vs.Dashboard
34-
section = section + fmt.Sprintf("| **Visualized as** | \"%s\" on dashboard `%s` |\n", title, dashboard)
34+
section += fmt.Sprintf("| **Visualized as** | \"%s\" on dashboard `%s` |\n", title, dashboard)
3535
}
3636

3737
return section
@@ -42,7 +42,7 @@ func (cg *ConfGen) generatePromEncodeText(metrics api.MetricsItems) string {
4242
for i := range metrics {
4343
mType := metrics[i].Type
4444
name := cg.config.Encode.Prom.Prefix + metrics[i].Name
45-
section = section + fmt.Sprintf("| **Exposed as** | `%s` of type `%s` |\n", name, mType)
45+
section += fmt.Sprintf("| **Exposed as** | `%s` of type `%s` |\n", name, mType)
4646
}
4747

4848
return section
@@ -57,7 +57,7 @@ func (cg *ConfGen) generateOperationText(definitions api.AggregateDefinitions) s
5757
if operationKey != "" {
5858
operationKey = fmt.Sprintf("field `%s`", operationKey)
5959
}
60-
section = section + fmt.Sprintf("| **OperationType** | aggregate by `%s` and `%s` %s |\n", by, operation, operationKey)
60+
section += fmt.Sprintf("| **OperationType** | aggregate by `%s` and `%s` %s |\n", by, operation, operationKey)
6161
}
6262

6363
return section
@@ -70,7 +70,7 @@ func (cg *ConfGen) generateDoc(fileName string) error {
7070
replacer := strings.NewReplacer("-", " ", "_", " ")
7171
name := replacer.Replace(filepath.Base(metric.FileName[:len(metric.FileName)-len(filepath.Ext(metric.FileName))]))
7272

73-
labels := strings.Join(metric.Tags[:], ", ")
73+
labels := strings.Join(metric.Tags, ", ")
7474
// TODO: add support for multiple operations
7575
operation := cg.generateOperationText(metric.Aggregates.Rules)
7676
expose := cg.generatePromEncodeText(metric.PromEncode.Metrics)

pkg/confgen/grafana_jsonnet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func (cg *ConfGen) GenerateGrafanaJSON() (string, error) {
359359
if err != nil {
360360
return "", err
361361
}
362-
panelsJSON = panelsJSON + jsonStr
362+
panelsJSON += jsonStr
363363
}
364364
return panelsJSON, nil
365365
}

pkg/pipeline/encode/encode_prom.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (e *EncodeProm) checkConfUpdate() {
245245
break
246246
}
247247
default:
248-
//Nothing to do
248+
// Nothing to do
249249
return
250250
}
251251
}

0 commit comments

Comments
 (0)