55 "os"
66 "path/filepath"
77 "strings"
8+ "time"
89
910 "io"
10- "time"
1111
1212 "github.com/containernetworking/cni/libcni"
1313)
@@ -24,10 +24,7 @@ func (l *CNILoader) GetCNIConfig() *libcni.CNIConfig {
2424
2525func (l * CNILoader ) GetNetworkConfig () (* libcni.NetworkConfigList , error ) {
2626
27- var (
28- confFilePaths []string
29- confListFilePaths []string
30- )
27+ var confListFilePaths []string
3128
3229 err := filepath .Walk (l .ConfigDir , func (path string , info os.FileInfo , err error ) error {
3330 if err != nil {
@@ -38,17 +35,15 @@ func (l *CNILoader) GetNetworkConfig() (*libcni.NetworkConfigList, error) {
3835 return nil
3936 }
4037
41- if strings .HasSuffix (path , ".conf" ) {
42- confFilePaths = append (confFilePaths , path )
43- } else if strings .HasSuffix (path , ".conflist" ) {
38+ if strings .HasSuffix (path , ".conflist" ) {
4439 confListFilePaths = append (confListFilePaths , path )
4540 }
4641
4742 return nil
4843 })
4944
5045 if err != nil {
51- return nil , fmt .Errorf ("error loading config: %s" , err )
46+ return nil , fmt .Errorf ("error walking config directory : %s" , err )
5247 }
5348
5449 var toReturn * libcni.NetworkConfigList
@@ -60,28 +55,11 @@ func (l *CNILoader) GetNetworkConfig() (*libcni.NetworkConfigList, error) {
6055 return confList , fmt .Errorf ("unable to load config from %s: %s" , path , err )
6156 }
6257
63- toReturn = confList
64- } else if len (confFilePaths ) > 0 {
65- path := confFilePaths [0 ]
66- //lint:ignore SA1019 - we will address this, but would like to keep units passing
67- conf , err := libcni .ConfFromFile (path )
68- if err != nil {
69- return nil , fmt .Errorf ("unable to load config from %s: %s" , path , err )
70- }
71-
72- //lint:ignore SA1019 - we will address this, but would like to keep units passing
73- confList , err := libcni .ConfListFromConf (conf )
74- if err != nil {
75- // untested, unable to cause failure case.
76- return nil , fmt .Errorf ("unable to upconvert from conf to conf list %s: %s" , path , err )
77- }
78-
7958 toReturn = confList
8059 }
8160
82- if (len (confListFilePaths ) + len (confFilePaths )) > 1 {
83- fmt .Fprintf (l .Logger , `%s - Only one CNI config file or conflist (chain) will be executed.
84- If a conf and conflist file are both present, then the conflist will be executed.
61+ if len (confListFilePaths ) > 1 {
62+ fmt .Fprintf (l .Logger , `%s - Only one CNI conflist (chain) will be executed.
8563 If multiple CNI config files are present, behavior is undefined.` , time .Now ().Format (time .RFC3339 ))
8664 }
8765
0 commit comments