v1.16.9
This commit is contained in:
dayterr
2026-10-23 16:06:09 +03:00
parent 84164a72a4
commit 54a86e5361
21 changed files with 351 additions and 71 deletions

View File

@@ -508,24 +508,24 @@ func migrateV2ModeValidator(fe validator.FieldLevel) bool {
// pressureThresholdValidator checks if PressureThreshold is in range from 5 to 50
func pressureThresholdValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(pressureThresholdMin) && fieldValue <= uint64(pressureThresholdMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(pressureThresholdMin) && fieldValue <= float64(pressureThresholdMax)
}
// deflateThresholdValidator checks if DeflateThreshold is in range from 10 to 70
func deflateThresholdValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(deflateThresholdMin) && fieldValue <= uint64(deflateThresholdMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(deflateThresholdMin) && fieldValue <= float64(deflateThresholdMax)
}
func bufferPCTValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(bufferPCTMin) && fieldValue <= uint64(bufferPCTMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(bufferPCTMin) && fieldValue <= float64(bufferPCTMax)
}
func guaranteedPCTValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(guaranteedPCTMin) && fieldValue <= uint64(guaranteedPCTMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(guaranteedPCTMin) && fieldValue <= float64(guaranteedPCTMax)
}
func guaranteedABSMinValidator(fe validator.FieldLevel) bool {
@@ -534,18 +534,18 @@ func guaranteedABSMinValidator(fe validator.FieldLevel) bool {
}
func shrinkThresholdPCTValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(shrinkThresholdPCTMin) && fieldValue <= uint64(shrinkThresholdPCTMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(shrinkThresholdPCTMin) && fieldValue <= float64(shrinkThresholdPCTMax)
}
func balloonMaxShrinkPCTValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(balloonMaxShrinkPCTMin) && fieldValue <= uint64(balloonMaxShrinkPCTMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(balloonMaxShrinkPCTMin) && fieldValue <= float64(balloonMaxShrinkPCTMax)
}
func balloonMaxGrowPCTValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().Uint()
return fieldValue >= uint64(balloonMaxGrowPCTMin) && fieldValue <= uint64(balloonMaxGrowPCTMax)
fieldValue := fe.Field().Float()
return fieldValue >= float64(balloonMaxGrowPCTMin) && fieldValue <= float64(balloonMaxGrowPCTMax)
}
func vmChangeCooldownValidator(fe validator.FieldLevel) bool {
@@ -567,3 +567,8 @@ func logLevelValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
return IsInSlice(fieldValue, logLevelValues)
}
func sepTypesValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
return IsInSlice(fieldValue, sepTypesValues)
}

View File

@@ -367,6 +367,12 @@ func errorMessage(fe validator.FieldError) string {
prefix,
fe.Field(),
joinValues(sepTechStatusValues))
case "sepTypes":
return fmt.Sprintf("%s %s must be one of the following: %s",
prefix,
fe.Field(),
joinValues(sepTypesValues))
}
return fe.Error()

View File

@@ -398,5 +398,10 @@ func registerAllValidators(validate *validator.Validate) error {
return err
}
err = validate.RegisterValidation("sepTypes", sepTypesValidator)
if err != nil {
return err
}
return nil
}

View File

@@ -63,7 +63,7 @@ var (
loaderTypeValues = []string{"linux", "windows", "unknown"}
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des", "ustor"}
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des", "ustor", "aerodisk"}
languageValues = []string{"ru", "en"}
@@ -88,6 +88,8 @@ var (
migrateV2ModeValues = []string{"compute", "disks", "compute_and_disks"}
logLevelValues = []string{"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
sepTypesValues = []string{"DES", "DORADO", "HITACHI", "LOCAL", "SHARED", "TATLIN", "USTOR", "AERODISK"}
)
const (