- `CNI_NETNS`: Path to network namespace file
- `CNI_IFNAME`: Interface name to set up; plugin must honor this interface name or return an error
- `CNI_ARGS`: Extra arguments passed in by the user at invocation time. Alphanumeric key-value pairs separated by semicolons; for example, "FOO=BAR;ABC=123"
-- `CNI_PATH`: Colon-separated list of paths to search for CNI plugin executables
+- `CNI_PATH`: List of paths to search for CNI plugin executables. Paths are separated by an OS-specific list separator; for example ':' on Linux and ';' on Windows
Network configuration in JSON format is streamed to the plugin through stdin. This means it is not tied to a particular file on disk and can contain information which changes between invocations.
"fmt"
"os"
"path/filepath"
- "strings"
"github.com/containernetworking/cni/libcni"
)
netns := os.Args[3]
cninet := &libcni.CNIConfig{
- Path: strings.Split(os.Getenv(EnvCNIPath), ":"),
+ Path: filepath.SplitList(os.Getenv(EnvCNIPath)),
}
rt := &libcni.RuntimeConf{
package libcni
import (
+ "os"
"strings"
"github.com/containernetworking/cni/pkg/invoke"
NetNS: rt.NetNS,
PluginArgs: rt.Args,
IfName: rt.IfName,
- Path: strings.Join(c.Path, ":"),
+ Path: strings.Join(c.Path, string(os.PathListSeparator)),
}
}
import (
"fmt"
"os"
- "strings"
+ "path/filepath"
"github.com/containernetworking/cni/pkg/types"
)
return nil, fmt.Errorf("CNI_COMMAND is not ADD")
}
- paths := strings.Split(os.Getenv("CNI_PATH"), ":")
+ paths := filepath.SplitList(os.Getenv("CNI_PATH"))
pluginPath, err := FindInPath(delegatePlugin, paths)
if err != nil {
return fmt.Errorf("CNI_COMMAND is not DEL")
}
- paths := strings.Split(os.Getenv("CNI_PATH"), ":")
+ paths := filepath.SplitList(os.Getenv("CNI_PATH"))
pluginPath, err := FindInPath(delegatePlugin, paths)
if err != nil {