0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 19:12:59 +00:00
terraform-provider-proxmox/proxmoxtf/resource/validators/firewall.go
Pavel Boldyrev efd0d7b466
chore: remove unused code (#1236)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2024-04-24 20:52:41 -04:00

41 lines
1.2 KiB
Go

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package validators
import (
"regexp"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
var rateExpression = regexp.MustCompile(`[1-9][0-9]*/(second|minute|hour|day)`)
// FirewallRate returns a schema validation function for a firewall rate.
func FirewallRate() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringMatch(
rateExpression,
"Must be a valid rate expression, e.g. '1/second'",
))
}
// FirewallPolicy returns a schema validation function for a firewall policy.
func FirewallPolicy() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice(
[]string{"ACCEPT", "REJECT", "DROP"},
false,
))
}
// FirewallLogLevel returns a schema validation function for a firewall log level.
func FirewallLogLevel() schema.SchemaValidateDiagFunc {
return validation.ToDiagFunc(validation.StringInSlice(
[]string{"emerg", "alert", "crit", "err", "warning", "notice", "info", "debug", "nolog"},
false,
))
}