feat: improve ENV variable overrides, introduce Node struct, refactoring

This commit is contained in:
2025-05-20 11:04:23 +02:00
parent bfc82870c3
commit d0a478d172
12 changed files with 210 additions and 149 deletions

23
pkg/util/dbus.go Normal file
View File

@@ -0,0 +1,23 @@
package util
import (
"log"
"github.com/godbus/dbus/v5"
)
// WithConnection executes the given function with a D-Bus system connection
// and handles any connection errors
func WithConnection(fn func(*dbus.Conn) error) error {
conn, err := dbus.SystemBus()
if err != nil {
log.Printf("[ERROR] Failed to connect to system bus: %v", err)
return err
}
if err := fn(conn); err != nil {
log.Printf("[ERROR] Failed to execute D-Bus function: %s", err)
return err
}
conn.Close()
return nil
}