From 163a7730888dac2d436988499af87d4ff8f7d118 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:08:14 -0400 Subject: [PATCH] chore(code): reorganize HA & node network code (#1218) Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --- fwprovider/{ => ha}/datasource_hagroup.go | 6 ++-- fwprovider/{ => ha}/datasource_hagroups.go | 2 +- fwprovider/{ => ha}/datasource_haresource.go | 10 +++---- fwprovider/{ => ha}/datasource_haresources.go | 2 +- fwprovider/{ => ha}/hagroup_model.go | 12 ++++---- fwprovider/{ => ha}/haresource_model.go | 20 ++++++------- fwprovider/{ => ha}/resource_hagroup.go | 18 ++++++------ fwprovider/{ => ha}/resource_haresource.go | 29 +++++++++---------- fwprovider/ha/validators.go | 29 +++++++++++++++++++ .../{ => network}/resource_linux_bridge.go | 2 +- .../{ => network}/resource_linux_vlan.go | 2 +- fwprovider/provider.go | 18 +++++++----- .../validators/ha_resource_validator.go | 28 ------------------ 13 files changed, 89 insertions(+), 89 deletions(-) rename fwprovider/{ => ha}/datasource_hagroup.go (97%) rename fwprovider/{ => ha}/datasource_hagroups.go (99%) rename fwprovider/{ => ha}/datasource_haresource.go (95%) rename fwprovider/{ => ha}/datasource_haresources.go (99%) rename fwprovider/{ => ha}/hagroup_model.go (86%) rename fwprovider/{ => ha}/haresource_model.go (80%) rename fwprovider/{ => ha}/resource_hagroup.go (97%) rename fwprovider/{ => ha}/resource_haresource.go (94%) create mode 100644 fwprovider/ha/validators.go rename fwprovider/{ => network}/resource_linux_bridge.go (99%) rename fwprovider/{ => network}/resource_linux_vlan.go (99%) delete mode 100644 fwprovider/validators/ha_resource_validator.go diff --git a/fwprovider/datasource_hagroup.go b/fwprovider/ha/datasource_hagroup.go similarity index 97% rename from fwprovider/datasource_hagroup.go rename to fwprovider/ha/datasource_hagroup.go index 3ffd97c8..889fb86e 100644 --- a/fwprovider/datasource_hagroup.go +++ b/fwprovider/ha/datasource_hagroup.go @@ -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)...) } diff --git a/fwprovider/datasource_hagroups.go b/fwprovider/ha/datasource_hagroups.go similarity index 99% rename from fwprovider/datasource_hagroups.go rename to fwprovider/ha/datasource_hagroups.go index 9b2e55c1..16edeb96 100644 --- a/fwprovider/datasource_hagroups.go +++ b/fwprovider/ha/datasource_hagroups.go @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package fwprovider +package ha import ( "context" diff --git a/fwprovider/datasource_haresource.go b/fwprovider/ha/datasource_haresource.go similarity index 95% rename from fwprovider/datasource_haresource.go rename to fwprovider/ha/datasource_haresource.go index 02b869ce..95b583c9 100644 --- a/fwprovider/datasource_haresource.go +++ b/fwprovider/ha/datasource_haresource.go @@ -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)...) } diff --git a/fwprovider/datasource_haresources.go b/fwprovider/ha/datasource_haresources.go similarity index 99% rename from fwprovider/datasource_haresources.go rename to fwprovider/ha/datasource_haresources.go index 44f29552..4576a047 100644 --- a/fwprovider/datasource_haresources.go +++ b/fwprovider/ha/datasource_haresources.go @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package fwprovider +package ha import ( "context" diff --git a/fwprovider/hagroup_model.go b/fwprovider/ha/hagroup_model.go similarity index 86% rename from fwprovider/hagroup_model.go rename to fwprovider/ha/hagroup_model.go index d6785f29..d8ba151f 100644 --- a/fwprovider/hagroup_model.go +++ b/fwprovider/ha/hagroup_model.go @@ -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, ",") diff --git a/fwprovider/haresource_model.go b/fwprovider/ha/haresource_model.go similarity index 80% rename from fwprovider/haresource_model.go rename to fwprovider/ha/haresource_model.go index be98e267..21f87ccd 100644 --- a/fwprovider/haresource_model.go +++ b/fwprovider/ha/haresource_model.go @@ -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() { diff --git a/fwprovider/resource_hagroup.go b/fwprovider/ha/resource_hagroup.go similarity index 97% rename from fwprovider/resource_hagroup.go rename to fwprovider/ha/resource_hagroup.go index 20ef1f7c..10bafa5f 100644 --- a/fwprovider/resource_hagroup.go +++ b/fwprovider/ha/resource_hagroup.go @@ -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. diff --git a/fwprovider/resource_haresource.go b/fwprovider/ha/resource_haresource.go similarity index 94% rename from fwprovider/resource_haresource.go rename to fwprovider/ha/resource_haresource.go index aaee1ea7..62db96c6 100644 --- a/fwprovider/resource_haresource.go +++ b/fwprovider/ha/resource_haresource.go @@ -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, ) { diff --git a/fwprovider/ha/validators.go b/fwprovider/ha/validators.go new file mode 100644 index 00000000..c9f0b223 --- /dev/null +++ b/fwprovider/ha/validators.go @@ -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") +} diff --git a/fwprovider/resource_linux_bridge.go b/fwprovider/network/resource_linux_bridge.go similarity index 99% rename from fwprovider/resource_linux_bridge.go rename to fwprovider/network/resource_linux_bridge.go index 7793bf5f..8d5fd93f 100644 --- a/fwprovider/resource_linux_bridge.go +++ b/fwprovider/network/resource_linux_bridge.go @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package fwprovider +package network import ( "context" diff --git a/fwprovider/resource_linux_vlan.go b/fwprovider/network/resource_linux_vlan.go similarity index 99% rename from fwprovider/resource_linux_vlan.go rename to fwprovider/network/resource_linux_vlan.go index b869f2a1..e33e83bf 100644 --- a/fwprovider/resource_linux_vlan.go +++ b/fwprovider/network/resource_linux_vlan.go @@ -4,7 +4,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -package fwprovider +package network import ( "context" diff --git a/fwprovider/provider.go b/fwprovider/provider.go index fd3a9abc..3d2d3a6d 100644 --- a/fwprovider/provider.go +++ b/fwprovider/provider.go @@ -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, } } diff --git a/fwprovider/validators/ha_resource_validator.go b/fwprovider/validators/ha_resource_validator.go deleted file mode 100644 index b89bc6d6..00000000 --- a/fwprovider/validators/ha_resource_validator.go +++ /dev/null @@ -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") -}