From f18ac2d0bc223639389251bb7d73cf92eae78f05 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 20 Jan 2022 14:13:30 +0100 Subject: [PATCH] quota: format code with gofumpt Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn --- quota/errors.go | 7 ++----- quota/projectquota.go | 15 +++++++++------ quota/projectquota_test.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/quota/errors.go b/quota/errors.go index 37f3438bd0..0dc3735eb4 100644 --- a/quota/errors.go +++ b/quota/errors.go @@ -2,15 +2,12 @@ package quota // import "github.com/docker/docker/quota" import "github.com/docker/docker/errdefs" -var ( - _ errdefs.ErrNotImplemented = (*errQuotaNotSupported)(nil) -) +var _ errdefs.ErrNotImplemented = (*errQuotaNotSupported)(nil) // ErrQuotaNotSupported indicates if were found the FS didn't have projects quotas available var ErrQuotaNotSupported = errQuotaNotSupported{} -type errQuotaNotSupported struct { -} +type errQuotaNotSupported struct{} func (e errQuotaNotSupported) NotImplemented() {} diff --git a/quota/projectquota.go b/quota/projectquota.go index 575e7a9d26..a0f6f442e0 100644 --- a/quota/projectquota.go +++ b/quota/projectquota.go @@ -51,6 +51,7 @@ struct fsxattr { const int Q_XGETQSTAT_PRJQUOTA = QCMD(Q_XGETQSTAT, PRJQUOTA); */ import "C" + import ( "context" "os" @@ -70,8 +71,10 @@ type pquotaState struct { nextProjectID uint32 } -var pquotaStateInst *pquotaState -var pquotaStateOnce sync.Once +var ( + pquotaStateInst *pquotaState + pquotaStateOnce sync.Once +) // getPquotaState - get global pquota state tracker instance func getPquotaState() *pquotaState { @@ -230,7 +233,7 @@ func setProjectQuota(backingFsBlockDev string, projectID uint32, quota Quota) er d.d_blk_hardlimit = C.__u64(quota.Size / 512) d.d_blk_softlimit = d.d_blk_hardlimit - var cs = C.CString(backingFsBlockDev) + cs := C.CString(backingFsBlockDev) defer C.free(unsafe.Pointer(cs)) _, _, errno := unix.Syscall6(unix.SYS_QUOTACTL, C.Q_XSETPQLIM, @@ -258,7 +261,7 @@ func (q *Control) GetQuota(targetPath string, quota *Quota) error { // var d C.fs_disk_quota_t - var cs = C.CString(q.backingFsBlockDev) + cs := C.CString(q.backingFsBlockDev) defer C.free(unsafe.Pointer(cs)) _, _, errno := unix.Syscall6(unix.SYS_QUOTACTL, C.Q_XGETPQUOTA, @@ -409,7 +412,7 @@ func makeBackingFsDev(home string) (string, error) { backingFsBlockDev := path.Join(home, "backingFsBlockDev") // Re-create just in case someone copied the home directory over to a new device unix.Unlink(backingFsBlockDev) - err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0600, int(stat.Dev)) + err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0o600, int(stat.Dev)) switch err { case nil: return backingFsBlockDev, nil @@ -423,7 +426,7 @@ func makeBackingFsDev(home string) (string, error) { } func hasQuotaSupport(backingFsBlockDev string) (bool, error) { - var cs = C.CString(backingFsBlockDev) + cs := C.CString(backingFsBlockDev) defer free(cs) var qstat C.fs_quota_stat_t diff --git a/quota/projectquota_test.go b/quota/projectquota_test.go index 072c3f81cd..8857e607f5 100644 --- a/quota/projectquota_test.go +++ b/quota/projectquota_test.go @@ -49,7 +49,7 @@ func testBlockDevQuotaEnabled(t *testing.T, mountPoint, backingFsDev, testDir st func testSmallerThanQuota(t *testing.T, ctrl *Control, homeDir, testDir, testSubDir string) { assert.NilError(t, ctrl.SetQuota(testSubDir, Quota{testQuotaSize})) smallerThanQuotaFile := filepath.Join(testSubDir, "smaller-than-quota") - assert.NilError(t, os.WriteFile(smallerThanQuotaFile, make([]byte, testQuotaSize/2), 0644)) + assert.NilError(t, os.WriteFile(smallerThanQuotaFile, make([]byte, testQuotaSize/2), 0o644)) assert.NilError(t, os.Remove(smallerThanQuotaFile)) } @@ -60,7 +60,7 @@ func testBiggerThanQuota(t *testing.T, ctrl *Control, homeDir, testDir, testSubD assert.NilError(t, ctrl.SetQuota(testSubDir, Quota{testQuotaSize})) biggerThanQuotaFile := filepath.Join(testSubDir, "bigger-than-quota") - err := os.WriteFile(biggerThanQuotaFile, make([]byte, testQuotaSize+1), 0644) + err := os.WriteFile(biggerThanQuotaFile, make([]byte, testQuotaSize+1), 0o644) assert.Assert(t, is.ErrorContains(err, "")) if err == io.ErrShortWrite { assert.NilError(t, os.Remove(biggerThanQuotaFile))