1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package main
import (
"fmt"
"strings"
liblxc "gopkg.in/lxc/go-lxc.v2"
)
func networkGet(container *liblxc.Container, index int, configKey string) map[string]string {
keys := container.ConfigKeys(fmt.Sprintf("%s.%d", configKey, index))
if len(keys) == 0 {
return nil
}
dev := make(map[string]string)
for _, k := range keys {
value := container.ConfigItem(fmt.Sprintf("%s.%d.%s", configKey, index, k))
if len(value) == 0 || strings.TrimSpace(value[0]) == "" {
continue
}
dev[k] = value[0]
}
if len(dev) == 0 {
return nil
}
return dev
}
|