docs: enhance EvoBGP architecture plan with new risk mitigation strategies, testing matrix for BIRD2, and CI/CD workflow details. Updated section titles for clarity and added completed todos for deployment practices.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package birdfmt
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// RenderStaticIPv4Protocol renders a BIRD 2 `protocol static` block for IPv4 prefixes.
|
||||
// Prefixes are sorted for stable output (golden tests, reproducible rev).
|
||||
func RenderStaticIPv4Protocol(protocolName string, prefixes []netip.Prefix) string {
|
||||
if protocolName == "" {
|
||||
protocolName = "evobgp_static_v4"
|
||||
}
|
||||
uniq := make(map[string]netip.Prefix)
|
||||
for _, p := range prefixes {
|
||||
if !p.Addr().Is4() {
|
||||
continue
|
||||
}
|
||||
uniq[p.String()] = p.Masked()
|
||||
}
|
||||
keys := make([]string, 0, len(uniq))
|
||||
for k := range uniq {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
var b strings.Builder
|
||||
b.WriteString("protocol static ")
|
||||
b.WriteString(protocolName)
|
||||
b.WriteString(" {\n ipv4;\n")
|
||||
for _, k := range keys {
|
||||
b.WriteString(" route ")
|
||||
b.WriteString(k)
|
||||
b.WriteString(" unreachable;\n")
|
||||
}
|
||||
b.WriteString("}\n")
|
||||
return b.String()
|
||||
}
|
||||
Reference in New Issue
Block a user