Fix default case for CNIDir

In case of no-config for CNIDir, multus-cni does not set
defaultCNIDir into CNIDir hence multus-cni failed to create
container network. This change fixes it.
This commit is contained in:
Tomofumi Hayashi 2018-05-08 15:24:49 +09:00
parent a78a9241f4
commit 4eeb1fa43f

View File

@ -58,6 +58,10 @@ func loadNetConf(bytes []byte) (*types.NetConf, error) {
defaultcninetwork = true
}
if netconf.CNIDir == "" {
netconf.CNIDir = defaultCNIDir
}
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`)
@ -73,10 +77,6 @@ func loadNetConf(bytes []byte) (*types.NetConf, error) {
return nil, fmt.Errorf(`delegates or kubeconfig option is must, refer README.md`)
}
if netconf.CNIDir == "" {
netconf.CNIDir = defaultCNIDir
}
return netconf, nil
}