Skip to content

Commit

Permalink
Remove dependence on io/ioutil, update Go to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
donatwork committed Aug 21, 2023
1 parent be811c1 commit c28dff0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/dell/csm-metrics-powerscale

go 1.20
go 1.21

require (
github.com/dell/goisilon v1.11.0
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQL
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
Expand Down Expand Up @@ -231,6 +232,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down Expand Up @@ -281,6 +283,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
Expand Down
4 changes: 2 additions & 2 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

Expand Down Expand Up @@ -51,7 +51,7 @@ func GetPowerScaleClusters(filePath string, logger *logrus.Logger) (map[string]*
Clusters []*service.PowerScaleCluster `yaml:"isilonClusters"`
}

data, err := ioutil.ReadFile(filepath.Clean(filePath))
data, err := os.ReadFile(filepath.Clean(filePath))
if err != nil {
logger.WithError(err).Errorf("cannot read file %s", filePath)
return nil, nil, err
Expand Down
8 changes: 4 additions & 4 deletions internal/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package common_test

import (
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -69,11 +69,11 @@ func Test_Run(t *testing.T) {
logger := logrus.New()
filePath, expectError := test(t)

fileContentBytes, _ := ioutil.ReadFile(filePath)
fileContentBytes, _ := os.ReadFile(filePath)

newContent := strings.Replace(string(fileContentBytes), "[serverip]", serverIP, 1)
newContent = strings.Replace(newContent, "[serverport]", serverPort, 1)
ioutil.WriteFile(filePath, []byte(newContent), 0644)
os.WriteFile(filePath, []byte(newContent), 0644)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)

Check failure on line 76 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

clusters, defaultCluster, err := common.GetPowerScaleClusters(filePath, logger)

Expand All @@ -86,7 +86,7 @@ func Test_Run(t *testing.T) {
assert.NotNil(t, defaultCluster)
assert.Nil(t, err)
}
ioutil.WriteFile(filePath, fileContentBytes, 0644)
os.WriteFile(filePath, fileContentBytes, 0644)

Check failure on line 89 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)

Check failure on line 89 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)

Check failure on line 89 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)

Check failure on line 89 in internal/common/common_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)
})
}
}
Expand Down
11 changes: 6 additions & 5 deletions internal/service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package service_test
import (
"context"
"errors"
"os"
"testing"

"github.com/dell/goisilon"
"github.com/dell/goisilon/api/json"
"io/ioutil"
v1 "k8s.io/api/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"

"github.com/dell/csm-metrics-powerscale/internal/service"
"github.com/dell/csm-metrics-powerscale/internal/service/mocks"
Expand Down Expand Up @@ -75,12 +76,12 @@ var mockVolumes = []k8s.VolumeInfo{

func Test_ExportVolumeMetrics(t *testing.T) {
quotaFile1 := "testdata/recordings/client1-quotas.json"
contentBytes1, _ := ioutil.ReadFile(quotaFile1)
contentBytes1, _ := os.ReadFile(quotaFile1)
var client1MockQuotaList goisilon.QuotaList
json.Unmarshal(contentBytes1, &client1MockQuotaList)

quotaFile2 := "testdata/recordings/client2-quotas.json"
contentBytes2, _ := ioutil.ReadFile(quotaFile2)
contentBytes2, _ := os.ReadFile(quotaFile2)
var client2MockQuotaList goisilon.QuotaList
json.Unmarshal(contentBytes2, &client2MockQuotaList)

Expand Down Expand Up @@ -441,7 +442,7 @@ func Test_ExportClusterMetrics(t *testing.T) {
metrics.EXPECT().RecordClusterPerformanceStatsMetrics(gomock.Any(), gomock.Any()).Times(1)

file := "testdata/recordings/platform-3-statistics-current.json"
contentBytes, _ := ioutil.ReadFile(file)
contentBytes, _ := os.ReadFile(file)
var stats goisilon.FloatStats
json.Unmarshal(contentBytes, &stats)

Expand Down

0 comments on commit c28dff0

Please sign in to comment.