Skip to content

cniNetworkManager: move Windows-specific variable to _windows.go #2725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/containerutil/container_network_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/netns"
"github.com/containerd/nerdctl/pkg/api/types"
"github.com/containerd/nerdctl/pkg/clientutil"
"github.com/containerd/nerdctl/pkg/dnsutil/hostsstore"
Expand Down Expand Up @@ -128,7 +127,7 @@ func NewNetworkingOptionsManager(globalOptions types.GlobalCommandOptions, netOp
case nettype.Container:
manager = &containerNetworkManager{globalOptions, netOpts, client}
case nettype.CNI:
manager = &cniNetworkManager{globalOptions, netOpts, nil, client}
manager = &cniNetworkManager{globalOptions, netOpts, client, cniNetworkManagerPlatform{}}
default:
return nil, fmt.Errorf("unexpected container networking type: %q", netType)
}
Expand Down Expand Up @@ -471,8 +470,8 @@ func (m *hostNetworkManager) ContainerNetworkingOpts(_ context.Context, containe
type cniNetworkManager struct {
globalOptions types.GlobalCommandOptions
netOpts types.NetworkOptions
netNs *netns.NetNS
client *containerd.Client
cniNetworkManagerPlatform
}

// NetworkOptions Returns a copy of the internal types.NetworkOptions.
Expand Down
3 changes: 3 additions & 0 deletions pkg/containerutil/container_network_manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import (
"github.com/containerd/nerdctl/pkg/rootlessutil"
)

type cniNetworkManagerPlatform struct {
}

// Verifies that the internal network settings are correct.
func (m *cniNetworkManager) VerifyNetworkOptions(_ context.Context) error {
e, err := netutil.NewCNIEnv(m.globalOptions.CNIPath, m.globalOptions.CNINetConfPath, netutil.WithDefaultNetwork())
Expand Down
3 changes: 3 additions & 0 deletions pkg/containerutil/container_network_manager_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (
"github.com/containerd/nerdctl/pkg/api/types"
)

type cniNetworkManagerPlatform struct {
}

// Verifies that the internal network settings are correct.
func (m *cniNetworkManager) VerifyNetworkOptions(_ context.Context) error {
return fmt.Errorf("CNI networking currently unsupported on %s", runtime.GOOS)
Expand Down
4 changes: 4 additions & 0 deletions pkg/containerutil/container_network_manager_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import (
"github.com/containerd/nerdctl/pkg/ocihook"
)

type cniNetworkManagerPlatform struct {
netNs *netns.NetNS
}

// Verifies that the internal network settings are correct.
func (m *cniNetworkManager) VerifyNetworkOptions(_ context.Context) error {
e, err := netutil.NewCNIEnv(m.globalOptions.CNIPath, m.globalOptions.CNINetConfPath, netutil.WithDefaultNetwork())
Expand Down