Skip to content

Commit

Permalink
refactor(bird): extract runtime config function
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Jan 15, 2025
1 parent 33cca29 commit eb2e9f1
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions pkg/bird/bird.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ func MoveCacheAndReconfigure(birdDirectory string, cacheDirectory string, birdSo
for _, f := range birdConfigFiles {
log.Debugf("Removing old BIRD config file %s", f)
if err := os.Remove(f); err != nil {
log.Fatalf("Removing old BIRD config files: %v", err)
log.Fatalf("Unable to remove old BIRD config files: %v", err)
}
}

// Copy from cache to bird config
// Copy from cache dir to bird config dir
files, err := filepath.Glob(path.Join(cacheDirectory, "*.conf"))
if err != nil {
log.Fatal(err)
Expand All @@ -275,15 +275,20 @@ func MoveCacheAndReconfigure(birdDirectory string, cacheDirectory string, birdSo
}

if !noConfigure {
log.Info("Reconfiguring BIRD")
resp, _, err := RunCommand("configure", birdSocket)
if err != nil {
log.Fatal(err)
}
// Print bird output as multiple lines
for _, line := range strings.Split(strings.Trim(resp, "\n"), "\n") {
log.Infof("BIRD response (multiline): %s", line)
}
Configure(birdSocket)
}
}

// Configure applies a runtime BIRD configuration
func Configure(birdSocket string) {
log.Info("Reconfiguring BIRD")
resp, _, err := RunCommand("configure", birdSocket)
if err != nil {
log.Fatalf("BIRD configure error: %v", err)
}
// Print bird output as multiple lines
for _, line := range strings.Split(strings.Trim(resp, "\n"), "\n") {
log.Infof("BIRD response (multiline): %s", line)
}
}

Expand Down

0 comments on commit eb2e9f1

Please sign in to comment.