@@ -147,17 +147,13 @@ func extractCapacityRequirements(req placementv1beta1.PropertySelectorRequiremen
147147// validateCapacity checks if the provided capacity value is valid.
148148func validateCapacity (value string , operator placementv1beta1.PropertySelectorOperator ) (uint32 , error ) {
149149 // Parse directly as uint32 to avoid integer overflow issues
150- capacity , err := strconv .ParseUint (value , 10 , 32 )
150+ valueUint , err := strconv .ParseUint (value , 10 , 32 )
151151 if err != nil {
152152 return 0 , fmt .Errorf ("invalid capacity value %q: %w" , value , err )
153153 }
154+ capacity := uint32 (valueUint )
154155
155- // Validate capacity is non-negative
156- if capacity < 0 {
157- return 0 , fmt .Errorf ("capacity value %d cannot be negative" , capacity )
158- }
159-
160- // Validate capacity bounds
156+ // Validate capacity bounds (capacity is already >= 0 since it's parsed as uint)
161157 if capacity < minVMInstanceCapacity {
162158 return 0 , fmt .Errorf ("capacity value %d is below minimum allowed value of %d" , capacity , minVMInstanceCapacity )
163159 }
@@ -169,6 +165,5 @@ func validateCapacity(value string, operator placementv1beta1.PropertySelectorOp
169165 // For GreaterThanOrEqualTo, subtract 1 as client requests only support GreaterThan
170166 capacity -= 1
171167 }
172-
173- return uint32 (capacity ), nil
168+ return capacity , nil
174169}
0 commit comments