[v9.5.x] Expressions/threshold: Fix incorrect thresholds args length (#66926)
Expressions/threshold: Fix incorrect thresholds args length (#66859)
(cherry picked from commit 350de3f3bf)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
co-authored by
Gilles De Mey
parent
006cea2192
commit
dcc5190620
@@ -29,6 +29,17 @@ var (
|
||||
)
|
||||
|
||||
func NewThresholdCommand(refID, referenceVar, thresholdFunc string, conditions []float64) (*ThresholdCommand, error) {
|
||||
switch thresholdFunc {
|
||||
case ThresholdIsOutsideRange, ThresholdIsWithinRange:
|
||||
if len(conditions) < 2 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments: got %d but need 2", len(conditions))
|
||||
}
|
||||
case ThresholdIsAbove, ThresholdIsBelow:
|
||||
if len(conditions) < 1 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments: got %d but need 1", len(conditions))
|
||||
}
|
||||
}
|
||||
|
||||
return &ThresholdCommand{
|
||||
RefID: refID,
|
||||
ReferenceVar: referenceVar,
|
||||
|
||||
Reference in New Issue
Block a user