Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix golint in volume fs #97930

Merged
merged 1 commit into from Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion hack/.golint_failures
Expand Up @@ -183,7 +183,6 @@ pkg/volume/csi/fake
pkg/volume/git_repo
pkg/volume/iscsi
pkg/volume/testing
pkg/volume/util/fs
pkg/volume/util/volumepathhandler
pkg/volume/vsphere_volume
plugin/pkg/admission/eventratelimit/apis/eventratelimit/v1alpha1
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/metrics_du.go
Expand Up @@ -87,7 +87,7 @@ func (md *metricsDu) runFind(metrics *Metrics) error {
// getFsInfo writes metrics.Capacity and metrics.Available from the filesystem
// info
func (md *metricsDu) getFsInfo(metrics *Metrics) error {
available, capacity, _, inodes, inodesFree, _, err := fs.FsInfo(md.path)
available, capacity, _, inodes, inodesFree, _, err := fs.Info(md.path)
if err != nil {
return NewFsInfoFailedError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/volume/metrics_statfs.go
Expand Up @@ -55,7 +55,7 @@ func (md *metricsStatFS) GetMetrics() (*Metrics, error) {

// getFsInfo writes metrics.Capacity, metrics.Used and metrics.Available from the filesystem info
func (md *metricsStatFS) getFsInfo(metrics *Metrics) error {
available, capacity, usage, inodes, inodesFree, inodesUsed, err := fs.FsInfo(md.path)
available, capacity, usage, inodes, inodesFree, inodesUsed, err := fs.Info(md.path)
if err != nil {
return NewFsInfoFailedError(err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/volume/util/fs/fs.go
Expand Up @@ -30,9 +30,9 @@ import (
"k8s.io/kubernetes/pkg/volume/util/fsquota"
)

// FsInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
// Info linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
// for the filesystem that path resides upon.
func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why the func name "FsInfo" is not allowed by golint?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

pkg/volume/util/fs/fs.go:35:6: func name will be used as fs.FsInfo by other packages, and that stutters; consider calling this Info

statfs := &unix.Statfs_t{}
err := unix.Statfs(path, statfs)
if err != nil {
Expand Down
11 changes: 6 additions & 5 deletions pkg/volume/util/fs/fs_unsupported.go
Expand Up @@ -24,16 +24,17 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
)

// FSInfo unsupported returns 0 values for available and capacity and an error.
func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
return 0, 0, 0, 0, 0, 0, fmt.Errorf("FsInfo not supported for this build.")
// Info unsupported returns 0 values for available and capacity and an error.
func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
return 0, 0, 0, 0, 0, 0, fmt.Errorf("fsinfo not supported for this build")
}

// DiskUsage gets disk usage of specified path.
func DiskUsage(path string) (*resource.Quantity, error) {
return nil, fmt.Errorf("Du not supported for this build.")
return nil, fmt.Errorf("du not supported for this build")
}

// Find will always return zero since is on unsupported platform.
func Find(path string) (int64, error) {
return 0, fmt.Errorf("Find not supported for this build.")
return 0, fmt.Errorf("find not supported for this build")
}
6 changes: 3 additions & 3 deletions pkg/volume/util/fs/fs_windows.go
Expand Up @@ -34,9 +34,9 @@ var (
procGetDiskFreeSpaceEx = modkernel32.NewProc("GetDiskFreeSpaceExW")
)

// FSInfo returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
// Info returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
// for the filesystem that path resides upon.
func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
func Info(path string) (int64, int64, int64, int64, int64, int64, error) {
var freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes int64
var err error

Expand Down Expand Up @@ -77,7 +77,7 @@ func DiskUsage(path string) (*resource.Quantity, error) {
return &used, nil
}

// Always return zero since inodes is not supported on Windows.
// Find will always return zero since inodes is not supported on Windows.
func Find(path string) (int64, error) {
return 0, nil
}
Expand Down
24 changes: 12 additions & 12 deletions pkg/volume/util/fs/fs_windows_test.go
Expand Up @@ -27,35 +27,35 @@ import (

func TestDiskUsage(t *testing.T) {

dir_1, err := ioutil.TempDir("", "dir_1")
dir1, err := ioutil.TempDir("", "dir_1")
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
defer os.RemoveAll(dir_1)
defer os.RemoveAll(dir1)

tmpfile_1, err := ioutil.TempFile(dir_1, "test")
if _, err = tmpfile_1.WriteString("just for testing"); err != nil {
tmpfile1, err := ioutil.TempFile(dir1, "test")
if _, err = tmpfile1.WriteString("just for testing"); err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
dir_2, err := ioutil.TempDir(dir_1, "dir_2")
dir2, err := ioutil.TempDir(dir1, "dir_2")
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
tmpfile_2, err := ioutil.TempFile(dir_2, "test")
if _, err = tmpfile_2.WriteString("just for testing"); err != nil {
tmpfile2, err := ioutil.TempFile(dir2, "test")
if _, err = tmpfile2.WriteString("just for testing"); err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}

dirInfo1, err := os.Lstat(dir_1)
dirInfo1, err := os.Lstat(dir1)
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
dirInfo2, err := os.Lstat(dir_2)
dirInfo2, err := os.Lstat(dir2)
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
file1 := dir_1 + "/" + "test"
file2 := dir_2 + "/" + "test"
file1 := dir1 + "/" + "test"
file2 := dir2 + "/" + "test"
fileInfo1, err := os.Lstat(file1)
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
Expand All @@ -66,7 +66,7 @@ func TestDiskUsage(t *testing.T) {
}
total := dirInfo1.Size() + dirInfo2.Size() + fileInfo1.Size() + fileInfo2.Size()

size, err := DiskUsage(dir_1)
size, err := DiskUsage(dir1)
if err != nil {
t.Fatalf("TestDiskUsage failed: %s", err.Error())
}
Expand Down