quota: format code with gofumpt
Formatting the code with https://github.com/mvdan/gofumpt Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b2663a0f73
commit
f18ac2d0bc
3 changed files with 13 additions and 13 deletions
|
@ -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() {}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue