0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 11:02:59 +00:00
terraform-provider-proxmox/fwprovider/nodes/hardwaremapping/shared.go
Pavel Boldyrev 2a356014a1
misc(code): move fwprovider files around (#1866)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
2025-03-29 19:02:41 +00:00

50 lines
2.6 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 hardwaremapping
import (
"regexp"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
datasourceschema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
resourceschema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)
//nolint:gochecknoglobals
var (
// dataSourceSchemaBaseAttrComment is the base comment attribute for a hardware mapping data source.
// Note that the Proxmox VE API attribute is named "description", but we map it as a comment since this naming is
// generally across the Proxmox VE web UI and API documentations. This still follows the [Terraform "best practices"]
// as it improves the user experience by matching the field name to the naming used in the human-facing interfaces.
//
// [Terraform "best practices"]: https://developer.hashicorp.com/terraform/plugin/best-practices/hashicorp-provider-design-principles#resource-and-attribute-schema-should-closely-match-the-underlying-api
dataSourceSchemaBaseAttrComment = datasourceschema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.UTF8LengthAtLeast(1),
stringvalidator.RegexMatches(regexp.MustCompile(`^\S|^$`), "must not start with whitespace"),
stringvalidator.RegexMatches(regexp.MustCompile(`\S$|^$`), "must not end with whitespace"),
},
}
// dataSourceSchemaBaseAttrComment is the base comment attribute for a hardware mapping resource.
// Note that the Proxmox VE API attribute is named "description", but we map it as a comment since this naming is
// generally across the Proxmox VE web UI and API documentations. This still follows the [Terraform "best practices"]
// as it improves the user experience by matching the field name to the naming used in the human-facing interfaces.
//
// [Terraform "best practices"]: https://developer.hashicorp.com/terraform/plugin/best-practices/hashicorp-provider-design-principles#resource-and-attribute-schema-should-closely-match-the-underlying-api
resourceSchemaBaseAttrComment = resourceschema.StringAttribute{
Optional: true,
Validators: []validator.String{
stringvalidator.UTF8LengthAtLeast(1),
stringvalidator.RegexMatches(regexp.MustCompile(`^\S|^$`), "must not start with whitespace"),
stringvalidator.RegexMatches(regexp.MustCompile(`\S$|^$`), "must not end with whitespace"),
},
}
)