Skip to content

Commit 012ffe8

Browse files
authored
Merge pull request #3294 from apostasie/dev-import-order
Import ordering
2 parents 728421a + 77b0a29 commit 012ffe8

File tree

274 files changed

+490
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+490
-175
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
run: make lint-yaml
3535
- name: shellcheck
3636
run: make lint-shell
37+
- name: go imports ordering
38+
run: |
39+
go install -v github.com/incu6us/goimports-reviser/v3@latest
40+
make lint-imports
3741
3842
test-unit:
3943
runs-on: ubuntu-24.04

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ clean:
7070
lint: lint-go lint-yaml lint-shell
7171

7272
lint-go:
73-
cd $(MAKEFILE_DIR) && golangci-lint run $(VERBOSE_FLAG_LONG)
73+
cd $(MAKEFILE_DIR) && golangci-lint run $(VERBOSE_FLAG_LONG) ./...
74+
75+
lint-imports:
76+
cd $(MAKEFILE_DIR) && goimports-reviser -list-diff -company-prefixes "github.com/containerd" ./...
77+
78+
lint-fix-imports:
79+
cd $(MAKEFILE_DIR) && goimports-reviser -company-prefixes "github.com/containerd" ./...
7480

7581
lint-yaml:
7682
cd $(MAKEFILE_DIR) && yamllint .

cmd/nerdctl/builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/spf13/cobra"
2626

2727
"github.com/containerd/log"
28+
2829
"github.com/containerd/nerdctl/v2/pkg/buildkitutil"
2930
)
3031

cmd/nerdctl/builder_build_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import (
2323
"strings"
2424
"testing"
2525

26-
"github.com/containerd/nerdctl/v2/pkg/testutil"
27-
"github.com/containerd/platforms"
2826
"gotest.tools/v3/assert"
27+
28+
"github.com/containerd/platforms"
29+
30+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2931
)
3032

3133
func TestBuild(t *testing.T) {

cmd/nerdctl/builder_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ import (
2424
"path/filepath"
2525
"testing"
2626

27+
"gotest.tools/v3/assert"
28+
2729
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
2830
"github.com/containerd/nerdctl/v2/pkg/testutil"
29-
"gotest.tools/v3/assert"
3031
)
3132

3233
func TestBuilderDebug(t *testing.T) {

cmd/nerdctl/completion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/spf13/cobra"
2424

2525
containerd "github.com/containerd/containerd/v2/client"
26+
2627
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2728
"github.com/containerd/nerdctl/v2/pkg/labels"
2829
"github.com/containerd/nerdctl/v2/pkg/netutil"

cmd/nerdctl/compose_config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import (
2222
"path/filepath"
2323
"testing"
2424

25-
"github.com/containerd/nerdctl/v2/pkg/testutil"
2625
"gotest.tools/v3/assert"
26+
27+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2728
)
2829

2930
func TestComposeConfig(t *testing.T) {

cmd/nerdctl/compose_cp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ package main
1919
import (
2020
"errors"
2121

22+
"github.com/spf13/cobra"
23+
2224
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2325
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
2426
"github.com/containerd/nerdctl/v2/pkg/composer"
2527
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
26-
"github.com/spf13/cobra"
2728
)
2829

2930
func newComposeCopyCommand() *cobra.Command {

cmd/nerdctl/compose_cp_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import (
2222
"path/filepath"
2323
"testing"
2424

25-
"github.com/containerd/nerdctl/v2/pkg/testutil"
2625
"gotest.tools/v3/assert"
26+
27+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2728
)
2829

2930
func TestComposeCopy(t *testing.T) {

cmd/nerdctl/compose_exec_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ import (
2424
"strings"
2525
"testing"
2626

27-
"github.com/containerd/nerdctl/v2/pkg/testutil"
2827
"gotest.tools/v3/assert"
28+
29+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2930
)
3031

3132
func TestComposeExec(t *testing.T) {

cmd/nerdctl/compose_images.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
containerd "github.com/containerd/containerd/v2/client"
2929
"github.com/containerd/containerd/v2/core/snapshots"
3030
"github.com/containerd/containerd/v2/pkg/progress"
31+
3132
"github.com/containerd/nerdctl/v2/pkg/clientutil"
3233
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
3334
"github.com/containerd/nerdctl/v2/pkg/formatter"

cmd/nerdctl/compose_ps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/containerd/errdefs"
3232
gocni "github.com/containerd/go-cni"
3333
"github.com/containerd/log"
34+
3435
"github.com/containerd/nerdctl/v2/pkg/clientutil"
3536
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
3637
"github.com/containerd/nerdctl/v2/pkg/containerutil"

cmd/nerdctl/compose_ps_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
"testing"
2424
"time"
2525

26+
"gotest.tools/v3/assert"
27+
2628
"github.com/containerd/nerdctl/v2/pkg/tabutil"
2729
"github.com/containerd/nerdctl/v2/pkg/testutil"
28-
"gotest.tools/v3/assert"
2930
)
3031

3132
func TestComposePs(t *testing.T) {

cmd/nerdctl/compose_push.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
package main
1818

1919
import (
20+
"github.com/spf13/cobra"
21+
2022
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2123
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
2224
"github.com/containerd/nerdctl/v2/pkg/composer"
23-
"github.com/spf13/cobra"
2425
)
2526

2627
func newComposePushCommand() *cobra.Command {

cmd/nerdctl/compose_rm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import (
2020
"fmt"
2121
"strings"
2222

23+
"github.com/spf13/cobra"
24+
2325
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2426
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
2527
"github.com/containerd/nerdctl/v2/pkg/composer"
26-
"github.com/spf13/cobra"
2728
)
2829

2930
func newComposeRemoveCommand() *cobra.Command {

cmd/nerdctl/compose_run_linux_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import (
2323
"testing"
2424
"time"
2525

26+
"gotest.tools/v3/assert"
27+
2628
"github.com/containerd/log"
29+
2730
"github.com/containerd/nerdctl/v2/pkg/testutil"
2831
"github.com/containerd/nerdctl/v2/pkg/testutil/nettestutil"
2932
"github.com/containerd/nerdctl/v2/pkg/testutil/testregistry"
30-
"gotest.tools/v3/assert"
3133
)
3234

3335
func TestComposeRun(t *testing.T) {

cmd/nerdctl/compose_start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
containerd "github.com/containerd/containerd/v2/client"
2828
"github.com/containerd/errdefs"
29+
2930
"github.com/containerd/nerdctl/v2/pkg/clientutil"
3031
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
3132
"github.com/containerd/nerdctl/v2/pkg/containerutil"

cmd/nerdctl/compose_top.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/spf13/cobra"
2323

2424
containerd "github.com/containerd/containerd/v2/client"
25+
2526
"github.com/containerd/nerdctl/v2/pkg/api/types"
2627
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2728
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"

cmd/nerdctl/compose_up.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import (
2222
"strconv"
2323
"strings"
2424

25+
"github.com/spf13/cobra"
26+
2527
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2628
"github.com/containerd/nerdctl/v2/pkg/cmd/compose"
2729
"github.com/containerd/nerdctl/v2/pkg/composer"
28-
"github.com/spf13/cobra"
2930
)
3031

3132
func newComposeUpCommand() *cobra.Command {

cmd/nerdctl/compose_up_linux_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"gotest.tools/v3/icmd"
2929

3030
"github.com/containerd/log"
31+
3132
"github.com/containerd/nerdctl/v2/pkg/composer/serviceparser"
3233
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
3334
"github.com/containerd/nerdctl/v2/pkg/testutil"

cmd/nerdctl/compose_up_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
"runtime"
2424
"testing"
2525

26-
"github.com/containerd/nerdctl/v2/pkg/testutil"
2726
"gotest.tools/v3/assert"
2827
"gotest.tools/v3/icmd"
28+
29+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2930
)
3031

3132
// https://github.com/containerd/nerdctl/issues/1942

cmd/nerdctl/compose_version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import (
2020
"fmt"
2121
"strings"
2222

23-
"github.com/containerd/nerdctl/v2/pkg/version"
2423
"github.com/spf13/cobra"
24+
25+
"github.com/containerd/nerdctl/v2/pkg/version"
2526
)
2627

2728
func newComposeVersionCommand() *cobra.Command {

cmd/nerdctl/container_attach.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
package main
1818

1919
import (
20+
"github.com/spf13/cobra"
21+
2022
containerd "github.com/containerd/containerd/v2/client"
23+
2124
"github.com/containerd/nerdctl/v2/pkg/api/types"
2225
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2326
"github.com/containerd/nerdctl/v2/pkg/cmd/container"
2427
"github.com/containerd/nerdctl/v2/pkg/consoleutil"
25-
"github.com/spf13/cobra"
2628
)
2729

2830
func newAttachCommand() *cobra.Command {

cmd/nerdctl/container_attach_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import (
2121
"strings"
2222
"testing"
2323

24-
"github.com/containerd/nerdctl/v2/pkg/testutil"
2524
"gotest.tools/v3/assert"
25+
26+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2627
)
2728

2829
// skipAttachForDocker should be called by attach-related tests that assert 'read detach keys' in stdout.

cmd/nerdctl/container_cp_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ import (
2424
"syscall"
2525
"testing"
2626

27+
"gotest.tools/v3/assert"
28+
2729
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
2830
"github.com/containerd/nerdctl/v2/pkg/testutil"
29-
"gotest.tools/v3/assert"
3031
)
3132

3233
func TestCopyToContainer(t *testing.T) {

cmd/nerdctl/container_create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import (
2020
"fmt"
2121
"runtime"
2222

23+
"github.com/spf13/cobra"
24+
2325
"github.com/containerd/nerdctl/v2/pkg/api/types"
2426
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2527
"github.com/containerd/nerdctl/v2/pkg/cmd/container"
2628
"github.com/containerd/nerdctl/v2/pkg/containerutil"
27-
"github.com/spf13/cobra"
2829
)
2930

3031
func newCreateCommand() *cobra.Command {

cmd/nerdctl/container_create_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import (
2222
"strings"
2323
"testing"
2424

25+
"gotest.tools/v3/assert"
26+
2527
"github.com/containerd/nerdctl/v2/pkg/testutil"
2628
"github.com/containerd/nerdctl/v2/pkg/testutil/nettestutil"
27-
"gotest.tools/v3/assert"
2829
)
2930

3031
func TestCreate(t *testing.T) {

cmd/nerdctl/container_diff.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ import (
3131
"github.com/containerd/containerd/v2/core/mount"
3232
"github.com/containerd/continuity/fs"
3333
"github.com/containerd/log"
34+
"github.com/containerd/platforms"
35+
3436
"github.com/containerd/nerdctl/v2/pkg/api/types"
3537
"github.com/containerd/nerdctl/v2/pkg/clientutil"
3638
"github.com/containerd/nerdctl/v2/pkg/idgen"
3739
"github.com/containerd/nerdctl/v2/pkg/idutil/containerwalker"
3840
"github.com/containerd/nerdctl/v2/pkg/imgutil"
3941
"github.com/containerd/nerdctl/v2/pkg/labels"
40-
"github.com/containerd/platforms"
4142
)
4243

4344
func newDiffCommand() *cobra.Command {

cmd/nerdctl/container_exec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/spf13/cobra"
2323

2424
containerd "github.com/containerd/containerd/v2/client"
25+
2526
"github.com/containerd/nerdctl/v2/pkg/api/types"
2627
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2728
"github.com/containerd/nerdctl/v2/pkg/cmd/container"

cmd/nerdctl/container_inspect_windows_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ package main
1919
import (
2020
"testing"
2121

22-
"github.com/containerd/nerdctl/v2/pkg/testutil"
2322
"gotest.tools/v3/assert"
23+
24+
"github.com/containerd/nerdctl/v2/pkg/testutil"
2425
)
2526

2627
func TestInspectProcessContainerContainsLabel(t *testing.T) {

cmd/nerdctl/container_kill.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
package main
1818

1919
import (
20+
"github.com/spf13/cobra"
21+
2022
containerd "github.com/containerd/containerd/v2/client"
23+
2124
"github.com/containerd/nerdctl/v2/pkg/api/types"
2225
"github.com/containerd/nerdctl/v2/pkg/clientutil"
2326
"github.com/containerd/nerdctl/v2/pkg/cmd/container"
24-
"github.com/spf13/cobra"
2527
)
2628

2729
func newKillCommand() *cobra.Command {

cmd/nerdctl/container_kill_linux_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ import (
2121
"strings"
2222
"testing"
2323

24+
"github.com/coreos/go-iptables/iptables"
25+
"gotest.tools/v3/assert"
26+
2427
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
2528
"github.com/containerd/nerdctl/v2/pkg/testutil"
2629
iptablesutil "github.com/containerd/nerdctl/v2/pkg/testutil/iptables"
27-
"github.com/coreos/go-iptables/iptables"
28-
"gotest.tools/v3/assert"
2930
)
3031

3132
// TestKillCleanupForwards runs a container that exposes a port and then kill it.

cmd/nerdctl/container_list_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ import (
2424
"strings"
2525
"testing"
2626

27+
"gotest.tools/v3/assert"
28+
2729
"github.com/containerd/nerdctl/v2/pkg/formatter"
2830
"github.com/containerd/nerdctl/v2/pkg/strutil"
2931
"github.com/containerd/nerdctl/v2/pkg/tabutil"
3032
"github.com/containerd/nerdctl/v2/pkg/testutil"
31-
"gotest.tools/v3/assert"
3233
)
3334

3435
type psTestContainer struct {

0 commit comments

Comments
 (0)