Skip to content

Commit 259c482

Browse files
authored
fix golangci-lint errors (#733)
Signed-off-by: Bala.FA <[email protected]>
1 parent ae995d5 commit 259c482

File tree

26 files changed

+55
-83
lines changed

26 files changed

+55
-83
lines changed

.github/workflows/linters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ jobs:
2727
SHELLCHECK_OPTS: -e SC1091 -e SC2016
2828
- uses: golangci/golangci-lint-action@v3
2929
with:
30-
version: v1.51.2
30+
version: v1.52.1
3131
args: --config ./.golangci.yml --timeout=60m
3232
skip-go-installation: true

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ issues:
3030
- exitAfterDefer
3131

3232
service:
33-
golangci-lint-version: 1.51.2 # use the fixed version to not introduce new linters unexpectedly
33+
golangci-lint-version: 1.52.1 # use the fixed version to not introduce new linters unexpectedly

cmd/directpv/node-controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ var nodeControllerCmd = &cobra.Command{
4040
if err := node.Sync(c.Context(), nodeID); err != nil {
4141
return err
4242
}
43-
return startNodeController(c.Context(), args)
43+
return startNodeController(c.Context())
4444
},
4545
}
4646

47-
func startNodeController(ctx context.Context, args []string) error {
47+
func startNodeController(ctx context.Context) error {
4848
var cancel context.CancelFunc
4949
ctx, cancel = context.WithCancel(ctx)
5050
defer cancel()

cmd/kubectl-directpv/install.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ func getLegacyFlag(ctx context.Context) bool {
232232
if result.Err != nil {
233233
utils.Eprintf(quietFlag, true, "unable to get volumes; %v", result.Err)
234234
break
235-
} else {
236-
return true
237235
}
236+
237+
return true
238238
}
239239

240240
legacyclient.Init()
@@ -243,9 +243,9 @@ func getLegacyFlag(ctx context.Context) bool {
243243
if result.Err != nil {
244244
utils.Eprintf(quietFlag, true, "unable to get legacy volumes; %v", result.Err)
245245
break
246-
} else {
247-
return true
248246
}
247+
248+
return true
249249
}
250250

251251
return false

cmd/kubectl-directpv/label.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ func validateLabelCmd() error {
7474
if err := validateNodeArgs(); err != nil {
7575
return err
7676
}
77-
if err := validateDriveNameArgs(); err != nil {
78-
return err
79-
}
80-
return nil
77+
78+
return validateDriveNameArgs()
8179
}
8280

8381
func parseLabel(kv string) (labelKey types.LabelKey, labelValue types.LabelValue, err error) {

cmd/kubectl-directpv/list_drives.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var listDrivesCmd = &cobra.Command{
7272
os.Exit(-1)
7373
}
7474

75-
listDrivesMain(c.Context(), args)
75+
listDrivesMain(c.Context())
7676
},
7777
}
7878

@@ -121,7 +121,7 @@ func validateListDrivesArgs() error {
121121
return nil
122122
}
123123

124-
func listDrivesMain(ctx context.Context, args []string) {
124+
func listDrivesMain(ctx context.Context) {
125125
drives, err := drive.NewLister().
126126
NodeSelector(toLabelValues(nodesArgs)).
127127
DriveNameSelector(toLabelValues(drivesArgs)).

cmd/kubectl-directpv/list_volumes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var listVolumesCmd = &cobra.Command{
8080
os.Exit(-1)
8181
}
8282

83-
listVolumesMain(c.Context(), args)
83+
listVolumesMain(c.Context())
8484
},
8585
}
8686

@@ -159,7 +159,7 @@ func getPVCName(ctx context.Context, volume types.Volume) string {
159159
return "-"
160160
}
161161

162-
func listVolumesMain(ctx context.Context, args []string) {
162+
func listVolumesMain(ctx context.Context) {
163163
volumes, err := volume.NewLister().
164164
NodeSelector(toLabelValues(nodesArgs)).
165165
DriveNameSelector(toLabelValues(drivesArgs)).

pkg/consts/consts.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ const (
8888
// MountRootDir is mount root directory.
8989
MountRootDir = AppRootDir + "/mnt"
9090

91-
CredentialsSecretName = AppName + "-creds"
92-
93-
PrivateKeyFileName = "key.pem"
94-
PublicCertFileName = "cert.pem"
95-
9691
NodeServerName = "node-server"
9792
ControllerServerName = "controller"
9893
NodeControllerName = "node-controller"

pkg/consts/consts.go.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ const (
8686
// MountRootDir is mount root directory.
8787
MountRootDir = AppRootDir + "/mnt"
8888

89-
CredentialsSecretName = AppName + "-creds"
90-
91-
PrivateKeyFileName = "key.pem"
92-
PublicCertFileName = "cert.pem"
93-
9489
NodeServerName = "node-server"
9590
ControllerServerName = "controller"
9691
NodeControllerName = "node-controller"

pkg/controller/controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ type Controller struct {
7474
}
7575

7676
// New creates a new controller for the provided handler
77-
func New(ctx context.Context, name string, handler EventHandler, workers int, resyncPeriod time.Duration) *Controller {
77+
func New(name string, handler EventHandler, workers int, resyncPeriod time.Duration) *Controller {
7878
informer := cache.NewSharedIndexInformer(
7979
handler.ListerWatcher(),
8080
handler.ObjectType(),
@@ -153,9 +153,11 @@ func (c *Controller) HasSynced() bool {
153153
}
154154

155155
func (c *Controller) runWorker(ctx context.Context) {
156+
//revive:disable:empty-block
156157
for c.processNextItem(ctx) {
157158
// continue looping
158159
}
160+
//revive:enable:empty-block
159161
}
160162

161163
func (c *Controller) processNextItem(ctx context.Context) bool {

0 commit comments

Comments
 (0)