Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
style: fix staticcheck style warnings
rcourtmanad998a1e2fb1
diff --git a/internal/alerts/alerts.go b/internal/alerts/alerts.goindex 1ddac41ba4..54514d4388 100644--- a/internal/alerts/alerts.go+++ b/internal/alerts/alerts.go@@ -8375,10 +8375,9 @@ func (m *Manager) LoadActiveAlerts() error {// We can detect this if we have Node field and it appears in the ResourceIDif alert.Node != "" && len(parts) >= 2 {var newResourceID string- var vmidStr string// Try to extract VMID (should be last part)- vmidStr = parts[len(parts)-1]+ vmidStr := parts[len(parts)-1]if _, err := strconv.Atoi(vmidStr); err == nil {// VMID is valid, now check if we need to migrateif len(parts) == 3 && alert.Instance != "" && alert.Instance != alert.Node {diff --git a/internal/api/config_handlers.go b/internal/api/config_handlers.goindex 0d67217a07..91548a13e6 100644--- a/internal/api/config_handlers.go+++ b/internal/api/config_handlers.go@@ -1576,13 +1576,7 @@ func (h *ConfigHandlers) HandleTestConnection(w http.ResponseWriter, r *http.Req// Auto-generate name if not provided for testif req.Name == "" {// Extract hostname from URL- host := req.Host- if strings.HasPrefix(host, "http://") {- host = strings.TrimPrefix(host, "http://")- }- if strings.HasPrefix(host, "https://") {- host = strings.TrimPrefix(host, "https://")- }+ host := strings.TrimPrefix(strings.TrimPrefix(req.Host, "http://"), "https://")// Remove portif colonIndex := strings.Index(host, ":"); colonIndex != -1 {host = host[:colonIndex]@@ -2550,7 +2544,7 @@ func (h *ConfigHandlers) HandleTestNodeConfig(w http.ResponseWriter, r *http.Reqlatency := time.Since(startTime).Milliseconds()testResult = map[string]interface{}{"status": "success",- "message": fmt.Sprintf("Connected to PBS instance"),+ "message": "Connected to PBS instance","latency": latency,}}diff --git a/internal/config/docker_metadata.go b/internal/config/docker_metadata.goindex 0fe2e969f9..a482c0eb93 100644--- a/internal/config/docker_metadata.go+++ b/internal/config/docker_metadata.go@@ -151,20 +151,18 @@ func (s *DockerMetadataStore) ReplaceAll(metadata map[string]*DockerMetadata) ers.metadata = make(map[string]*DockerMetadata)- if metadata != nil {- for resourceID, meta := range metadata {- if meta == nil {- continue- }-- clone := *meta- clone.ID = resourceID- // Ensure slice copy is not nil to allow JSON marshalling of empty tags- if clone.Tags == nil {- clone.Tags = []string{}- }- s.metadata[resourceID] = &clone+ for resourceID, meta := range metadata {+ if meta == nil {+ continue}++ clone := *meta+ clone.ID = resourceID+ // Ensure slice copy is not nil to allow JSON marshalling of empty tags+ if clone.Tags == nil {+ clone.Tags = []string{}+ }+ s.metadata[resourceID] = &clone}return s.save()diff --git a/internal/config/guest_metadata.go b/internal/config/guest_metadata.goindex 56047cd7aa..9af934f334 100644--- a/internal/config/guest_metadata.go+++ b/internal/config/guest_metadata.go@@ -180,20 +180,18 @@ func (s *GuestMetadataStore) ReplaceAll(metadata map[string]*GuestMetadata) erros.metadata = make(map[string]*GuestMetadata)- if metadata != nil {- for guestID, meta := range metadata {- if meta == nil {- continue- }-- clone := *meta- clone.ID = guestID- // Ensure slice copy is not nil to allow JSON marshalling of empty tags- if clone.Tags == nil {- clone.Tags = []string{}- }- s.metadata[guestID] = &clone+ for guestID, meta := range metadata {+ if meta == nil {+ continue}++ clone := *meta+ clone.ID = guestID+ // Ensure slice copy is not nil to allow JSON marshalling of empty tags+ if clone.Tags == nil {+ clone.Tags = []string{}+ }+ s.metadata[guestID] = &clone}return s.save()diff --git a/internal/monitoring/metrics.go b/internal/monitoring/metrics.goindex 03dafef6c9..6a623120fb 100644--- a/internal/monitoring/metrics.go+++ b/internal/monitoring/metrics.go@@ -409,7 +409,7 @@ func (pm *PollMetrics) SetBreakerState(instanceType, instance, state string, fairetrySeconds := 0.0if !retryAt.IsZero() {- retrySeconds = retryAt.Sub(time.Now()).Seconds()+ retrySeconds = time.Until(retryAt).Seconds()if retrySeconds < 0 {retrySeconds = 0}diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.goindex 9ceedf6515..87b8b5be1d 100644--- a/internal/notifications/notifications.go+++ b/internal/notifications/notifications.go@@ -2241,7 +2241,7 @@ func (n *NotificationManager) generatePayloadFromTemplateWithService(templateStrif err := json.Unmarshal(buf.Bytes(), &jsonCheck); err != nil {log.Error().Err(err).- Str("payload", string(buf.Bytes())).+ Str("payload", buf.String()).Msg("Generated webhook payload is invalid JSON")return nil, fmt.Errorf("template produced invalid JSON: %w", err)}diff --git a/pkg/discovery/discovery.go b/pkg/discovery/discovery.goindex 6e3a5be46f..93fe00877e 100644--- a/pkg/discovery/discovery.go+++ b/pkg/discovery/discovery.go@@ -285,7 +285,7 @@ func (s *Scanner) DiscoverServersWithCallbacks(ctx context.Context, subnet strin} else if errors.Is(err, context.DeadlineExceeded) {errType = "timeout"// Provide user-friendly timeout message- errMsg = fmt.Sprintf("Scan timed out after 2 minutes - this is normal for large networks. Servers found in earlier phases are still available.")+ errMsg = "Scan timed out after 2 minutes - this is normal for large networks. Servers found in earlier phases are still available."}result.AddError("extra_targets", errType, errMsg, "", 0)if errors.Is(err, context.Canceled) {@@ -333,7 +333,7 @@ func (s *Scanner) DiscoverServersWithCallbacks(ctx context.Context, subnet strin} else if errors.Is(err, context.DeadlineExceeded) {errType = "timeout"// Provide user-friendly timeout message- errMsg = fmt.Sprintf("Scan timed out after 2 minutes - this is normal for large networks. Servers found in earlier phases are still available.")+ errMsg = "Scan timed out after 2 minutes - this is normal for large networks. Servers found in earlier phases are still available."}result.AddError(phase.Name, errType, errMsg, "", 0)if errors.Is(err, context.Canceled) {@@ -781,9 +781,7 @@ func clonePhase(phase envdetect.SubnetPhase) envdetect.SubnetPhase {cloned := phaseif phase.Subnets != nil {cloned.Subnets = make([]net.IPNet, len(phase.Subnets))- for i, subnet := range phase.Subnets {- cloned.Subnets[i] = subnet- }+ copy(cloned.Subnets, phase.Subnets)}return cloned}