Skip to content

Commit

Permalink
more lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nvanthao committed Oct 21, 2024
1 parent 604f72e commit 7683c8d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/analyze/host_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func (a *AnalyzeHostMemory) CheckCondition(when string, data CollectorData) (boo
if !ok {
return false, fmt.Errorf("could not parse quantity %q", desired)
}
if desiredInt < 0 {
return false, fmt.Errorf("desired value must be a positive integer, got %d", desiredInt)
}

switch operator {
case "<":
Expand All @@ -87,7 +90,8 @@ func (a *AnalyzeHostMemory) CheckCondition(when string, data CollectorData) (boo
return memInfo.Total >= uint64(desiredInt), nil
case "=", "==", "===":
return memInfo.Total == uint64(desiredInt), nil
default:
return false, fmt.Errorf("unsupported operator: %q", operator)
}

return false, errors.New("unknown operator")
}

0 comments on commit 7683c8d

Please sign in to comment.