diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-06-15 09:19:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 09:19:40 -0400 |
commit | f4c3b718eb22a161a897a6ed55d10f3a07e31aa8 (patch) | |
tree | bb453d40a50f8cef1ebfedc73e43e2c7fe7d3456 /pkg/network/files.go | |
parent | e94e3fd2e829fd2cd38428aa9d9bf68b37bb8407 (diff) | |
parent | 200cfa41a434b7143620c2c252b3eb7ab3ef92f9 (diff) | |
download | podman-f4c3b718eb22a161a897a6ed55d10f3a07e31aa8.tar.gz podman-f4c3b718eb22a161a897a6ed55d10f3a07e31aa8.tar.bz2 podman-f4c3b718eb22a161a897a6ed55d10f3a07e31aa8.zip |
Merge pull request #6557 from rhatdan/lint
Turn on More linters
Diffstat (limited to 'pkg/network/files.go')
-rw-r--r-- | pkg/network/files.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pkg/network/files.go b/pkg/network/files.go index 81c0e1a28..beb3289f3 100644 --- a/pkg/network/files.go +++ b/pkg/network/files.go @@ -22,13 +22,13 @@ func GetCNIConfDir(config *config.Config) string { // 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) + configs := make([]*libcni.NetworkConfigList, 0, len(files)) for _, confFile := range files { conf, err := libcni.ConfListFromFile(confFile) if err != nil { @@ -72,7 +72,7 @@ func ReadRawCNIConfByName(config *config.Config, name string) ([]byte, error) { // GetCNIPlugins returns a list of plugins that a given network // has in the form of a string func GetCNIPlugins(list *libcni.NetworkConfigList) string { - var plugins []string + plugins := make([]string, 0, len(list.Plugins)) for _, plug := range list.Plugins { plugins = append(plugins, plug.Network.Type) } @@ -106,12 +106,11 @@ func GetNetworksFromFilesystem(config *config.Config) ([]*allocator.Net, error) // GetNetworkNamesFromFileSystem gets all the names from the cni network // configuration files func GetNetworkNamesFromFileSystem(config *config.Config) ([]string, error) { - var networkNames []string - networks, err := LoadCNIConfsFromDir(GetCNIConfDir(config)) if err != nil { return nil, err } + networkNames := []string{} for _, n := range networks { networkNames = append(networkNames, n.Name) } @@ -144,12 +143,12 @@ func GetInterfaceNameFromConfig(path string) (string, error) { // GetBridgeNamesFromFileSystem is a convenience function to get all the bridge // names from the configured networks func GetBridgeNamesFromFileSystem(config *config.Config) ([]string, error) { - var bridgeNames []string - networks, err := LoadCNIConfsFromDir(GetCNIConfDir(config)) if err != nil { return nil, err } + + bridgeNames := []string{} for _, n := range networks { var name string // iterate network conflists |