Skip to content

Commit daff1b1

Browse files
committed
golangci-lint: fmt code
1 parent c46d2c4 commit daff1b1

File tree

30 files changed

+104
-105
lines changed

30 files changed

+104
-105
lines changed

.golangci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
run:
2+
skip-files:
3+
- ".*_test.go"
4+
- pkg/utils/http/reverse_proxy.go
5+
- pkg/proxy/apiserver/options.go
6+
skip-dirs:
7+
- vendor/
8+
9+
linters:
10+
disable:
11+
- errcheck
12+
- unused

e2e/customoperator/app/controller/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func add(c client.Client, namespace, kind string) error {
6969
if cm.Data == nil {
7070
cm.Data = map[string]string{}
7171
}
72-
val, _ := cm.Data[key]
72+
val := cm.Data[key]
7373
sto := &store{}
7474
if val == "" {
7575
sto.Kinds = map[string]string{}
7676
} else {
7777
json.Unmarshal([]byte(val), sto)
7878
}
79-
names, _ := sto.Kinds[kind]
79+
names := sto.Kinds[kind]
8080
nameSet := list(names)
8181
if nameSet.Has(namespace) {
8282
return nil

e2e/customoperator/app/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
"flag"
2121
"fmt"
22-
"math/rand"
2322
_ "net/http/pprof"
2423
"os"
2524
"time"
@@ -60,8 +59,6 @@ func main() {
6059
pflag.Parse()
6160
ctrl.SetLogger(klogr.New())
6261

63-
rand.Seed(time.Now().UnixNano())
64-
6562
cfg := ctrl.GetConfigOrDie()
6663
cfg.UserAgent = "testapp"
6764

pkg/cmd/manager/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ package main
1818

1919
import (
2020
"flag"
21-
"math/rand"
2221
"net/http"
2322
_ "net/http/pprof"
2423
"os"
25-
"time"
2624

2725
"github.com/spf13/pflag"
2826
"k8s.io/apimachinery/pkg/runtime"
@@ -82,8 +80,6 @@ func main() {
8280
pflag.Parse()
8381
ctrl.SetLogger(klogr.New())
8482

85-
rand.Seed(time.Now().UnixNano())
86-
8783
go func() {
8884
if err := http.ListenAndServe(pprofAddr, nil); err != nil {
8985
setupLog.Error(err, "unable to start pprof")

pkg/cmd/proxy/main.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ import (
2020
"context"
2121
"flag"
2222
"fmt"
23-
"math/rand"
2423
"net"
2524
"net/http"
2625
"os"
27-
"time"
2826

2927
"github.com/prometheus/client_golang/prometheus/promhttp"
3028
"github.com/spf13/pflag"
@@ -53,7 +51,6 @@ var (
5351
)
5452

5553
func main() {
56-
rand.Seed(time.Now().UnixNano())
5754
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
5855
pflag.Parse()
5956

@@ -106,15 +103,11 @@ func main() {
106103

107104
serveHTTP(ctx, readyHandler)
108105
if stoppedWebhook != nil {
109-
select {
110-
case <-stoppedWebhook:
111-
klog.Infof("Webhook proxy stopped")
112-
}
113-
}
114-
select {
115-
case <-stoppedApiserver:
116-
klog.Infof("Apiserver proxy stopped")
106+
<-stoppedWebhook
107+
klog.Infof("Webhook proxy stopped")
117108
}
109+
<-stoppedApiserver
110+
klog.Infof("Apiserver proxy stopped")
118111
}
119112

120113
func serveHTTP(ctx context.Context, readyHandler *healthz.Handler) {

pkg/grpcregistry/grpc_registry.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ func (r *grpcRegistry) Start(ctx context.Context) error {
9898
return fmt.Errorf("error listening grpc server address %s: %v", addr, err)
9999
}
100100
klog.Infof("Start listening gRPC server with leaderElection=%v on %s", r.needLeaderElection, addr)
101-
go grpcServer.Serve(lis)
101+
go func() {
102+
if err = grpcServer.Serve(lis); err != nil {
103+
klog.Errorf("serve gRPC error %v", err)
104+
}
105+
}()
106+
102107
<-ctx.Done()
103108
return nil
104109
}

pkg/manager/controllers/patchrunnable/labelpatch_runnable.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ func (p *PatchRunnable) setInvalid(gvk schema.GroupVersionKind) {
282282
p.invalidL.Lock()
283283
defer p.invalidL.Unlock()
284284
p.invalid.Insert(groupVersionKindKey(gvk))
285-
return
286285
}
287286

288287
func groupVersionKindKey(gvk schema.GroupVersionKind) string {

pkg/manager/controllers/patchrunnable/patchrunnable_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package patchrunnable
1919
import (
2020
"context"
2121
"fmt"
22+
"math/rand"
2223
"net/url"
2324
"path/filepath"
2425
"testing"
@@ -169,3 +170,10 @@ func TestEnv(t *testing.T) {
169170
err = testEnv.Stop()
170171
g.Expect(err).NotTo(gomega.HaveOccurred())
171172
}
173+
174+
func TestRand(t *testing.T) {
175+
176+
for i := 0; i < 10; i++ {
177+
fmt.Println(rand.Int31())
178+
}
179+
}

pkg/manager/controllers/rollout/expectation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func SetExpectedRevision(sts *appsv1.StatefulSet, podRevision map[string]string)
5656

5757
func isUpdatedRevision(sts *appsv1.StatefulSet, po *corev1.Pod) bool {
5858
expectedRevision := recentRevision(sts)
59-
revision, _ := po.Labels[appsv1.StatefulSetRevisionLabel]
59+
revision := po.Labels[appsv1.StatefulSetRevisionLabel]
6060
return revision == expectedRevision
6161
}
6262

pkg/manager/controllers/rollout/rollout_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func isLeader(po *corev1.Pod, identity string) bool {
298298
func updateRolloutAnno(sts *appsv1.StatefulSet, upgradedPods []string) (updated bool) {
299299
msg, _ := json.Marshal(upgradedPods)
300300
val := string(msg)
301-
if upgradedPods == nil || len(upgradedPods) == 0 {
301+
if len(upgradedPods) == 0 {
302302
val = ""
303303
}
304304
if sts.Annotations == nil {

0 commit comments

Comments
 (0)