refactor: dedupe status-severity ranking and small webui helpers
statusSeverity was byte-for-byte duplicated in collector/contract.go and app/sat_overlay.go (same switch, same comment). Export it as collector.StatusSeverity and drop the app-package copy. page_topo.go inlined the same GPU/NIC/RAID class switch as its own pcieDeviceKind function in one spot — call the function instead. page_validate.go had its own copy of pages.go's firstNonEmpty (all call sites already pre-trim their inputs via validateTrimPtr, so the extra TrimSpace was redundant) — drop the duplicate. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e3697c0a11
commit
134bed3eae
@@ -70,10 +70,10 @@ func isRAIDClass(class string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// statusSeverity ranks component statuses so merges can only escalate, never
|
||||
// StatusSeverity ranks component statuses so merges can only escalate, never
|
||||
// downgrade. Unknown ranks with OK: it means "couldn't tell", not "healthy",
|
||||
// so it must not silently clear a Warning/Critical raised by an earlier stage.
|
||||
func statusSeverity(status string) int {
|
||||
func StatusSeverity(status string) int {
|
||||
switch strings.TrimSpace(status) {
|
||||
case statusCritical:
|
||||
return 3
|
||||
@@ -101,7 +101,7 @@ func mergeDeviceStatus(dev *schema.HardwarePCIeDevice, status, description strin
|
||||
if dev.Status != nil {
|
||||
current = strings.TrimSpace(*dev.Status)
|
||||
}
|
||||
if current != "" && current != statusUnknown && statusSeverity(status) <= statusSeverity(current) {
|
||||
if current != "" && current != statusUnknown && StatusSeverity(status) <= StatusSeverity(current) {
|
||||
return
|
||||
}
|
||||
dev.Status = &status
|
||||
|
||||
Reference in New Issue
Block a user