feat: enhance evobgp with new command-line tools for bundle management, including pull, verify, and apply functionalities. Update go.mod to include necessary dependencies and complete todos in architecture plan for improved observability and deployment practices.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package birdfmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ManagedBanner returns a comment block marking EvoBGP-generated files (optional first line in bird.d/*.conf).
|
||||
func ManagedBanner(revisionHint string) string {
|
||||
rev := strings.TrimSpace(revisionHint)
|
||||
var b strings.Builder
|
||||
b.WriteString("# EvoBGP generated — do not edit by hand.\n")
|
||||
if rev != "" {
|
||||
b.WriteString("# Revision: ")
|
||||
b.WriteString(rev)
|
||||
b.WriteByte('\n')
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// JoinFragments concatenates non-empty text blocks with a blank line between them.
|
||||
func JoinFragments(parts ...string) string {
|
||||
var out []string
|
||||
for _, p := range parts {
|
||||
p = strings.TrimSpace(p)
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
out = append(out, p)
|
||||
}
|
||||
if len(out) == 0 {
|
||||
return ""
|
||||
}
|
||||
return strings.Join(out, "\n\n") + "\n"
|
||||
}
|
||||
|
||||
// ValidateIncludePath rejects paths that could break out of the config directory.
|
||||
func ValidateIncludePath(p string) error {
|
||||
p = strings.TrimSpace(p)
|
||||
if p == "" {
|
||||
return fmt.Errorf("birdfmt: include path is empty")
|
||||
}
|
||||
if strings.Contains(p, "..") {
|
||||
return fmt.Errorf("birdfmt: include path must not contain '..': %q", p)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user