mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 10:33:46 +00:00
chore(code): reorganize HA & node network code (#1218)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
1bf3bf0f68
commit
163a773088
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -105,7 +105,7 @@ func (d *haGroupDatasource) Configure(
|
||||
|
||||
// Read fetches the list of HA groups from the Proxmox cluster then converts it to a list of strings.
|
||||
func (d *haGroupDatasource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
|
||||
var state haGroupModel
|
||||
var state GroupModel
|
||||
|
||||
resp.Diagnostics.Append(req.Config.Get(ctx, &state)...)
|
||||
|
||||
@ -127,6 +127,6 @@ func (d *haGroupDatasource) Read(ctx context.Context, req datasource.ReadRequest
|
||||
|
||||
state.ID = types.StringValue(groupID)
|
||||
|
||||
resp.Diagnostics.Append(state.importFromAPI(*group)...)
|
||||
resp.Diagnostics.Append(state.ImportFromAPI(*group)...)
|
||||
resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"context"
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -15,8 +15,6 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/structure"
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/validators"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
haresources "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/resources"
|
||||
proxmoxtypes "github.com/bpg/terraform-provider-proxmox/proxmox/types"
|
||||
@ -57,7 +55,7 @@ func (d *haResourceDatasource) Schema(_ context.Context, _ datasource.SchemaRequ
|
||||
Description: "The identifier of the Proxmox HA resource to read.",
|
||||
Required: true,
|
||||
Validators: []validator.String{
|
||||
validators.HAResourceIDValidator(),
|
||||
resourceIDValidator(),
|
||||
},
|
||||
},
|
||||
"type": schema.StringAttribute{
|
||||
@ -112,7 +110,7 @@ func (d *haResourceDatasource) Configure(
|
||||
|
||||
// Read fetches the specified HA resource.
|
||||
func (d *haResourceDatasource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
|
||||
var data haResourceModel
|
||||
var data ResourceModel
|
||||
|
||||
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
|
||||
|
||||
@ -140,6 +138,6 @@ func (d *haResourceDatasource) Read(ctx context.Context, req datasource.ReadRequ
|
||||
return
|
||||
}
|
||||
|
||||
data.importFromAPI(resource)
|
||||
data.ImportFromAPI(resource)
|
||||
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"context"
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -18,8 +18,8 @@ import (
|
||||
hagroups "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/groups"
|
||||
)
|
||||
|
||||
// haGroupModel is the model used to represent a High Availability group.
|
||||
type haGroupModel struct {
|
||||
// GroupModel is the model used to represent a High Availability group.
|
||||
type GroupModel struct {
|
||||
ID types.String `tfsdk:"id"` // Identifier used by Terraform
|
||||
Group types.String `tfsdk:"group"` // HA group name
|
||||
Comment types.String `tfsdk:"comment"` // Comment, if present
|
||||
@ -28,8 +28,8 @@ type haGroupModel struct {
|
||||
Restricted types.Bool `tfsdk:"restricted"` // Flag that prevents execution on other member nodes
|
||||
}
|
||||
|
||||
// Import the contents of a HA group model from the API's response data.
|
||||
func (m *haGroupModel) importFromAPI(group hagroups.HAGroupGetResponseData) diag.Diagnostics {
|
||||
// ImportFromAPI imports the contents of a HA group model from the API's response data.
|
||||
func (m *GroupModel) ImportFromAPI(group hagroups.HAGroupGetResponseData) diag.Diagnostics {
|
||||
m.Comment = types.StringPointerValue(group.Comment)
|
||||
m.NoFailback = group.NoFailback.ToValue()
|
||||
m.Restricted = group.Restricted.ToValue()
|
||||
@ -39,7 +39,7 @@ func (m *haGroupModel) importFromAPI(group hagroups.HAGroupGetResponseData) diag
|
||||
|
||||
// Parse the list of member nodes. The list is received from the Proxmox API as a string. It must
|
||||
// be converted into a map value. Errors will be returned as Terraform diagnostics.
|
||||
func (m *haGroupModel) parseHAGroupNodes(nodes string) diag.Diagnostics {
|
||||
func (m *GroupModel) parseHAGroupNodes(nodes string) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
nodesIn := strings.Split(nodes, ",")
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -15,8 +15,8 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
)
|
||||
|
||||
// haResourceModel maps the schema data for the High Availability resource data source.
|
||||
type haResourceModel struct {
|
||||
// ResourceModel maps the schema data for the High Availability resource data source.
|
||||
type ResourceModel struct {
|
||||
// The Terraform resource identifier
|
||||
ID types.String `tfsdk:"id"`
|
||||
// The Proxmox HA resource identifier
|
||||
@ -35,8 +35,8 @@ type haResourceModel struct {
|
||||
MaxRestart types.Int64 `tfsdk:"max_restart"`
|
||||
}
|
||||
|
||||
// importFromAPI imports the contents of a HA resource model from the API's response data.
|
||||
func (d *haResourceModel) importFromAPI(data *haresources.HAResourceGetResponseData) {
|
||||
// ImportFromAPI imports the contents of a HA resource model from the API's response data.
|
||||
func (d *ResourceModel) ImportFromAPI(data *haresources.HAResourceGetResponseData) {
|
||||
d.ID = data.ID.ToValue()
|
||||
d.ResourceID = data.ID.ToValue()
|
||||
d.Type = data.Type.ToValue()
|
||||
@ -48,7 +48,7 @@ func (d *haResourceModel) importFromAPI(data *haresources.HAResourceGetResponseD
|
||||
}
|
||||
|
||||
// toRequestBase builds the common request data structure for HA resource creation or update API calls.
|
||||
func (d *haResourceModel) toRequestBase() haresources.HAResourceDataBase {
|
||||
func (d *ResourceModel) toRequestBase() haresources.HAResourceDataBase {
|
||||
var state proxmoxtypes.HAResourceState
|
||||
|
||||
if d.State.IsNull() {
|
||||
@ -74,8 +74,8 @@ func (d *haResourceModel) toRequestBase() haresources.HAResourceDataBase {
|
||||
}
|
||||
}
|
||||
|
||||
// toCreateRequest builds the request data structure for creating a new HA resource.
|
||||
func (d *haResourceModel) toCreateRequest(resID proxmoxtypes.HAResourceID) *haresources.HAResourceCreateRequestBody {
|
||||
// ToCreateRequest builds the request data structure for creating a new HA resource.
|
||||
func (d *ResourceModel) ToCreateRequest(resID proxmoxtypes.HAResourceID) *haresources.HAResourceCreateRequestBody {
|
||||
return &haresources.HAResourceCreateRequestBody{
|
||||
ID: resID,
|
||||
Type: &resID.Type,
|
||||
@ -83,8 +83,8 @@ func (d *haResourceModel) toCreateRequest(resID proxmoxtypes.HAResourceID) *hare
|
||||
}
|
||||
}
|
||||
|
||||
// toUpdateRequest builds the request data structure for updating an existing HA resource.
|
||||
func (d *haResourceModel) toUpdateRequest(state *haResourceModel) *haresources.HAResourceUpdateRequestBody {
|
||||
// ToUpdateRequest builds the request data structure for updating an existing HA resource.
|
||||
func (d *ResourceModel) ToUpdateRequest(state *ResourceModel) *haresources.HAResourceUpdateRequestBody {
|
||||
var del []string
|
||||
|
||||
if d.Comment.IsNull() && !state.Comment.IsNull() {
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -144,7 +144,7 @@ func (r *hagroupResource) Configure(
|
||||
|
||||
// Create creates a new HA group on the Proxmox cluster.
|
||||
func (r *hagroupResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
|
||||
var data haGroupModel
|
||||
var data GroupModel
|
||||
|
||||
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
|
||||
|
||||
@ -178,7 +178,7 @@ func (r *hagroupResource) Create(ctx context.Context, req resource.CreateRequest
|
||||
|
||||
// Read reads a HA group definition from the Proxmox cluster.
|
||||
func (r *hagroupResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
|
||||
var data haGroupModel
|
||||
var data GroupModel
|
||||
|
||||
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
|
||||
|
||||
@ -200,7 +200,7 @@ func (r *hagroupResource) Read(ctx context.Context, req resource.ReadRequest, re
|
||||
|
||||
// Update updates a HA group definition on the Proxmox cluster.
|
||||
func (r *hagroupResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
|
||||
var data, state haGroupModel
|
||||
var data, state GroupModel
|
||||
|
||||
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
|
||||
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
|
||||
@ -233,7 +233,7 @@ func (r *hagroupResource) Update(ctx context.Context, req resource.UpdateRequest
|
||||
|
||||
// Delete deletes a HA group definition.
|
||||
func (r *hagroupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
|
||||
var data haGroupModel
|
||||
var data GroupModel
|
||||
|
||||
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
|
||||
|
||||
@ -270,7 +270,7 @@ func (r *hagroupResource) ImportState(
|
||||
resp *resource.ImportStateResponse,
|
||||
) {
|
||||
reqID := req.ID
|
||||
data := haGroupModel{
|
||||
data := GroupModel{
|
||||
ID: types.StringValue(reqID),
|
||||
Group: types.StringValue(reqID),
|
||||
}
|
||||
@ -281,7 +281,7 @@ func (r *hagroupResource) ImportState(
|
||||
// state accordingly. It is assumed that the `state`'s identifier is set.
|
||||
func (r *hagroupResource) readBack(
|
||||
ctx context.Context,
|
||||
data *haGroupModel,
|
||||
data *GroupModel,
|
||||
respDiags *diag.Diagnostics,
|
||||
respState *tfsdk.State,
|
||||
) {
|
||||
@ -303,7 +303,7 @@ func (r *hagroupResource) readBack(
|
||||
|
||||
// read reads information about a HA group from the cluster. The group identifier must have been set in the
|
||||
// `data`.
|
||||
func (r *hagroupResource) read(ctx context.Context, data *haGroupModel) (bool, diag.Diagnostics) {
|
||||
func (r *hagroupResource) read(ctx context.Context, data *GroupModel) (bool, diag.Diagnostics) {
|
||||
name := data.Group.ValueString()
|
||||
|
||||
group, err := r.client.Get(ctx, name)
|
||||
@ -317,7 +317,7 @@ func (r *hagroupResource) read(ctx context.Context, data *haGroupModel) (bool, d
|
||||
return false, diags
|
||||
}
|
||||
|
||||
return true, data.importFromAPI(*group)
|
||||
return true, data.ImportFromAPI(*group)
|
||||
}
|
||||
|
||||
// groupNodesToString converts the map of group member nodes into a string.
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package ha
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -13,7 +13,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/structure"
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/validators"
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
haresources "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/resources"
|
||||
proxmoxtypes "github.com/bpg/terraform-provider-proxmox/proxmox/types"
|
||||
@ -74,7 +73,7 @@ func (r *haResourceResource) Schema(
|
||||
Description: "The Proxmox HA resource identifier",
|
||||
Required: true,
|
||||
Validators: []validator.String{
|
||||
validators.HAResourceIDValidator(),
|
||||
resourceIDValidator(),
|
||||
},
|
||||
},
|
||||
"state": schema.StringAttribute{
|
||||
@ -83,7 +82,7 @@ func (r *haResourceResource) Schema(
|
||||
Computed: true,
|
||||
Default: stringdefault.StaticString("started"),
|
||||
Validators: []validator.String{
|
||||
validators.HAResourceStateValidator(),
|
||||
resourceStateValidator(),
|
||||
},
|
||||
},
|
||||
"type": schema.StringAttribute{
|
||||
@ -91,7 +90,7 @@ func (r *haResourceResource) Schema(
|
||||
Computed: true,
|
||||
Optional: true,
|
||||
Validators: []validator.String{
|
||||
validators.HAResourceTypeValidator(),
|
||||
resourceTypeValidator(),
|
||||
},
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.UseStateForUnknown(),
|
||||
@ -158,7 +157,7 @@ func (r *haResourceResource) Configure(
|
||||
|
||||
// Create creates a new HA resource.
|
||||
func (r *haResourceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
|
||||
var data haResourceModel
|
||||
var data ResourceModel
|
||||
|
||||
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
|
||||
|
||||
@ -176,7 +175,7 @@ func (r *haResourceResource) Create(ctx context.Context, req resource.CreateRequ
|
||||
return
|
||||
}
|
||||
|
||||
createRequest := data.toCreateRequest(resID)
|
||||
createRequest := data.ToCreateRequest(resID)
|
||||
|
||||
err = r.client.Create(ctx, createRequest)
|
||||
if err != nil {
|
||||
@ -199,7 +198,7 @@ func (r *haResourceResource) Update(
|
||||
req resource.UpdateRequest,
|
||||
resp *resource.UpdateResponse,
|
||||
) {
|
||||
var data, state haResourceModel
|
||||
var data, state ResourceModel
|
||||
|
||||
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
|
||||
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
|
||||
@ -218,7 +217,7 @@ func (r *haResourceResource) Update(
|
||||
return
|
||||
}
|
||||
|
||||
updateRequest := data.toUpdateRequest(&state)
|
||||
updateRequest := data.ToUpdateRequest(&state)
|
||||
|
||||
err = r.client.Update(ctx, resID, updateRequest)
|
||||
if err == nil {
|
||||
@ -238,7 +237,7 @@ func (r *haResourceResource) Delete(
|
||||
req resource.DeleteRequest,
|
||||
resp *resource.DeleteResponse,
|
||||
) {
|
||||
var data haResourceModel
|
||||
var data ResourceModel
|
||||
|
||||
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
|
||||
|
||||
@ -282,7 +281,7 @@ func (r *haResourceResource) Read(
|
||||
req resource.ReadRequest,
|
||||
resp *resource.ReadResponse,
|
||||
) {
|
||||
var data haResourceModel
|
||||
var data ResourceModel
|
||||
|
||||
resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
|
||||
|
||||
@ -309,7 +308,7 @@ func (r *haResourceResource) ImportState(
|
||||
resp *resource.ImportStateResponse,
|
||||
) {
|
||||
reqID := req.ID
|
||||
data := haResourceModel{
|
||||
data := ResourceModel{
|
||||
ID: types.StringValue(reqID),
|
||||
ResourceID: types.StringValue(reqID),
|
||||
}
|
||||
@ -318,7 +317,7 @@ func (r *haResourceResource) ImportState(
|
||||
|
||||
// read reads information about a HA resource from the cluster. The Terraform resource identifier must have been set
|
||||
// in the model before this function is called.
|
||||
func (r *haResourceResource) read(ctx context.Context, data *haResourceModel) (bool, diag.Diagnostics) {
|
||||
func (r *haResourceResource) read(ctx context.Context, data *ResourceModel) (bool, diag.Diagnostics) {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
resID, err := proxmoxtypes.ParseHAResourceID(data.ID.ValueString())
|
||||
@ -340,7 +339,7 @@ func (r *haResourceResource) read(ctx context.Context, data *haResourceModel) (b
|
||||
return false, diags
|
||||
}
|
||||
|
||||
data.importFromAPI(res)
|
||||
data.ImportFromAPI(res)
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@ -349,7 +348,7 @@ func (r *haResourceResource) read(ctx context.Context, data *haResourceModel) (b
|
||||
// state accordingly. It is assumed that the `state`'s identifier is set.
|
||||
func (r *haResourceResource) readBack(
|
||||
ctx context.Context,
|
||||
data *haResourceModel,
|
||||
data *ResourceModel,
|
||||
respDiags *diag.Diagnostics,
|
||||
respState *tfsdk.State,
|
||||
) {
|
29
fwprovider/ha/validators.go
Normal file
29
fwprovider/ha/validators.go
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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 ha
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/validators"
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox/types"
|
||||
)
|
||||
|
||||
// resourceIDValidator returns a new HA resource identifier validator.
|
||||
func resourceIDValidator() validator.String {
|
||||
return validators.NewParseValidator(types.ParseHAResourceID, "value must be a valid HA resource identifier")
|
||||
}
|
||||
|
||||
// resourceStateValidator returns a new HA resource state validator.
|
||||
func resourceStateValidator() validator.String {
|
||||
return validators.NewParseValidator(types.ParseHAResourceState, "value must be a valid HA resource state")
|
||||
}
|
||||
|
||||
// resourceTypeValidator returns a new HA resource type validator.
|
||||
func resourceTypeValidator() validator.String {
|
||||
return validators.NewParseValidator(types.ParseHAResourceType, "value must be a valid HA resource type")
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package network
|
||||
|
||||
import (
|
||||
"context"
|
@ -4,7 +4,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package fwprovider
|
||||
package network
|
||||
|
||||
import (
|
||||
"context"
|
@ -25,6 +25,8 @@ import (
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/ha"
|
||||
"github.com/bpg/terraform-provider-proxmox/fwprovider/network"
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox/api"
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes"
|
||||
@ -436,22 +438,22 @@ func (p *proxmoxProvider) Configure(
|
||||
|
||||
func (p *proxmoxProvider) Resources(_ context.Context) []func() resource.Resource {
|
||||
return []func() resource.Resource{
|
||||
NewHAGroupResource,
|
||||
NewHAResourceResource,
|
||||
ha.NewHAGroupResource,
|
||||
ha.NewHAResourceResource,
|
||||
network.NewLinuxBridgeResource,
|
||||
network.NewLinuxVLANResource,
|
||||
NewClusterOptionsResource,
|
||||
NewLinuxBridgeResource,
|
||||
NewLinuxVLANResource,
|
||||
NewDownloadFileResource,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *proxmoxProvider) DataSources(_ context.Context) []func() datasource.DataSource {
|
||||
return []func() datasource.DataSource{
|
||||
ha.NewHAGroupsDataSource,
|
||||
ha.NewHAGroupDataSource,
|
||||
ha.NewHAResourcesDataSource,
|
||||
ha.NewHAResourceDataSource,
|
||||
NewVersionDataSource,
|
||||
NewHAGroupsDataSource,
|
||||
NewHAGroupDataSource,
|
||||
NewHAResourcesDataSource,
|
||||
NewHAResourceDataSource,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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 (
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox/types"
|
||||
)
|
||||
|
||||
// HAResourceIDValidator returns a new HA resource identifier validator.
|
||||
func HAResourceIDValidator() validator.String {
|
||||
return NewParseValidator(types.ParseHAResourceID, "value must be a valid HA resource identifier")
|
||||
}
|
||||
|
||||
// HAResourceStateValidator returns a new HA resource state validator.
|
||||
func HAResourceStateValidator() validator.String {
|
||||
return NewParseValidator(types.ParseHAResourceState, "value must be a valid HA resource state")
|
||||
}
|
||||
|
||||
// HAResourceTypeValidator returns a new HA resource type validator.
|
||||
func HAResourceTypeValidator() validator.String {
|
||||
return NewParseValidator(types.ParseHAResourceType, "value must be a valid HA resource type")
|
||||
}
|
Loading…
Reference in New Issue
Block a user