Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter issue #291

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc
with:
version: v1.60
version: v1.62.0
args: ./...
6 changes: 2 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ linters:
- bodyclose
- containedctx
- contextcheck
- copyloopvar
# - cyclop
- decorder
- dogsled
Expand All @@ -22,10 +23,8 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
# - exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
# - gci
Expand All @@ -41,7 +40,6 @@ linters:
# - gofumpt
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
Expand Down Expand Up @@ -89,4 +87,4 @@ linters:
- usestdlibvars
- wastedassign
# - whitespace
# - wrapcheck #TODO: add it back later potentially?
# - wrapcheck #TODO: add it back later potentially?
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ARG GO_VERSION=1.23.0
ARG XX_VERSION=1.2.1
ARG GOLANGCI_LINT_VERSION=v1.55.2
ARG GOLANGCI_LINT_VERSION=v1.62.0

# xx is a helper for cross-compilation
FROM --platform=${BUILDPLATFORM} tonistiigi/xx:${XX_VERSION} AS xx
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/k8s_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (c *k8sAPICollector) computeMetrics(ctx context.Context) (Metrics, error) {
errMetric = errors.Join(errMetric, err)
l.Error("could not send gauge", log.ErrorField(err))
}
l.Info("Stats for the run time duration", log.Dur("run", runDuration), log.Dur("wait", runTotalWaitTime), log.Percent("throttling_percent", 100*runThrottlingPercentage, 100)) //nolint:gomnd
l.Info("Stats for the run time duration", log.Dur("run", runDuration), log.Dur("wait", runTotalWaitTime), log.Percent("throttling_percent", 100*runThrottlingPercentage, 100))

// SaveMetadata
metadata := Metrics{
Expand Down
8 changes: 0 additions & 8 deletions pkg/collector/k8s_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func TestNewK8sAPICollectorConfig(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := viper.New()
Expand Down Expand Up @@ -157,7 +156,6 @@ func Test_k8sAPICollector_streamPodsNamespace(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down Expand Up @@ -226,7 +224,6 @@ func Test_k8sAPICollector_StreamRoles(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down Expand Up @@ -295,7 +292,6 @@ func Test_k8sAPICollector_StreamRoleBindings(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down Expand Up @@ -364,7 +360,6 @@ func Test_k8sAPICollector_StreamNodes(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down Expand Up @@ -433,7 +428,6 @@ func Test_k8sAPICollector_StreamClusterRoles(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down Expand Up @@ -502,7 +496,6 @@ func Test_k8sAPICollector_StreamClusterRoleBindings(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down Expand Up @@ -571,7 +564,6 @@ func Test_k8sAPICollector_StreamEndpoints(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
clientset, mock := tt.testfct(t)
Expand Down
1 change: 0 additions & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestMustLoadConfig(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := viper.New()
Expand Down
3 changes: 1 addition & 2 deletions pkg/dump/ingestor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestNewDumpIngestor(t *testing.T) { //nolint:paralleltest,nolintlint
// Can not run parallel tests as the environment variable KUBECONFIG is set
// t.Setenv is not compatible with parallel tests
for _, tt := range tests { //nolint:paralleltest
tt := tt

t.Run(tt.name, func(t *testing.T) {
got, err := NewDumpIngestor(ctx, tt.args.collectorClient, tt.args.compression, tt.args.directoryOutput, tt.args.runID)
if (err != nil) != tt.wantErr {
Expand Down Expand Up @@ -127,7 +127,6 @@ func TestDumpIngestor_DumpK8sObjects(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
mDumpWriter, mCollectorClient := tt.testfct(t)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/cluster_role_binding_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func TestDumpIngestor_IngestClusterRoleBinding(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.clusterRoleBinding)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/cluster_role_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func TestDumpIngestor_IngestClusterRole(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.clusterRoles)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/endpoint_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestEndpoint(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.endpoints)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/node_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func TestDumpIngestor_IngestNode(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.nodes)
Expand Down
2 changes: 0 additions & 2 deletions pkg/dump/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func NewPipelineDumpIngestor(ctx context.Context, collector collector.CollectorC
func (p *PipelineDumpIngestor) Run(ctx context.Context) error {
var err error
for _, v := range p.sequence {
v := v
p.wp.Submit(func() error {
errDump := dumpK8sObjs(ctx, v.operationName, v.entity, v.streamFunc)
if errDump != nil {
Expand All @@ -161,7 +160,6 @@ func (p *PipelineDumpIngestor) WaitAndClose(ctx context.Context) error {
}

for _, v := range p.closingSequence {
v := v
errDump := dumpK8sObjs(ctx, v.operationName, v.entity, v.streamFunc)
if errDump != nil {
err = errors.Join(err, errDump)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func TestPipelineDumpIngestor_Run(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
mDumpWriter, mCollectorClient := tt.testfct(t)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/pod_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestPod(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.pods)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/role_binding_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestRoleBinding(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.roleBindings)
Expand Down
1 change: 0 additions & 1 deletion pkg/dump/pipeline/role_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestRole(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ingestor := tt.testfct(t, tt.args.roles)
Expand Down
4 changes: 0 additions & 4 deletions pkg/dump/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestParsePath(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := ParsePath(context.TODO(), tt.args.path)
Expand Down Expand Up @@ -138,7 +137,6 @@ func TestDumpResult_GetFilename(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
i := &DumpResult{
Expand Down Expand Up @@ -192,7 +190,6 @@ func TestDumpResult_GetFullPath(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
i := &DumpResult{
Expand Down Expand Up @@ -282,7 +279,6 @@ func TestNewDumpResult(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := NewDumpResult(tt.args.clusterName, tt.args.runID, tt.args.isCompressed)
Expand Down
2 changes: 0 additions & 2 deletions pkg/ingestor/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func TestIngestorAPI_Ingest(t *testing.T) {
// },
}
for _, tt := range tests {
tt := tt
mt.Run(tt.name, func(mt *mtest.T) {
mt.Parallel()
mockedPuller := mocksPuller.NewDataPuller(t)
Expand Down Expand Up @@ -224,7 +223,6 @@ func TestIngestorAPI_isAlreadyIngestedInDB(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
mt.Run(tt.name, func(mt *mtest.T) {
mt.Parallel()
g := &IngestorAPI{
Expand Down
5 changes: 0 additions & 5 deletions pkg/ingestor/puller/blob/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func TestBlobStore_ListFiles(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -280,7 +279,6 @@ func TestBlobStore_Pull(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -374,7 +372,6 @@ func TestNewBlobStorage(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := NewBlobStorage(tt.args.cfg, tt.args.blobConfig)
Expand Down Expand Up @@ -451,7 +448,6 @@ func TestBlobStore_Put(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down Expand Up @@ -515,7 +511,6 @@ func TestBlobStore_Extract(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := context.Background()
Expand Down
4 changes: 0 additions & 4 deletions pkg/ingestor/puller/puller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func Test_sanitizeExtractPath(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if err := sanitizeExtractPath(tt.args.filePath, tt.args.destination); (err != nil) != tt.wantErr {
Expand Down Expand Up @@ -83,7 +82,6 @@ func TestCheckSanePath(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if err := CheckSanePath(tt.args.path, tt.args.baseFolder); (err != nil) != tt.wantErr {
Expand Down Expand Up @@ -124,7 +122,6 @@ func TestExtractTarGz(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tmpPath, err := os.MkdirTemp("/tmp", "kubehound-test")
Expand Down Expand Up @@ -195,7 +192,6 @@ func TestIsTarGz(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got, err := IsTarGz(context.TODO(), tt.args.filePath, tt.args.maxArchiveSize)
Expand Down
3 changes: 0 additions & 3 deletions pkg/kubehound/graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ func (b *Builder) buildSimple(ctx context.Context, oic *converter.ObjectIDConver
}

for label, e := range b.edges.Simple() {
e := e
label := label

wp.Submit(func() error {
err := b.buildEdge(workCtx, label, e, oic)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/vertex/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func TestContainer_Traversal(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := Container{}
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/vertex/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestIdentity_Traversal(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := Identity{}
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/vertex/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestNode_Traversal(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := Node{}
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/vertex/permission_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestPermissionSet_Traversal(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := PermissionSet{}
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/vertex/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestPod_Traversal(t *testing.T) {
}

for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
v := Pod{}
Expand Down
Loading
Loading