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 (
"context"
"os"
"runtime"
cni "github.com/containerd/go-cni"
"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)
}
cniHandle, err := cni.New(
cni.WithMinNetworkCount(2),
cni.WithPluginDir([]string{opt.BinaryDir}),
cni.WithInterfacePrefix(("eth")),
cni.WithLoNetwork,
cni.WithConfFile(opt.ConfigPath))
cniOptions := []cni.CNIOpt{cni.WithPluginDir([]string{opt.BinaryDir}), cni.WithInterfacePrefix("eth")}
// Windows doesn't use CNI for loopback.
if runtime.GOOS != "windows" {
cniOptions = append([]cni.CNIOpt{cni.WithMinNetworkCount(2)}, cniOptions...)
cniOptions = append(cniOptions, cni.WithLoNetwork)
}
cniOptions = append(cniOptions, cni.WithConfFile(opt.ConfigPath))
cniHandle, err := cni.New(cniOptions...)
if err != nil {
return nil, err
}