diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-08-16 17:33:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-16 17:33:31 +0200 |
commit | 704cc582ac37fbbb7c8241a1cc09540f4976ed12 (patch) | |
tree | 57bb887e113b307a39865eb38d2b733e01c59f1c /pkg/network | |
parent | 2d47f1ae5425faa6800606092e997bd565dc3a1c (diff) | |
parent | 6220ef1488d3e135c332c265fdb6a3c7b240b561 (diff) | |
download | podman-704cc582ac37fbbb7c8241a1cc09540f4976ed12.tar.gz podman-704cc582ac37fbbb7c8241a1cc09540f4976ed12.tar.bz2 podman-704cc582ac37fbbb7c8241a1cc09540f4976ed12.zip |
Merge pull request #3719 from baude/networklist
inclusion of podman network
Diffstat (limited to 'pkg/network')
-rw-r--r-- | pkg/network/config.go | 4 | ||||
-rw-r--r-- | pkg/network/network.go | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/pkg/network/config.go b/pkg/network/config.go new file mode 100644 index 000000000..d282f66b6 --- /dev/null +++ b/pkg/network/config.go @@ -0,0 +1,4 @@ +package network + +// CNIConfigDir is the path where CNI config files exist +const CNIConfigDir = "/etc/cni/net.d" diff --git a/pkg/network/network.go b/pkg/network/network.go new file mode 100644 index 000000000..9d04340a3 --- /dev/null +++ b/pkg/network/network.go @@ -0,0 +1,26 @@ +package network + +import ( + "sort" + + "github.com/containernetworking/cni/libcni" +) + +// LoadCNIConfsFromDir loads all the CNI configurations from a dir +func LoadCNIConfsFromDir(dir string) ([]*libcni.NetworkConfigList, error) { + var configs []*libcni.NetworkConfigList + files, err := libcni.ConfFiles(dir, []string{".conflist"}) + if err != nil { + return nil, err + } + sort.Strings(files) + + for _, confFile := range files { + conf, err := libcni.ConfListFromFile(confFile) + if err != nil { + return nil, err + } + configs = append(configs, conf) + } + return configs, nil +} |