Skip to content

Commit 03f0862

Browse files
authored
Merge pull request #3728 from apostasie/chore-import-cleanup
Chore: import cleanup
2 parents a5ab79c + f914ea3 commit 03f0862

File tree

19 files changed

+110
-110
lines changed

19 files changed

+110
-110
lines changed

cmd/nerdctl/compose/compose_ps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
containerd "github.com/containerd/containerd/v2/client"
3030
"github.com/containerd/containerd/v2/core/runtime/restart"
3131
"github.com/containerd/errdefs"
32-
gocni "github.com/containerd/go-cni"
32+
"github.com/containerd/go-cni"
3333
"github.com/containerd/log"
3434

3535
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
@@ -323,7 +323,7 @@ type PortPublisher struct {
323323
// formatPublishers parses and returns docker-compatible []PortPublisher from
324324
// label map. If an error happens, an empty slice is returned.
325325
func formatPublishers(labelMap map[string]string) []PortPublisher {
326-
mapper := func(pm gocni.PortMapping) PortPublisher {
326+
mapper := func(pm cni.PortMapping) PortPublisher {
327327
return PortPublisher{
328328
URL: pm.HostIP,
329329
TargetPort: int(pm.ContainerPort),

cmd/nerdctl/container/container_run_network.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
"github.com/spf13/cobra"
2323

24-
gocni "github.com/containerd/go-cni"
24+
"github.com/containerd/go-cni"
2525

2626
"github.com/containerd/nerdctl/v2/pkg/api/types"
2727
"github.com/containerd/nerdctl/v2/pkg/portutil"
@@ -144,7 +144,7 @@ func loadNetworkFlags(cmd *cobra.Command) (types.NetworkOptions, error) {
144144
return netOpts, err
145145
}
146146
portSlice = strutil.DedupeStrSlice(portSlice)
147-
portMappings := []gocni.PortMapping{}
147+
portMappings := []cni.PortMapping{}
148148
for _, p := range portSlice {
149149
pm, err := portutil.ParseFlagP(p)
150150
if err != nil {

pkg/api/types/container_network_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package types
1818

1919
import (
20-
gocni "github.com/containerd/go-cni"
20+
"github.com/containerd/go-cni"
2121
)
2222

2323
// NetworkOptions struct defining networking-related options.
@@ -43,5 +43,5 @@ type NetworkOptions struct {
4343
// UTS namespace to use
4444
UTSNamespace string
4545
// PortMappings specifies a list of ports to publish from the container to the host
46-
PortMappings []gocni.PortMapping
46+
PortMappings []cni.PortMapping
4747
}

pkg/bypass4netnsutil/bypass.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
rlkclient "github.com/rootless-containers/rootlesskit/v2/pkg/api/client"
2929

3030
"github.com/containerd/errdefs"
31-
gocni "github.com/containerd/go-cni"
31+
"github.com/containerd/go-cni"
3232

3333
"github.com/containerd/nerdctl/v2/pkg/annotations"
3434
)
@@ -66,7 +66,7 @@ type Bypass4netnsCNIBypassManager struct {
6666
ignoreBind bool
6767
}
6868

69-
func (b4nnm *Bypass4netnsCNIBypassManager) StartBypass(ctx context.Context, ports []gocni.PortMapping, id, stateDir string) error {
69+
func (b4nnm *Bypass4netnsCNIBypassManager) StartBypass(ctx context.Context, ports []cni.PortMapping, id, stateDir string) error {
7070
socketPath, err := GetSocketPathByID(id)
7171
if err != nil {
7272
return err

pkg/cmd/container/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"github.com/containerd/containerd/v2/core/containers"
3838
"github.com/containerd/containerd/v2/pkg/cio"
3939
"github.com/containerd/containerd/v2/pkg/oci"
40-
gocni "github.com/containerd/go-cni"
40+
"github.com/containerd/go-cni"
4141
"github.com/containerd/log"
4242

4343
"github.com/containerd/nerdctl/v2/pkg/annotations"
@@ -646,7 +646,7 @@ type internalLabels struct {
646646
networks []string
647647
ipAddress string
648648
ip6Address string
649-
ports []gocni.PortMapping
649+
ports []cni.PortMapping
650650
macAddress string
651651
// volume
652652
mountPoints []*mountutil.Processed

pkg/cmd/container/kill.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
containerd "github.com/containerd/containerd/v2/client"
3030
"github.com/containerd/containerd/v2/pkg/cio"
3131
"github.com/containerd/errdefs"
32-
gocni "github.com/containerd/go-cni"
32+
"github.com/containerd/go-cni"
3333
"github.com/containerd/log"
3434

3535
"github.com/containerd/nerdctl/v2/pkg/api/types"
@@ -131,8 +131,8 @@ func cleanupNetwork(ctx context.Context, container containerd.Container, globalO
131131
if portErr != nil {
132132
return fmt.Errorf("no oci spec: %q", portErr)
133133
}
134-
portMappings := []gocni.NamespaceOpts{
135-
gocni.WithCapabilityPortMap(ports),
134+
portMappings := []cni.NamespaceOpts{
135+
cni.WithCapabilityPortMap(ports),
136136
}
137137

138138
// retrieve info to get cni instance
@@ -158,26 +158,26 @@ func cleanupNetwork(ctx context.Context, container containerd.Container, globalO
158158
if err != nil {
159159
return err
160160
}
161-
cniOpts := []gocni.Opt{
162-
gocni.WithPluginDir([]string{globalOpts.CNIPath}),
161+
cniOpts := []cni.Opt{
162+
cni.WithPluginDir([]string{globalOpts.CNIPath}),
163163
}
164164
var netw *netutil.NetworkConfig
165165
for _, netstr := range networks {
166166
if netw, err = e.NetworkByNameOrID(netstr); err != nil {
167167
return err
168168
}
169-
cniOpts = append(cniOpts, gocni.WithConfListBytes(netw.Bytes))
169+
cniOpts = append(cniOpts, cni.WithConfListBytes(netw.Bytes))
170170
}
171-
cni, err := gocni.New(cniOpts...)
171+
cniObj, err := cni.New(cniOpts...)
172172
if err != nil {
173173
return err
174174
}
175175

176-
var namespaceOpts []gocni.NamespaceOpts
176+
var namespaceOpts []cni.NamespaceOpts
177177
namespaceOpts = append(namespaceOpts, portMappings...)
178178
namespace := spec.Annotations[labels.Namespace]
179179
fullID := namespace + "-" + container.ID()
180-
if err := cni.Remove(ctx, fullID, "", namespaceOpts...); err != nil {
180+
if err := cniObj.Remove(ctx, fullID, "", namespaceOpts...); err != nil {
181181
log.L.WithError(err).Errorf("failed to call cni.Remove")
182182
return err
183183
}

pkg/consoleutil/consoleutil_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package consoleutil
2020

2121
import (
22-
gocontext "context"
22+
"context"
2323
"os"
2424
"os/signal"
2525

@@ -31,7 +31,7 @@ import (
3131

3232
// HandleConsoleResize resizes the console.
3333
// From https://github.com/containerd/containerd/blob/v1.7.0-rc.2/cmd/ctr/commands/tasks/tasks_unix.go#L43-L68
34-
func HandleConsoleResize(ctx gocontext.Context, task resizer, con console.Console) error {
34+
func HandleConsoleResize(ctx context.Context, task resizer, con console.Console) error {
3535
// do an initial resize of the console
3636
size, err := con.Size()
3737
if err != nil {

pkg/consoleutil/consoleutil_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package consoleutil
1818

1919
import (
20-
gocontext "context"
20+
"context"
2121
"time"
2222

2323
"github.com/containerd/console"
@@ -26,7 +26,7 @@ import (
2626

2727
// HandleConsoleResize resizes the console.
2828
// From https://github.com/containerd/containerd/blob/v1.7.0-rc.2/cmd/ctr/commands/tasks/tasks_windows.go#L34-L61
29-
func HandleConsoleResize(ctx gocontext.Context, task resizer, con console.Console) error {
29+
func HandleConsoleResize(ctx context.Context, task resizer, con console.Console) error {
3030
// do an initial resize of the console
3131
size, err := con.Size()
3232
if err != nil {

pkg/containerutil/container_network_manager_windows.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
containerd "github.com/containerd/containerd/v2/client"
2424
"github.com/containerd/containerd/v2/pkg/netns"
2525
"github.com/containerd/containerd/v2/pkg/oci"
26-
gocni "github.com/containerd/go-cni"
26+
"github.com/containerd/go-cni"
2727

2828
"github.com/containerd/nerdctl/v2/pkg/api/types"
2929
"github.com/containerd/nerdctl/v2/pkg/netutil"
@@ -66,26 +66,26 @@ func (m *cniNetworkManager) VerifyNetworkOptions(_ context.Context) error {
6666
return nil
6767
}
6868

69-
func (m *cniNetworkManager) getCNI() (gocni.CNI, error) {
69+
func (m *cniNetworkManager) getCNI() (cni.CNI, error) {
7070
e, err := netutil.NewCNIEnv(m.globalOptions.CNIPath, m.globalOptions.CNINetConfPath, netutil.WithNamespace(m.globalOptions.Namespace), netutil.WithDefaultNetwork(m.globalOptions.BridgeIP))
7171
if err != nil {
7272
return nil, fmt.Errorf("failed to instantiate CNI env: %s", err)
7373
}
7474

75-
cniOpts := []gocni.Opt{
76-
gocni.WithPluginDir([]string{m.globalOptions.CNIPath}),
77-
gocni.WithPluginConfDir(m.globalOptions.CNINetConfPath),
75+
cniOpts := []cni.Opt{
76+
cni.WithPluginDir([]string{m.globalOptions.CNIPath}),
77+
cni.WithPluginConfDir(m.globalOptions.CNINetConfPath),
7878
}
7979

8080
if netMap, err := verifyNetworkTypes(e, m.netOpts.NetworkSlice, nil); err == nil {
8181
for _, netConf := range netMap {
82-
cniOpts = append(cniOpts, gocni.WithConfListBytes(netConf.Bytes))
82+
cniOpts = append(cniOpts, cni.WithConfListBytes(netConf.Bytes))
8383
}
8484
} else {
8585
return nil, err
8686
}
8787

88-
return gocni.New(cniOpts...)
88+
return cni.New(cniOpts...)
8989
}
9090

9191
// Performs setup actions required for the container with the given ID.
@@ -171,26 +171,26 @@ func (m *cniNetworkManager) setupNetNs() (*netns.NetNS, error) {
171171
return ns, err
172172
}
173173

174-
// Returns the []gocni.NamespaceOpts to be used for CNI setup/teardown.
175-
func (m *cniNetworkManager) getCNINamespaceOpts() []gocni.NamespaceOpts {
176-
opts := []gocni.NamespaceOpts{
177-
gocni.WithLabels(map[string]string{
174+
// Returns the []cni.NamespaceOpts to be used for CNI setup/teardown.
175+
func (m *cniNetworkManager) getCNINamespaceOpts() []cni.NamespaceOpts {
176+
opts := []cni.NamespaceOpts{
177+
cni.WithLabels(map[string]string{
178178
// allow loose CNI argument verification
179179
// FYI: https://github.com/containernetworking/cni/issues/560
180180
"IgnoreUnknown": "1",
181181
}),
182182
}
183183

184184
if m.netOpts.MACAddress != "" {
185-
opts = append(opts, gocni.WithArgs("MAC", m.netOpts.MACAddress))
185+
opts = append(opts, cni.WithArgs("MAC", m.netOpts.MACAddress))
186186
}
187187

188188
if m.netOpts.IPAddress != "" {
189-
opts = append(opts, gocni.WithArgs("IP", m.netOpts.IPAddress))
189+
opts = append(opts, cni.WithArgs("IP", m.netOpts.IPAddress))
190190
}
191191

192192
if m.netOpts.PortMappings != nil {
193-
opts = append(opts, gocni.WithCapabilityPortMap(m.netOpts.PortMappings))
193+
opts = append(opts, cni.WithCapabilityPortMap(m.netOpts.PortMappings))
194194
}
195195

196196
return opts

pkg/defaults/defaults_freebsd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package defaults
1818

1919
import (
20-
gocni "github.com/containerd/go-cni"
20+
"github.com/containerd/go-cni"
2121
)
2222

2323
const (
@@ -32,11 +32,11 @@ func DataRoot() string {
3232

3333
func CNIPath() string {
3434
// default: /opt/cni/bin
35-
return gocni.DefaultCNIDir
35+
return cni.DefaultCNIDir
3636
}
3737

3838
func CNINetConfPath() string {
39-
return gocni.DefaultNetDir
39+
return cni.DefaultNetDir
4040
}
4141

4242
func CNIRuntimeDir() string {

pkg/defaults/defaults_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"path/filepath"
2424

2525
"github.com/containerd/containerd/v2/plugins"
26-
gocni "github.com/containerd/go-cni"
26+
"github.com/containerd/go-cni"
2727
"github.com/containerd/log"
2828

2929
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
@@ -48,7 +48,7 @@ func DataRoot() string {
4848

4949
func CNIPath() string {
5050
candidates := []string{
51-
gocni.DefaultCNIDir, // /opt/cni/bin
51+
cni.DefaultCNIDir, // /opt/cni/bin
5252
"/usr/local/libexec/cni",
5353
"/usr/local/lib/cni",
5454
"/usr/libexec/cni", // Fedora
@@ -74,12 +74,12 @@ func CNIPath() string {
7474
}
7575

7676
// default: /opt/cni/bin
77-
return gocni.DefaultCNIDir
77+
return cni.DefaultCNIDir
7878
}
7979

8080
func CNINetConfPath() string {
8181
if !rootlessutil.IsRootless() {
82-
return gocni.DefaultNetDir
82+
return cni.DefaultNetDir
8383
}
8484
xch, err := rootlessutil.XDGConfigHome()
8585
if err != nil {

pkg/labels/labels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const (
5454
// Currently, the length of the slice must be 1.
5555
Networks = Prefix + "networks"
5656

57-
// Ports is a JSON-marshalled string of []gocni.PortMapping .
57+
// Ports is a JSON-marshalled string of []cni.PortMapping .
5858
Ports = Prefix + "ports"
5959

6060
// IPAddress is the static IP address of the container assigned by the user

0 commit comments

Comments
 (0)