mirror of
https://github.com/containers/podman.git
synced 2026-03-20 07:37:11 -04:00
adding podman network and the subcommands inspect, list, and rm. the inspect subcommand displays the raw cni network configuration. the list subcommand displays a summary of the cni networks ala ps. and the rm subcommand removes a cni network. Signed-off-by: baude <bbaude@redhat.com>
27 lines
571 B
Go
27 lines
571 B
Go
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
|
|
}
|