From 7683c8db976e39ac8bf975f8dd7f7a937755abf5 Mon Sep 17 00:00:00 2001 From: Gerard Nguyen Date: Thu, 17 Oct 2024 15:37:34 +1100 Subject: [PATCH] more lint fix --- pkg/analyze/host_memory.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/analyze/host_memory.go b/pkg/analyze/host_memory.go index ea70df1da..a3f4397d8 100644 --- a/pkg/analyze/host_memory.go +++ b/pkg/analyze/host_memory.go @@ -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 "<": @@ -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") }