Skip to content

Commit

Permalink
Validating hugepages (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Bonic authored Jun 20, 2022
1 parent b2201aa commit ab9f807
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion internal/ovirt/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,18 @@ func validateEnum(values []string) schema.SchemaValidateDiagFunc {
}

func validateHugePages(i interface{}, path cty.Path) diag.Diagnostics {
err := ovirtclient.VMHugePages(i.(int)).Validate()
hugePages := i.(int)
if hugePages < 0 {
return diag.Diagnostics{
diag.Diagnostic{
Severity: diag.Error,
Summary: "Not a valid huge page value.",
Detail: "must not be negative",
AttributePath: path,
},
}
}
err := ovirtclient.VMHugePages(hugePages).Validate()
if err != nil {
return diag.Diagnostics{
diag.Diagnostic{
Expand Down

0 comments on commit ab9f807

Please sign in to comment.