Skip to content

Commit

Permalink
Merge pull request #240 from kubeservice-stack/drop-ioutil
Browse files Browse the repository at this point in the history
Replace deprecation ioutil fucntions
  • Loading branch information
peter-wangxu authored Nov 24, 2023
2 parents 4e7d041 + 695264a commit 3f84fda
Show file tree
Hide file tree
Showing 365 changed files with 30,463 additions and 15,398 deletions.
31 changes: 16 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/aws/aws-sdk-go v1.44.44
github.com/container-storage-interface/spec v1.5.0
github.com/docker/go-units v0.4.0
github.com/golang/protobuf v1.5.2
github.com/golang/protobuf v1.5.3
github.com/google/credstore v0.0.0-20181218150457-e184c60ef875
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
Expand All @@ -17,15 +17,15 @@ require (
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/opentracing/opentracing-go v1.2.0
github.com/peter-wangxu/simple-golang-tools v0.0.0-20210209091758-458c22961dd2
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/client_golang v1.17.0
github.com/ricochet2200/go-disk-usage v0.0.0-20150921141558-f0d1b743428f
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
golang.org/x/net v0.8.0
golang.org/x/sys v0.6.0
golang.org/x/net v0.17.0
golang.org/x/sys v0.13.0
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.31.0
k8s.io/api v0.24.15
k8s.io/apimachinery v0.24.15
k8s.io/client-go v0.24.15
Expand All @@ -39,12 +39,14 @@ require (
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.4
)

require github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect; indirectgo-logr
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
Expand All @@ -56,28 +58,27 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/selinux v1.10.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
51 changes: 33 additions & 18 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/agent/discovery/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package discovery

import (
"io/ioutil"
"os"
"path/filepath"
"regexp"

Expand All @@ -28,7 +28,7 @@ import (
func (d *Discoverer) discoverDevices(newStatus *localv1alpha1.NodeLocalStorageStatus) error {
sysBlockPath := filepath.Join(d.SysPath, "/block")
blockRegExp := regexp.MustCompile(d.RegExp)
blockDirs, err := ioutil.ReadDir(sysBlockPath)
blockDirs, err := os.ReadDir(sysBlockPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/discovery/mountpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package discovery

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

localv1alpha1 "github.com/alibaba/open-local/pkg/apis/storage/v1alpha1"
Expand All @@ -34,7 +34,7 @@ func (d *Discoverer) discoverMountPoints(newStatus *localv1alpha1.NodeLocalStora
return fmt.Errorf("List mountpoint error: %s", err.Error())
}

files, err := ioutil.ReadDir(d.MountPath)
files, err := os.ReadDir(d.MountPath)
if err != nil {
return fmt.Errorf("Read mount path error: %s", err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/csi/client/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"
)
Expand All @@ -25,7 +25,7 @@ func DoRequest(url string) ([]byte, error) {
defer resp.Body.Close()

//
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/csi/nodeutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package csi

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -546,7 +545,7 @@ func checkIfRestored(path string) bool {
}

func labelRestored(path string) error {
if err := ioutil.WriteFile(filepath.Join(path, RestoreFileName), nil, 0644); err != nil {
if err := os.WriteFile(filepath.Join(path, RestoreFileName), nil, 0644); err != nil {
return fmt.Errorf("error writing restored file: %s", err.Error())
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/om/orphaned.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package om

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -44,7 +43,7 @@ func FixOrphanedPodIssue(line string) bool {

// check kubernetes csi volumes
csiPodPath := filepath.Join("/var/lib/kubelet/pods", orphanUID, "volumes/kubernetes.io~csi")
volumes, err := ioutil.ReadDir(csiPodPath)
volumes, err := os.ReadDir(csiPodPath)
if err != nil {
log.Warningf("OrphanPod: List Volumes with error: %s, line: %s", err.Error(), line)
return false
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package device

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -83,7 +83,7 @@ func GetPartitionsInfo(sysPath, blockName string) ([]Device, error) {
var devices []Device

blockPath := filepath.Join(sysPath, "/block", blockName)
dirs, err := ioutil.ReadDir(blockPath)
dirs, err := os.ReadDir(blockPath)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -142,7 +142,7 @@ func GetPartitionsInfo(sysPath, blockName string) ([]Device, error) {
}

func getFileContext(filePath string) (string, error) {
b, err := ioutil.ReadFile(filePath)
b, err := os.ReadFile(filePath)
if err != nil {
return "", fmt.Errorf("read file %s error: %s", filePath, err.Error())
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/utils/spdk/spdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package spdk
import (
"errors"
"fmt"
"io/ioutil"
"net/rpc"
"os"
"os/exec"
Expand Down Expand Up @@ -555,7 +554,7 @@ const VhostUserBlkMajor = 241
func getMinor(dir string) (uint32, error) {
var minors []uint32

files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -783,7 +782,7 @@ func getLoopDeviceFromSysfs(path string) (string, error) {
backingFile := fmt.Sprintf("%s/loop/backing_file", device)

// The contents of this file is the absolute path of "path".
data, err := ioutil.ReadFile(backingFile)
data, err := os.ReadFile(backingFile)
if err != nil {
continue
}
Expand Down
31 changes: 17 additions & 14 deletions vendor/github.com/cespare/xxhash/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/cespare/xxhash/v2/testall.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 20 additions & 27 deletions vendor/github.com/cespare/xxhash/v2/xxhash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3f84fda

Please sign in to comment.