diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-06-11 14:40:38 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-06-15 07:05:56 -0400 |
commit | 200cfa41a434b7143620c2c252b3eb7ab3ef92f9 (patch) | |
tree | ccf0cb95297dc65d4dc8bd366963e2b037fb1a8b /pkg/network/files.go | |
parent | 3f026eb6a682a68e69f9376b72157a8f084e575c (diff) | |
download | podman-200cfa41a434b7143620c2c252b3eb7ab3ef92f9.tar.gz podman-200cfa41a434b7143620c2c252b3eb7ab3ef92f9.tar.bz2 podman-200cfa41a434b7143620c2c252b3eb7ab3ef92f9.zip |
Turn on More linters
- misspell
- prealloc
- unparam
- nakedret
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
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 |