started with structure

This commit is contained in:
Matthias Hannig 2018-09-06 18:04:27 +02:00
parent efe2dfcb45
commit 0932fc0e36
2 changed files with 28 additions and 0 deletions

View File

@ -138,5 +138,32 @@ func (self NgBgpCommunities) Lookup(community string) (string, error) {
}
func (self NgBgpCommunities) Set(community string, label string) {
path := strings.Split(community, ":")
var lookup interface{} // This is all much too dynamic...
lookup = self
for _, key := range path {
clookup, ok := lookup.(NgBgpCommunities)
if !ok {
break
}
res, ok := clookup[key]
if !ok {
// Try to fall back to wildcard key
res, ok = clookup["*"]
if !ok {
break // we did everything we could.
}
}
lookup = res
}
label, ok := lookup.(string)
if !ok {
return "", fmt.Errorf("community not found")
}
return label, nil
}

View File

@ -12,3 +12,4 @@
background-color: #ddd;
}