Skip to content

Commit

Permalink
upgrade goclient library and fix linting (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
alikdell authored Mar 1, 2024
1 parent ea53c0c commit fea1118
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.53
version: latest
skip-cache: true
4 changes: 2 additions & 2 deletions cmd/metrics-powerstore/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func main() {
updateTracing(logger)

viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) {
viper.OnConfigChange(func(_ fsnotify.Event) {
updateLoggingSettings(logger)
updateCollectorAddress(config, exporter, logger)
updateProvisionerNames(volumeFinder, logger)
Expand All @@ -138,7 +138,7 @@ func main() {
})

configFileListener.WatchConfig()
configFileListener.OnConfigChange(func(e fsnotify.Event) {
configFileListener.OnConfigChange(func(_ fsnotify.Event) {
updatePowerStoreConnection(powerStoreSvc, logger)
})

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/dell/csm-metrics-powerstore
go 1.22

require (
github.com/dell/gocsi v1.9.0
github.com/dell/gopowerstore v1.14.0
github.com/dell/gocsi v1.10.0
github.com/dell/gopowerstore v1.15.0
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/mock v1.6.0
github.com/onsi/gomega v1.18.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dell/gocsi v1.9.0 h1:bdNuihZvn8oE2iNRM2pNAK7Ys63X6MVftg91479eX64=
github.com/dell/gocsi v1.9.0/go.mod h1:EfkorqCy3PXijLAAmTQlrmkZH4D16c8yCktB/iE/qYg=
github.com/dell/gopowerstore v1.14.0 h1:j4wSn25X2AH2t3/ySNPHmNWjqM0zHDkYyDPt+0uE8cc=
github.com/dell/gopowerstore v1.14.0/go.mod h1:YH3SpMX2dr3ouYWWPhk5lzjip3aaVVksFOSoenRDY5w=
github.com/dell/gocsi v1.10.0 h1:X3HQ4/Fx1bm857L497AF/uGCPiw1BB4OE4TpQYvsBEI=
github.com/dell/gocsi v1.10.0/go.mod h1:RkBQHWKqPuRBDipBglo40bd5h6wBzQkU4QeRUFOeKcs=
github.com/dell/gopowerstore v1.15.0 h1:9RmpAPiHQifrpHBd1XEkwVBCDSjql4nf3ZeqEcQaQrk=
github.com/dell/gopowerstore v1.15.0/go.mod h1:6oAr11lwtpjmlE+s+pDKx7qfQ1HvLFWtlFoNdI03ByQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
Expand Down
10 changes: 5 additions & 5 deletions internal/k8s/k8sapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ func Test_GetPersistentVolumes(t *testing.T) {
type configFn func() (*rest.Config, error)
check := func(fns ...checkFn) []checkFn { return fns }

hasNoError := func(t *testing.T, volumes *corev1.PersistentVolumeList, err error) {
hasNoError := func(t *testing.T, _ *corev1.PersistentVolumeList, err error) {
if err != nil {
t.Fatalf("expected no error")
}
}

checkExpectedOutput := func(expectedOutput *corev1.PersistentVolumeList) func(t *testing.T, volumes *corev1.PersistentVolumeList, err error) {
return func(t *testing.T, volumes *corev1.PersistentVolumeList, err error) {
return func(t *testing.T, volumes *corev1.PersistentVolumeList, _ error) {
assert.Equal(t, expectedOutput, volumes)
}
}

hasError := func(t *testing.T, volumes *corev1.PersistentVolumeList, err error) {
hasError := func(t *testing.T, _ *corev1.PersistentVolumeList, err error) {
if err == nil {
t.Fatalf("expected error")
}
Expand All @@ -74,7 +74,7 @@ func Test_GetPersistentVolumes(t *testing.T) {
return connect, nil, check(hasNoError, checkExpectedOutput(volumes))
},
"error connecting": func(*testing.T) (connectFn, configFn, []checkFn) {
connect := func(api *k8s.API) error {
connect := func(_ *k8s.API) error {
return errors.New("error")
}
return connect, nil, check(hasError)
Expand Down Expand Up @@ -127,7 +127,7 @@ func Test_NewForConfigError(t *testing.T) {
oldNewConfigFn := k8s.NewConfigFn
defer func() { k8s.NewConfigFn = oldNewConfigFn }()
expected := "could not create Clientset from KubeConfig"
k8s.NewConfigFn = func(config *rest.Config) (*kubernetes.Clientset, error) {
k8s.NewConfigFn = func(_ *rest.Config) (*kubernetes.Clientset, error) {
return nil, fmt.Errorf(expected)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/k8s/leader_elector.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (elect *LeaderElector) InitLeaderElection(endpoint string, namespace string
Callbacks: leaderelection.LeaderCallbacks{
OnStartedLeading: func(context.Context) {},
OnStoppedLeading: func() {},
OnNewLeader: func(identity string) {},
OnNewLeader: func(_ string) {},
},
Lock: &resourcelock.EndpointsLock{
EndpointsMeta: metav1.ObjectMeta{
Expand Down
6 changes: 3 additions & 3 deletions internal/k8s/leader_elector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Test_InitLeaderElection(t *testing.T) {
return nil, nil
}

clientset := func(config *rest.Config) (*kubernetes.Clientset, error) {
clientset := func(_ *rest.Config) (*kubernetes.Clientset, error) {
return nil, errors.New("error")
}

Expand All @@ -64,11 +64,11 @@ func Test_InitLeaderElection(t *testing.T) {
return nil, nil
}

clientset := func(config *rest.Config) (*kubernetes.Clientset, error) {
clientset := func(_ *rest.Config) (*kubernetes.Clientset, error) {
mockClientset := &kubernetes.Clientset{}
return mockClientset, nil
}
leaderelection := func(lec leaderelection.LeaderElectionConfig) (*leaderelection.LeaderElector, error) {
leaderelection := func(_ leaderelection.LeaderElectionConfig) (*leaderelection.LeaderElector, error) {
return nil, errors.New("error")
}
return configFn, clientset, leaderelection, check(hasError)
Expand Down
6 changes: 3 additions & 3 deletions internal/k8s/volume_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ func Test_K8sPersistentVolumeFinder(t *testing.T) {
type checkFn func(*testing.T, []k8s.VolumeInfo, error)
check := func(fns ...checkFn) []checkFn { return fns }

hasNoError := func(t *testing.T, volumes []k8s.VolumeInfo, err error) {
hasNoError := func(t *testing.T, _ []k8s.VolumeInfo, err error) {
if err != nil {
t.Fatalf("expected no error")
}
}

checkExpectedOutput := func(expectedOutput []k8s.VolumeInfo) func(t *testing.T, volumes []k8s.VolumeInfo, err error) {
return func(t *testing.T, volumes []k8s.VolumeInfo, err error) {
return func(t *testing.T, volumes []k8s.VolumeInfo, _ error) {
assert.Equal(t, expectedOutput, volumes)
}
}

hasError := func(t *testing.T, volumes []k8s.VolumeInfo, err error) {
hasError := func(t *testing.T, _ []k8s.VolumeInfo, err error) {
if err == nil {
t.Fatalf("expected error")
}
Expand Down

0 comments on commit fea1118

Please sign in to comment.