mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-20 09:01:15 +00:00
Code refactoring and including conf dir in the CNI Conf file option
Change-Id: I2b35377356f2144fd3889bf5de7ac430a19edf89 Co-authored-by: Doug Smith <dougbtv@users.noreply.github.com> Co-authored-by: Tomofumi Hayashi <s1061123@users.noreply.github.com> Co-authored-by: Dan Williams <dcbw@users.noreply.github.com>
This commit is contained in:
committed by
Kuralamudhan Ramakrishnan
parent
f0794119ba
commit
fd79ef6505
@@ -34,7 +34,10 @@ import (
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
const defaultCNIDir = "/var/lib/cni/multus"
|
||||
const (
|
||||
defaultCNIDir = "/var/lib/cni/multus"
|
||||
defaultConfDir = "/etc/cni/multus/net.d"
|
||||
)
|
||||
|
||||
var masterpluginEnabled bool
|
||||
var defaultcninetwork bool
|
||||
@@ -64,6 +67,10 @@ func loadNetConf(bytes []byte) (*types.NetConf, error) {
|
||||
netconf.CNIDir = defaultCNIDir
|
||||
}
|
||||
|
||||
if netconf.ConfDir == "" {
|
||||
netconf.ConfDir = defaultConfDir
|
||||
}
|
||||
|
||||
if netconf.UseDefault {
|
||||
if netconf.Kubeconfig == "" || !defaultcninetwork {
|
||||
return nil, fmt.Errorf(`If you have set always_use_default, you must also set the delegates & the kubeconfig, refer to the README`)
|
||||
@@ -283,7 +290,7 @@ func cmdAdd(args *skel.CmdArgs) error {
|
||||
}
|
||||
|
||||
if n.Kubeconfig != "" {
|
||||
podDelegate, err := k8s.GetK8sNetwork(args, n.Kubeconfig)
|
||||
podDelegate, err := k8s.GetK8sNetwork(args, n.Kubeconfig, n.ConfDir)
|
||||
if err != nil {
|
||||
if _, ok := err.(*k8s.NoK8sNetworkError); ok {
|
||||
nopodnet = true
|
||||
@@ -362,7 +369,7 @@ func cmdDel(args *skel.CmdArgs) error {
|
||||
}
|
||||
|
||||
if in.Kubeconfig != "" {
|
||||
podDelegate, r := k8s.GetK8sNetwork(args, in.Kubeconfig)
|
||||
podDelegate, r := k8s.GetK8sNetwork(args, in.Kubeconfig, in.ConfDir)
|
||||
if r != nil {
|
||||
if _, ok := r.(*k8s.NoK8sNetworkError); ok {
|
||||
nopodnet = true
|
||||
|
Reference in New Issue
Block a user