0
0
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:
Pavel Boldyrev 2024-04-15 20:08:14 -04:00 committed by GitHub
parent 1bf3bf0f68
commit 163a773088
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 89 additions and 89 deletions

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"context" "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. // 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) { 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)...) 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) 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)...) resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
} }

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"context" "context"

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"context" "context"
@ -15,8 +15,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/bpg/terraform-provider-proxmox/fwprovider/structure" "github.com/bpg/terraform-provider-proxmox/fwprovider/structure"
"github.com/bpg/terraform-provider-proxmox/fwprovider/validators"
"github.com/bpg/terraform-provider-proxmox/proxmox" "github.com/bpg/terraform-provider-proxmox/proxmox"
haresources "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/resources" haresources "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/resources"
proxmoxtypes "github.com/bpg/terraform-provider-proxmox/proxmox/types" 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.", Description: "The identifier of the Proxmox HA resource to read.",
Required: true, Required: true,
Validators: []validator.String{ Validators: []validator.String{
validators.HAResourceIDValidator(), resourceIDValidator(),
}, },
}, },
"type": schema.StringAttribute{ "type": schema.StringAttribute{
@ -112,7 +110,7 @@ func (d *haResourceDatasource) Configure(
// Read fetches the specified HA resource. // Read fetches the specified HA resource.
func (d *haResourceDatasource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { 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)...) resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
@ -140,6 +138,6 @@ func (d *haResourceDatasource) Read(ctx context.Context, req datasource.ReadRequ
return return
} }
data.importFromAPI(resource) data.ImportFromAPI(resource)
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
} }

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"context" "context"

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"fmt" "fmt"
@ -18,8 +18,8 @@ import (
hagroups "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/groups" hagroups "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/groups"
) )
// haGroupModel is the model used to represent a High Availability group. // GroupModel is the model used to represent a High Availability group.
type haGroupModel struct { type GroupModel struct {
ID types.String `tfsdk:"id"` // Identifier used by Terraform ID types.String `tfsdk:"id"` // Identifier used by Terraform
Group types.String `tfsdk:"group"` // HA group name Group types.String `tfsdk:"group"` // HA group name
Comment types.String `tfsdk:"comment"` // Comment, if present 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 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. // ImportFromAPI imports the contents of a HA group model from the API's response data.
func (m *haGroupModel) importFromAPI(group hagroups.HAGroupGetResponseData) diag.Diagnostics { func (m *GroupModel) ImportFromAPI(group hagroups.HAGroupGetResponseData) diag.Diagnostics {
m.Comment = types.StringPointerValue(group.Comment) m.Comment = types.StringPointerValue(group.Comment)
m.NoFailback = group.NoFailback.ToValue() m.NoFailback = group.NoFailback.ToValue()
m.Restricted = group.Restricted.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 // 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. // 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 var diags diag.Diagnostics
nodesIn := strings.Split(nodes, ",") nodesIn := strings.Split(nodes, ",")

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"fmt" "fmt"
@ -15,8 +15,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types"
) )
// haResourceModel maps the schema data for the High Availability resource data source. // ResourceModel maps the schema data for the High Availability resource data source.
type haResourceModel struct { type ResourceModel struct {
// The Terraform resource identifier // The Terraform resource identifier
ID types.String `tfsdk:"id"` ID types.String `tfsdk:"id"`
// The Proxmox HA resource identifier // The Proxmox HA resource identifier
@ -35,8 +35,8 @@ type haResourceModel struct {
MaxRestart types.Int64 `tfsdk:"max_restart"` MaxRestart types.Int64 `tfsdk:"max_restart"`
} }
// importFromAPI imports the contents of a HA resource model from the API's response data. // ImportFromAPI imports the contents of a HA resource model from the API's response data.
func (d *haResourceModel) importFromAPI(data *haresources.HAResourceGetResponseData) { func (d *ResourceModel) ImportFromAPI(data *haresources.HAResourceGetResponseData) {
d.ID = data.ID.ToValue() d.ID = data.ID.ToValue()
d.ResourceID = data.ID.ToValue() d.ResourceID = data.ID.ToValue()
d.Type = data.Type.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. // 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 var state proxmoxtypes.HAResourceState
if d.State.IsNull() { 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. // ToCreateRequest builds the request data structure for creating a new HA resource.
func (d *haResourceModel) toCreateRequest(resID proxmoxtypes.HAResourceID) *haresources.HAResourceCreateRequestBody { func (d *ResourceModel) ToCreateRequest(resID proxmoxtypes.HAResourceID) *haresources.HAResourceCreateRequestBody {
return &haresources.HAResourceCreateRequestBody{ return &haresources.HAResourceCreateRequestBody{
ID: resID, ID: resID,
Type: &resID.Type, 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. // ToUpdateRequest builds the request data structure for updating an existing HA resource.
func (d *haResourceModel) toUpdateRequest(state *haResourceModel) *haresources.HAResourceUpdateRequestBody { func (d *ResourceModel) ToUpdateRequest(state *ResourceModel) *haresources.HAResourceUpdateRequestBody {
var del []string var del []string
if d.Comment.IsNull() && !state.Comment.IsNull() { if d.Comment.IsNull() && !state.Comment.IsNull() {

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"context" "context"
@ -144,7 +144,7 @@ func (r *hagroupResource) Configure(
// Create creates a new HA group on the Proxmox cluster. // Create creates a new HA group on the Proxmox cluster.
func (r *hagroupResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { 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)...) 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. // Read reads a HA group definition from the Proxmox cluster.
func (r *hagroupResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { 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)...) 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. // Update updates a HA group definition on the Proxmox cluster.
func (r *hagroupResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { 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.Plan.Get(ctx, &data)...)
resp.Diagnostics.Append(req.State.Get(ctx, &state)...) 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. // Delete deletes a HA group definition.
func (r *hagroupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { 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)...) resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
@ -270,7 +270,7 @@ func (r *hagroupResource) ImportState(
resp *resource.ImportStateResponse, resp *resource.ImportStateResponse,
) { ) {
reqID := req.ID reqID := req.ID
data := haGroupModel{ data := GroupModel{
ID: types.StringValue(reqID), ID: types.StringValue(reqID),
Group: 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. // state accordingly. It is assumed that the `state`'s identifier is set.
func (r *hagroupResource) readBack( func (r *hagroupResource) readBack(
ctx context.Context, ctx context.Context,
data *haGroupModel, data *GroupModel,
respDiags *diag.Diagnostics, respDiags *diag.Diagnostics,
respState *tfsdk.State, 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 // read reads information about a HA group from the cluster. The group identifier must have been set in the
// `data`. // `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() name := data.Group.ValueString()
group, err := r.client.Get(ctx, name) 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 false, diags
} }
return true, data.importFromAPI(*group) return true, data.ImportFromAPI(*group)
} }
// groupNodesToString converts the map of group member nodes into a string. // groupNodesToString converts the map of group member nodes into a string.

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package ha
import ( import (
"context" "context"
@ -13,7 +13,6 @@ import (
"strings" "strings"
"github.com/bpg/terraform-provider-proxmox/fwprovider/structure" "github.com/bpg/terraform-provider-proxmox/fwprovider/structure"
"github.com/bpg/terraform-provider-proxmox/fwprovider/validators"
"github.com/bpg/terraform-provider-proxmox/proxmox" "github.com/bpg/terraform-provider-proxmox/proxmox"
haresources "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/resources" haresources "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/ha/resources"
proxmoxtypes "github.com/bpg/terraform-provider-proxmox/proxmox/types" proxmoxtypes "github.com/bpg/terraform-provider-proxmox/proxmox/types"
@ -74,7 +73,7 @@ func (r *haResourceResource) Schema(
Description: "The Proxmox HA resource identifier", Description: "The Proxmox HA resource identifier",
Required: true, Required: true,
Validators: []validator.String{ Validators: []validator.String{
validators.HAResourceIDValidator(), resourceIDValidator(),
}, },
}, },
"state": schema.StringAttribute{ "state": schema.StringAttribute{
@ -83,7 +82,7 @@ func (r *haResourceResource) Schema(
Computed: true, Computed: true,
Default: stringdefault.StaticString("started"), Default: stringdefault.StaticString("started"),
Validators: []validator.String{ Validators: []validator.String{
validators.HAResourceStateValidator(), resourceStateValidator(),
}, },
}, },
"type": schema.StringAttribute{ "type": schema.StringAttribute{
@ -91,7 +90,7 @@ func (r *haResourceResource) Schema(
Computed: true, Computed: true,
Optional: true, Optional: true,
Validators: []validator.String{ Validators: []validator.String{
validators.HAResourceTypeValidator(), resourceTypeValidator(),
}, },
PlanModifiers: []planmodifier.String{ PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(), stringplanmodifier.UseStateForUnknown(),
@ -158,7 +157,7 @@ func (r *haResourceResource) Configure(
// Create creates a new HA resource. // Create creates a new HA resource.
func (r *haResourceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { 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)...) resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
@ -176,7 +175,7 @@ func (r *haResourceResource) Create(ctx context.Context, req resource.CreateRequ
return return
} }
createRequest := data.toCreateRequest(resID) createRequest := data.ToCreateRequest(resID)
err = r.client.Create(ctx, createRequest) err = r.client.Create(ctx, createRequest)
if err != nil { if err != nil {
@ -199,7 +198,7 @@ func (r *haResourceResource) Update(
req resource.UpdateRequest, req resource.UpdateRequest,
resp *resource.UpdateResponse, resp *resource.UpdateResponse,
) { ) {
var data, state haResourceModel var data, state ResourceModel
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)
resp.Diagnostics.Append(req.State.Get(ctx, &state)...) resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
@ -218,7 +217,7 @@ func (r *haResourceResource) Update(
return return
} }
updateRequest := data.toUpdateRequest(&state) updateRequest := data.ToUpdateRequest(&state)
err = r.client.Update(ctx, resID, updateRequest) err = r.client.Update(ctx, resID, updateRequest)
if err == nil { if err == nil {
@ -238,7 +237,7 @@ func (r *haResourceResource) Delete(
req resource.DeleteRequest, req resource.DeleteRequest,
resp *resource.DeleteResponse, resp *resource.DeleteResponse,
) { ) {
var data haResourceModel var data ResourceModel
resp.Diagnostics.Append(req.State.Get(ctx, &data)...) resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
@ -282,7 +281,7 @@ func (r *haResourceResource) Read(
req resource.ReadRequest, req resource.ReadRequest,
resp *resource.ReadResponse, resp *resource.ReadResponse,
) { ) {
var data haResourceModel var data ResourceModel
resp.Diagnostics.Append(req.State.Get(ctx, &data)...) resp.Diagnostics.Append(req.State.Get(ctx, &data)...)
@ -309,7 +308,7 @@ func (r *haResourceResource) ImportState(
resp *resource.ImportStateResponse, resp *resource.ImportStateResponse,
) { ) {
reqID := req.ID reqID := req.ID
data := haResourceModel{ data := ResourceModel{
ID: types.StringValue(reqID), ID: types.StringValue(reqID),
ResourceID: 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 // 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. // 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 var diags diag.Diagnostics
resID, err := proxmoxtypes.ParseHAResourceID(data.ID.ValueString()) resID, err := proxmoxtypes.ParseHAResourceID(data.ID.ValueString())
@ -340,7 +339,7 @@ func (r *haResourceResource) read(ctx context.Context, data *haResourceModel) (b
return false, diags return false, diags
} }
data.importFromAPI(res) data.ImportFromAPI(res)
return true, nil 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. // state accordingly. It is assumed that the `state`'s identifier is set.
func (r *haResourceResource) readBack( func (r *haResourceResource) readBack(
ctx context.Context, ctx context.Context,
data *haResourceModel, data *ResourceModel,
respDiags *diag.Diagnostics, respDiags *diag.Diagnostics,
respState *tfsdk.State, respState *tfsdk.State,
) { ) {

View 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")
}

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package network
import ( import (
"context" "context"

View File

@ -4,7 +4,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
package fwprovider package network
import ( import (
"context" "context"

View File

@ -25,6 +25,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog" "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"
"github.com/bpg/terraform-provider-proxmox/proxmox/api" "github.com/bpg/terraform-provider-proxmox/proxmox/api"
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes" "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 { func (p *proxmoxProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{ return []func() resource.Resource{
NewHAGroupResource, ha.NewHAGroupResource,
NewHAResourceResource, ha.NewHAResourceResource,
network.NewLinuxBridgeResource,
network.NewLinuxVLANResource,
NewClusterOptionsResource, NewClusterOptionsResource,
NewLinuxBridgeResource,
NewLinuxVLANResource,
NewDownloadFileResource, NewDownloadFileResource,
} }
} }
func (p *proxmoxProvider) DataSources(_ context.Context) []func() datasource.DataSource { func (p *proxmoxProvider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{ return []func() datasource.DataSource{
ha.NewHAGroupsDataSource,
ha.NewHAGroupDataSource,
ha.NewHAResourcesDataSource,
ha.NewHAResourceDataSource,
NewVersionDataSource, NewVersionDataSource,
NewHAGroupsDataSource,
NewHAGroupDataSource,
NewHAResourcesDataSource,
NewHAResourceDataSource,
} }
} }

View File

@ -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")
}