mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-06 14:56:30 +08:00
Merge pull request #656 from gravitl/bugfix_v0.10.0_get_system_networks
Bugfix v0.10.0 get system networks
This commit is contained in:
commit
a4582dd14d
1 changed files with 7 additions and 5 deletions
|
|
@ -450,19 +450,21 @@ func PrintLog(message string, loglevel int) {
|
|||
|
||||
// GetSystemNetworks - get networks locally
|
||||
func GetSystemNetworks() ([]string, error) {
|
||||
var networks []string
|
||||
files, err := filepath.Glob(GetNetclientPathSpecific() + "netconfig-*")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
i := 0
|
||||
for _, file := range files {
|
||||
//don't want files such as *.bak, *.swp
|
||||
if filepath.Ext(file) == "" {
|
||||
files[i] = filepath.Base(file)
|
||||
i++
|
||||
if filepath.Ext(file) != "" {
|
||||
continue
|
||||
}
|
||||
file := filepath.Base(file)
|
||||
temp := strings.Split(file, "-")
|
||||
networks = append(networks, temp[1])
|
||||
}
|
||||
return files[:i], nil
|
||||
return networks, nil
|
||||
}
|
||||
|
||||
func stringAfter(original string, substring string) string {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue