Skip to content

Commit

Permalink
fix: remove panic statements and return errors
Browse files Browse the repository at this point in the history
Signed-off-by: Bhoopesh <[email protected]>
  • Loading branch information
bhoopesh369 committed Sep 19, 2024
1 parent e543632 commit 3539961
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sztp-agent/pkg/dhcp/dbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
func GetBootstrapURLsViaNetworkManager() ([]string, error) {
conn, err := dbus.SystemBus()
if err != nil {
panic(fmt.Errorf("failed to connect to system bus: %v", err))
return nil, fmt.Errorf("failed to connect to system bus: %v", err)
}

// Get NetworkManager object
Expand All @@ -28,7 +28,7 @@ func GetBootstrapURLsViaNetworkManager() ([]string, error) {
var activeConnPaths []dbus.ObjectPath
err = nm.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.NetworkManager", "ActiveConnections").Store(&activeConnPaths)
if err != nil {
panic(fmt.Errorf("failed to get ActiveConnections property: %v", err))
return nil, fmt.Errorf("failed to get ActiveConnections property: %v", err)
}

log.Println("[INFO] active connection paths: ", activeConnPaths)
Expand Down
2 changes: 1 addition & 1 deletion sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (a *Agent) performBootstrapSequence() error {
urls := a.GetBootstrapURL()
log.Println("[INFO] Performing the Bootstrap Sequence on each URL")
for _, url := range urls {
urlCopy := url
urlCopy := url // found no other way to escape golangci-lint
err = a.doRequestBootstrapServerOnboardingInfo(&urlCopy)
if err != nil {
log.Println("[ERROR] ", err.Error())
Expand Down

0 comments on commit 3539961

Please sign in to comment.