Skip to content

Commit 2c7469d

Browse files
committed
improve
1 parent 8ab3684 commit 2c7469d

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

.golangci.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
run:
2+
concurrency: 4
3+
timeout: 5m
4+
issues-exit-code: 1
5+
tests: true
6+
modules-download-mode: readonly
7+
8+
linters-settings:
9+
govet:
10+
enable-all: true
11+
disable:
12+
- shadow
13+
- fieldalignment
14+
gosec:
15+
includes: []
16+
17+
linters:
18+
disable-all: true
19+
enable:
20+
- err113
21+
- gofmt
22+
- goimports
23+
- govet
24+
- ineffassign
25+
- misspell
26+
- staticcheck
27+
- unused
28+
- goheader
29+
- gosec

Makefile

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ DOCKER_TAG := latest
66
# Go build flags
77
GO_BUILD_FLAGS := -ldflags="-s -w"
88

9-
.PHONY: all build docker clean
9+
.PHONY: all build docker clean lint
1010

11-
all: build docker push
11+
all: lint build docker push
1212

13-
build:
13+
lint:
14+
@echo "Running golangci-lint..."
15+
golangci-lint run ./...
16+
17+
build: lint
1418
@echo "Building Go binary..."
1519
go build $(GO_BUILD_FLAGS) -o $(BINARY_NAME) ./cmd/main.go
1620

pkg/iperf/test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package iperf
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"os"
78
"os/signal"
@@ -16,6 +17,9 @@ import (
1617
"k8s.io/client-go/kubernetes"
1718
)
1819

20+
// At the package level, add this static error:
21+
var errIperf3ClientPodFailed = errors.New("iperf3 client pod failed")
22+
1923
// TestConfig holds the configuration for the iperf3 test
2024
type TestConfig struct {
2125
Client *kubernetes.Clientset
@@ -247,7 +251,7 @@ PodCompleted:
247251
fmt.Println(string(logs))
248252

249253
if podPhase == corev1.PodFailed {
250-
return fmt.Errorf("iperf3 client pod failed")
254+
return fmt.Errorf("iperf3 client execution: %w", errIperf3ClientPodFailed)
251255
}
252256

253257
return nil

0 commit comments

Comments
 (0)