Don't add loopback CNI configuration on Windows

There's no Loopback CNI plugin for Windows as far as I can see, so I'm
assuming it's not needed.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
v0.8
Paul "TBBle" Hampson 2020-07-20 23:28:57 +10:00
parent 1fedff0e4b
commit 50c5d4ce51
1 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package cniprovider
import ( import (
"context" "context"
"os" "os"
"runtime"
cni "github.com/containerd/go-cni" cni "github.com/containerd/go-cni"
"github.com/gofrs/flock" "github.com/gofrs/flock"
@ -26,12 +27,17 @@ func New(opt Opt) (network.Provider, error) {
return nil, errors.Wrapf(err, "failed to read cni binary dir %q", opt.BinaryDir) return nil, errors.Wrapf(err, "failed to read cni binary dir %q", opt.BinaryDir)
} }
cniHandle, err := cni.New( cniOptions := []cni.CNIOpt{cni.WithPluginDir([]string{opt.BinaryDir}), cni.WithInterfacePrefix("eth")}
cni.WithMinNetworkCount(2),
cni.WithPluginDir([]string{opt.BinaryDir}), // Windows doesn't use CNI for loopback.
cni.WithInterfacePrefix(("eth")), if runtime.GOOS != "windows" {
cni.WithLoNetwork, cniOptions = append([]cni.CNIOpt{cni.WithMinNetworkCount(2)}, cniOptions...)
cni.WithConfFile(opt.ConfigPath)) cniOptions = append(cniOptions, cni.WithLoNetwork)
}
cniOptions = append(cniOptions, cni.WithConfFile(opt.ConfigPath))
cniHandle, err := cni.New(cniOptions...)
if err != nil { if err != nil {
return nil, err return nil, err
} }