mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
add networkd test apply logic
This commit is contained in:
parent
8cecb05739
commit
5db16b37e1
1 changed files with 33 additions and 0 deletions
33
internal/networkd/apply.go
Normal file
33
internal/networkd/apply.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package networkd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"nfsense.net/nfsense/internal/definitions"
|
||||
)
|
||||
|
||||
func ApplyNetworkdConfiguration(currentConfig definitions.Config, pendingConfig definitions.Config) error {
|
||||
files, err := GenerateNetworkdConfiguration(pendingConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Generating Networkd Configuration: %w", err)
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
f, err := os.Create("out/" + file.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating File: %w", err)
|
||||
}
|
||||
|
||||
_, err = f.WriteString(file.Content + "\n")
|
||||
if err != nil {
|
||||
return fmt.Errorf("writing File: %w", err)
|
||||
}
|
||||
|
||||
err = f.Sync()
|
||||
if err != nil {
|
||||
return fmt.Errorf("syncing File: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Reference in a new issue