From fea111832860d06ebabb38503471c62a69ca8c61 Mon Sep 17 00:00:00 2001 From: alikdell <52920355+alikdell@users.noreply.github.com> Date: Fri, 1 Mar 2024 13:43:03 -0500 Subject: [PATCH] upgrade goclient library and fix linting (#73) --- .github/workflows/linters.yaml | 2 +- cmd/metrics-powerstore/main.go | 4 ++-- go.mod | 4 ++-- go.sum | 8 ++++---- internal/k8s/k8sapi_test.go | 10 +++++----- internal/k8s/leader_elector.go | 2 +- internal/k8s/leader_elector_test.go | 6 +++--- internal/k8s/volume_finder_test.go | 6 +++--- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/linters.yaml b/.github/workflows/linters.yaml index cc151df..3380366 100644 --- a/.github/workflows/linters.yaml +++ b/.github/workflows/linters.yaml @@ -26,5 +26,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v4 with: - version: v1.53 + version: latest skip-cache: true diff --git a/cmd/metrics-powerstore/main.go b/cmd/metrics-powerstore/main.go index 56a691c..26c8ba8 100644 --- a/cmd/metrics-powerstore/main.go +++ b/cmd/metrics-powerstore/main.go @@ -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) @@ -138,7 +138,7 @@ func main() { }) configFileListener.WatchConfig() - configFileListener.OnConfigChange(func(e fsnotify.Event) { + configFileListener.OnConfigChange(func(_ fsnotify.Event) { updatePowerStoreConnection(powerStoreSvc, logger) }) diff --git a/go.mod b/go.mod index 804f56b..ea32b83 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 98c4cfd..5db0cf6 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/k8s/k8sapi_test.go b/internal/k8s/k8sapi_test.go index 9a3d080..b1765fb 100644 --- a/internal/k8s/k8sapi_test.go +++ b/internal/k8s/k8sapi_test.go @@ -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") } @@ -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) @@ -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) } diff --git a/internal/k8s/leader_elector.go b/internal/k8s/leader_elector.go index c0d685d..91e3a11 100644 --- a/internal/k8s/leader_elector.go +++ b/internal/k8s/leader_elector.go @@ -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{ diff --git a/internal/k8s/leader_elector_test.go b/internal/k8s/leader_elector_test.go index 0610935..8fd5ba4 100644 --- a/internal/k8s/leader_elector_test.go +++ b/internal/k8s/leader_elector_test.go @@ -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") } @@ -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) diff --git a/internal/k8s/volume_finder_test.go b/internal/k8s/volume_finder_test.go index 90c5615..3bbf242 100644 --- a/internal/k8s/volume_finder_test.go +++ b/internal/k8s/volume_finder_test.go @@ -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") }