chore: apply linter auto-fixes (wsl_v5, nlreturn, tagalign) (#984)

golangci-lint auto-fixes across multiple packages:
- wsl_v5: blank lines between logical blocks
- nlreturn: newlines before return statements
- tagalign: struct field tag alignment

No logic changes.

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cody Lee
2026-03-23 21:10:52 -05:00
committed by GitHub
parent 18c6e66a8e
commit 2f1e28c7d3
15 changed files with 132 additions and 62 deletions

View File

@@ -6,22 +6,22 @@ import (
)
type controller struct {
Info *prometheus.Desc
UptimeSeconds *prometheus.Desc
UpdateAvailable *prometheus.Desc
UpdateDownloaded *prometheus.Desc
AutobackupEnabled *prometheus.Desc
WebRTCSupport *prometheus.Desc
IsCloudConsole *prometheus.Desc
DataRetentionDays *prometheus.Desc
DataRetention5minHours *prometheus.Desc
DataRetentionHourlyHours *prometheus.Desc
DataRetentionDailyHours *prometheus.Desc
Info *prometheus.Desc
UptimeSeconds *prometheus.Desc
UpdateAvailable *prometheus.Desc
UpdateDownloaded *prometheus.Desc
AutobackupEnabled *prometheus.Desc
WebRTCSupport *prometheus.Desc
IsCloudConsole *prometheus.Desc
DataRetentionDays *prometheus.Desc
DataRetention5minHours *prometheus.Desc
DataRetentionHourlyHours *prometheus.Desc
DataRetentionDailyHours *prometheus.Desc
DataRetentionMonthlyHours *prometheus.Desc
UnsupportedDeviceCount *prometheus.Desc
InformPort *prometheus.Desc
HTTPSPort *prometheus.Desc
PortalHTTPPort *prometheus.Desc
UnsupportedDeviceCount *prometheus.Desc
InformPort *prometheus.Desc
HTTPSPort *prometheus.Desc
PortalHTTPPort *prometheus.Desc
}
func descController(ns string) *controller {
@@ -31,22 +31,22 @@ func descController(ns string) *controller {
nd := prometheus.NewDesc
return &controller{
Info: nd(ns+"controller_info", "Controller information (always 1)", infoLabels, nil),
UptimeSeconds: nd(ns+"controller_uptime_seconds", "Controller uptime in seconds", labels, nil),
UpdateAvailable: nd(ns+"controller_update_available", "Update available (1/0)", labels, nil),
UpdateDownloaded: nd(ns+"controller_update_downloaded", "Update downloaded (1/0)", labels, nil),
AutobackupEnabled: nd(ns+"controller_autobackup_enabled", "Auto backup enabled (1/0)", labels, nil),
WebRTCSupport: nd(ns+"controller_webrtc_support", "WebRTC supported (1/0)", labels, nil),
IsCloudConsole: nd(ns+"controller_is_cloud_console", "Is cloud console (1/0)", labels, nil),
DataRetentionDays: nd(ns+"controller_data_retention_days", "Data retention in days", labels, nil),
DataRetention5minHours: nd(ns+"controller_data_retention_5min_hours", "5-minute scale retention hours", labels, nil),
DataRetentionHourlyHours: nd(ns+"controller_data_retention_hourly_hours", "Hourly scale retention hours", labels, nil),
DataRetentionDailyHours: nd(ns+"controller_data_retention_daily_hours", "Daily scale retention hours", labels, nil),
Info: nd(ns+"controller_info", "Controller information (always 1)", infoLabels, nil),
UptimeSeconds: nd(ns+"controller_uptime_seconds", "Controller uptime in seconds", labels, nil),
UpdateAvailable: nd(ns+"controller_update_available", "Update available (1/0)", labels, nil),
UpdateDownloaded: nd(ns+"controller_update_downloaded", "Update downloaded (1/0)", labels, nil),
AutobackupEnabled: nd(ns+"controller_autobackup_enabled", "Auto backup enabled (1/0)", labels, nil),
WebRTCSupport: nd(ns+"controller_webrtc_support", "WebRTC supported (1/0)", labels, nil),
IsCloudConsole: nd(ns+"controller_is_cloud_console", "Is cloud console (1/0)", labels, nil),
DataRetentionDays: nd(ns+"controller_data_retention_days", "Data retention in days", labels, nil),
DataRetention5minHours: nd(ns+"controller_data_retention_5min_hours", "5-minute scale retention hours", labels, nil),
DataRetentionHourlyHours: nd(ns+"controller_data_retention_hourly_hours", "Hourly scale retention hours", labels, nil),
DataRetentionDailyHours: nd(ns+"controller_data_retention_daily_hours", "Daily scale retention hours", labels, nil),
DataRetentionMonthlyHours: nd(ns+"controller_data_retention_monthly_hours", "Monthly scale retention hours", labels, nil),
UnsupportedDeviceCount: nd(ns+"controller_unsupported_device_count", "Number of unsupported devices", labels, nil),
InformPort: nd(ns+"controller_inform_port", "Inform port number", labels, nil),
HTTPSPort: nd(ns+"controller_https_port", "HTTPS port number", labels, nil),
PortalHTTPPort: nd(ns+"controller_portal_http_port", "Portal HTTP port number", labels, nil),
UnsupportedDeviceCount: nd(ns+"controller_unsupported_device_count", "Number of unsupported devices", labels, nil),
InformPort: nd(ns+"controller_inform_port", "Inform port number", labels, nil),
HTTPSPort: nd(ns+"controller_https_port", "HTTPS port number", labels, nil),
PortalHTTPPort: nd(ns+"controller_portal_http_port", "Portal HTTP port number", labels, nil),
}
}
@@ -55,9 +55,11 @@ func (u *promUnifi) exportSysinfo(r report, s *unifi.Sysinfo) {
if hostname == "" {
hostname = s.Name
}
if hostname == "" {
hostname = s.SiteName // fallback when API omits both (e.g. remote/cloud)
}
labels := []string{hostname, s.SiteName, s.SourceName}
infoLabels := []string{s.Version, s.Build, s.DeviceType, s.ConsoleVer, hostname, s.SiteName, s.SourceName}
@@ -65,18 +67,22 @@ func (u *promUnifi) exportSysinfo(r report, s *unifi.Sysinfo) {
if s.UpdateAvail {
updateAvail = 1
}
updateDown := 0
if s.UpdateDown {
updateDown = 1
}
autobackup := 0
if s.Autobackup {
autobackup = 1
}
webrtc := 0
if s.HasWebRTC {
webrtc = 1
}
cloud := 0
if s.IsCloud {
cloud = 1

View File

@@ -58,6 +58,7 @@ func (u *promUnifi) exportFirewallPolicies(r report, policies []*unifi.FirewallP
// Per-site aggregate counters, keyed by "siteName|source"
type siteKey struct{ site, source string }
type siteStats struct {
total int
enabled int

View File

@@ -59,18 +59,18 @@ type pdu struct {
OutletPowerFactor *prometheus.Desc
OutletVoltage *prometheus.Desc
// UPS battery health (vbms_table)
BatteryLevelPercent *prometheus.Desc
BatteryTimeRemaining *prometheus.Desc
BatteryCharging *prometheus.Desc
BatteryMode *prometheus.Desc
BatteriesAvailable *prometheus.Desc
BatteriesReady *prometheus.Desc
PowerBudgetWatts *prometheus.Desc
PowerOutputWatts *prometheus.Desc
PowerFactor *prometheus.Desc
OutputVoltage *prometheus.Desc
OutputCurrentAmps *prometheus.Desc
LoadPercent *prometheus.Desc
BatteryLevelPercent *prometheus.Desc
BatteryTimeRemaining *prometheus.Desc
BatteryCharging *prometheus.Desc
BatteryMode *prometheus.Desc
BatteriesAvailable *prometheus.Desc
BatteriesReady *prometheus.Desc
PowerBudgetWatts *prometheus.Desc
PowerOutputWatts *prometheus.Desc
PowerFactor *prometheus.Desc
OutputVoltage *prometheus.Desc
OutputCurrentAmps *prometheus.Desc
LoadPercent *prometheus.Desc
BMSAnomalyCount *prometheus.Desc
PowerCycleOnRecoveryEnabled *prometheus.Desc
}
@@ -182,6 +182,7 @@ func (u *promUnifi) exportPDU(r report, d *unifi.PDU) {
if d.VBMSTable != nil {
u.exportPDUVBMS(r, d, append([]string{d.SiteName, d.Name, d.Mac, d.SourceName}, tag))
}
u.exportBYTstats(r, labels, d.TxBytes, d.RxBytes)
u.exportSYSstats(r, labels, d.SysStats, d.SystemStats)
u.exportSTAcount(r, labels, d.UserNumSta, d.GuestNumSta)

View File

@@ -72,6 +72,7 @@ func (r *Report) export(m *metric, v float64) prometheus.Metric {
for _, label := range m.Labels {
bytes += len(label) + 3 // label value + quotes and comma/equals overhead
}
bytes += 20 // approximate size for value and timestamp
r.Bytes += bytes