Fix numerous lint issues

Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
This commit is contained in:
Shengqi Chen 2025-02-27 22:42:49 +08:00
parent c01de06ac3
commit d2b3e731bf
No known key found for this signature in database
9 changed files with 41 additions and 41 deletions

View File

@ -9,7 +9,7 @@ import (
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/moby/moby/pkg/reexec" "github.com/moby/sys/reexec"
"github.com/pkg/profile" "github.com/pkg/profile"
"github.com/urfave/cli" "github.com/urfave/cli"
"gopkg.in/op/go-logging.v1" "gopkg.in/op/go-logging.v1"

2
go.mod
View File

@ -18,6 +18,7 @@ require (
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
github.com/imdario/mergo v0.3.16 github.com/imdario/mergo v0.3.16
github.com/moby/moby v28.0.1+incompatible github.com/moby/moby v28.0.1+incompatible
github.com/moby/sys/reexec v0.1.0
github.com/opencontainers/runtime-spec v1.2.0 github.com/opencontainers/runtime-spec v1.2.0
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/pkg/profile v1.7.0 github.com/pkg/profile v1.7.0
@ -67,7 +68,6 @@ require (
github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/leodido/go-urn v1.4.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/sys/reexec v0.1.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect github.com/moby/sys/userns v0.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect

View File

@ -15,7 +15,7 @@ import (
cgroups "github.com/containerd/cgroups/v3" cgroups "github.com/containerd/cgroups/v3"
cgv1 "github.com/containerd/cgroups/v3/cgroup1" cgv1 "github.com/containerd/cgroups/v3/cgroup1"
cgv2 "github.com/containerd/cgroups/v3/cgroup2" cgv2 "github.com/containerd/cgroups/v3/cgroup2"
"github.com/moby/moby/pkg/reexec" "github.com/moby/sys/reexec"
contspecs "github.com/opencontainers/runtime-spec/specs-go" contspecs "github.com/opencontainers/runtime-spec/specs-go"
) )

View File

@ -14,7 +14,7 @@ import (
cgv1 "github.com/containerd/cgroups/v3/cgroup1" cgv1 "github.com/containerd/cgroups/v3/cgroup1"
cgv2 "github.com/containerd/cgroups/v3/cgroup2" cgv2 "github.com/containerd/cgroups/v3/cgroup2"
units "github.com/docker/go-units" units "github.com/docker/go-units"
"github.com/moby/moby/pkg/reexec" "github.com/moby/sys/reexec"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
) )
@ -250,7 +250,7 @@ sleep 30
if cgcf.Group == "" { if cgcf.Group == "" {
wkrg, err := cgv2.NestedGroupPath("") wkrg, err := cgv2.NestedGroupPath("")
So(err, ShouldBeNil) So(err, ShouldBeNil)
wkrMgr, err := cgv2.Load(wkrg) wkrMgr, _ := cgv2.Load(wkrg)
allCtrls, err := wkrMgr.Controllers() allCtrls, err := wkrMgr.Controllers()
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = wkrMgr.ToggleControllers(allCtrls, cgv2.Disable) err = wkrMgr.ToggleControllers(allCtrls, cgv2.Disable)

View File

@ -10,12 +10,12 @@ import (
func TestConfigDiff(t *testing.T) { func TestConfigDiff(t *testing.T) {
Convey("When old and new configs are equal", t, func() { Convey("When old and new configs are equal", t, func() {
oldList := []mirrorConfig{ oldList := []mirrorConfig{
mirrorConfig{Name: "debian"}, {Name: "debian"},
mirrorConfig{Name: "debian-security"}, {Name: "debian-security"},
mirrorConfig{Name: "fedora"}, {Name: "fedora"},
mirrorConfig{Name: "archlinux"}, {Name: "archlinux"},
mirrorConfig{Name: "AOSP"}, {Name: "AOSP"},
mirrorConfig{Name: "ubuntu"}, {Name: "ubuntu"},
} }
newList := make([]mirrorConfig, len(oldList)) newList := make([]mirrorConfig, len(oldList))
copy(newList, oldList) copy(newList, oldList)
@ -25,12 +25,12 @@ func TestConfigDiff(t *testing.T) {
}) })
Convey("When old config is empty", t, func() { Convey("When old config is empty", t, func() {
newList := []mirrorConfig{ newList := []mirrorConfig{
mirrorConfig{Name: "debian"}, {Name: "debian"},
mirrorConfig{Name: "debian-security"}, {Name: "debian-security"},
mirrorConfig{Name: "fedora"}, {Name: "fedora"},
mirrorConfig{Name: "archlinux"}, {Name: "archlinux"},
mirrorConfig{Name: "AOSP"}, {Name: "AOSP"},
mirrorConfig{Name: "ubuntu"}, {Name: "ubuntu"},
} }
oldList := make([]mirrorConfig, 0) oldList := make([]mirrorConfig, 0)
@ -39,12 +39,12 @@ func TestConfigDiff(t *testing.T) {
}) })
Convey("When new config is empty", t, func() { Convey("When new config is empty", t, func() {
oldList := []mirrorConfig{ oldList := []mirrorConfig{
mirrorConfig{Name: "debian"}, {Name: "debian"},
mirrorConfig{Name: "debian-security"}, {Name: "debian-security"},
mirrorConfig{Name: "fedora"}, {Name: "fedora"},
mirrorConfig{Name: "archlinux"}, {Name: "archlinux"},
mirrorConfig{Name: "AOSP"}, {Name: "AOSP"},
mirrorConfig{Name: "ubuntu"}, {Name: "ubuntu"},
} }
newList := make([]mirrorConfig, 0) newList := make([]mirrorConfig, 0)
@ -53,19 +53,19 @@ func TestConfigDiff(t *testing.T) {
}) })
Convey("When giving two config lists with different names", t, func() { Convey("When giving two config lists with different names", t, func() {
oldList := []mirrorConfig{ oldList := []mirrorConfig{
mirrorConfig{Name: "debian"}, {Name: "debian"},
mirrorConfig{Name: "debian-security"}, {Name: "debian-security"},
mirrorConfig{Name: "fedora"}, {Name: "fedora"},
mirrorConfig{Name: "archlinux"}, {Name: "archlinux"},
mirrorConfig{Name: "AOSP", Env: map[string]string{"REPO": "/usr/bin/repo"}}, {Name: "AOSP", Env: map[string]string{"REPO": "/usr/bin/repo"}},
mirrorConfig{Name: "ubuntu"}, {Name: "ubuntu"},
} }
newList := []mirrorConfig{ newList := []mirrorConfig{
mirrorConfig{Name: "debian"}, {Name: "debian"},
mirrorConfig{Name: "debian-cd"}, {Name: "debian-cd"},
mirrorConfig{Name: "archlinuxcn"}, {Name: "archlinuxcn"},
mirrorConfig{Name: "AOSP", Env: map[string]string{"REPO": "/usr/local/bin/aosp-repo"}}, {Name: "AOSP", Env: map[string]string{"REPO": "/usr/local/bin/aosp-repo"}},
mirrorConfig{Name: "ubuntu-ports"}, {Name: "ubuntu-ports"},
} }
difference := diffMirrorConfig(oldList, newList) difference := diffMirrorConfig(oldList, newList)

View File

@ -77,7 +77,7 @@ func newRsyncProvider(c rsyncConfig) (*rsyncProvider, error) {
options = c.overriddenOptions options = c.overriddenOptions
} }
if c.useOverrideOnly == true { if c.useOverrideOnly {
if c.overriddenOptions == nil { if c.overriddenOptions == nil {
return nil, errors.New("rsync_override_only is set but no rsync_override provided") return nil, errors.New("rsync_override_only is set but no rsync_override provided")
} }

View File

@ -12,7 +12,7 @@ import (
"github.com/codeskyblue/go-sh" "github.com/codeskyblue/go-sh"
cgv1 "github.com/containerd/cgroups/v3/cgroup1" cgv1 "github.com/containerd/cgroups/v3/cgroup1"
"github.com/moby/moby/pkg/reexec" "github.com/moby/sys/reexec"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )

View File

@ -147,7 +147,7 @@ func TestWorker(t *testing.T) {
}) })
Convey("with one job", func(ctx C) { Convey("with one job", func(ctx C) {
workerCfg.Mirrors = []mirrorConfig{ workerCfg.Mirrors = []mirrorConfig{
mirrorConfig{ {
Name: "job-ls", Name: "job-ls",
Provider: provCommand, Provider: provCommand,
Command: "ls", Command: "ls",
@ -194,17 +194,17 @@ func TestWorker(t *testing.T) {
}) })
Convey("with several jobs", func(ctx C) { Convey("with several jobs", func(ctx C) {
workerCfg.Mirrors = []mirrorConfig{ workerCfg.Mirrors = []mirrorConfig{
mirrorConfig{ {
Name: "job-ls-1", Name: "job-ls-1",
Provider: provCommand, Provider: provCommand,
Command: "ls", Command: "ls",
}, },
mirrorConfig{ {
Name: "job-fail", Name: "job-fail",
Provider: provCommand, Provider: provCommand,
Command: "non-existent-command-xxxx", Command: "non-existent-command-xxxx",
}, },
mirrorConfig{ {
Name: "job-ls-2", Name: "job-ls-2",
Provider: provCommand, Provider: provCommand,
Command: "ls", Command: "ls",

View File

@ -12,7 +12,7 @@ import (
func TestZFSHook(t *testing.T) { func TestZFSHook(t *testing.T) {
Convey("ZFS Hook should work", t, func(ctx C) { Convey("ZFS Hook should work", t, func(ctx C) {
tmpDir, err := os.MkdirTemp("", "tunasync") tmpDir, _ := os.MkdirTemp("", "tunasync")
tmpFile := filepath.Join(tmpDir, "log_file") tmpFile := filepath.Join(tmpDir, "log_file")
c := cmdConfig{ c := cmdConfig{