Skip to content
Open
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
11 changes: 8 additions & 3 deletions pkg/netutil/cni_plugin_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package netutil

type natConfig struct {
PluginType string `json:"type"`
Master string `json:"master,omitempty"`
IPAM map[string]interface{} `json:"ipam"`
PluginType string `json:"type"`
Master string `json:"master,omitempty"`
IPAM map[string]interface{} `json:"ipam"`
Capabilities map[string]bool `json:"capabilities,omitempty"`
}

func (*natConfig) GetPluginType() string {
Expand All @@ -30,6 +31,10 @@ func newNatPlugin(master string) *natConfig {
return &natConfig{
PluginType: "nat",
Master: master,
Capabilities: map[string]bool{
"portMappings": true,
"dns": true,
},
}
}

Expand Down
18 changes: 17 additions & 1 deletion pkg/netutil/netutil_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,26 @@

package netutil

import "testing"
import (
"testing"

"gotest.tools/v3/assert"
)

// Tests whether nerdctl properly creates the default network when required.
// On Windows, the default driver used will be "nat". (netutil.DefaultNetworkName)
func TestDefaultNetworkCreation(t *testing.T) {
testDefaultNetworkCreation(t)
}

func TestGenerateCNIPluginsNatCapabilities(t *testing.T) {
e := &CNIEnv{}
plugins, err := e.generateCNIPlugins("nat", "nat", nil, nil, false, false)
assert.NilError(t, err)
assert.Assert(t, len(plugins) == 1)
nat, ok := plugins[0].(*natConfig)
assert.Assert(t, ok)
assert.Assert(t, nat.Capabilities != nil)
assert.Assert(t, nat.Capabilities["portMappings"])
assert.Assert(t, nat.Capabilities["dns"])
}
Loading