diff --git a/fwprovider/hardwaremapping/datasource_pci.go b/fwprovider/hardwaremapping/datasource_pci.go index 11edf44e..bae1ae73 100644 --- a/fwprovider/hardwaremapping/datasource_pci.go +++ b/fwprovider/hardwaremapping/datasource_pci.go @@ -25,18 +25,18 @@ import ( // Ensure the implementation satisfies the required interfaces. var ( - _ datasource.DataSource = &dataSourcePCI{} - _ datasource.DataSourceWithConfigure = &dataSourcePCI{} + _ datasource.DataSource = &pciDataSource{} + _ datasource.DataSourceWithConfigure = &pciDataSource{} ) -// dataSourcePCI is the data source implementation for a PCI hardware mapping. -type dataSourcePCI struct { +// pciDataSource is the data source implementation for a PCI hardware mapping. +type pciDataSource struct { // client is the hardware mapping API client. client *mappings.Client } // Configure adds the provider-configured client to the data source. -func (d *dataSourcePCI) Configure( +func (d *pciDataSource) Configure( _ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, @@ -59,12 +59,12 @@ func (d *dataSourcePCI) Configure( } // Metadata returns the data source type name. -func (d *dataSourcePCI) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { +func (d *pciDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_hardware_mapping_pci" } // Read fetches the specified PCI hardware mapping from the Proxmox VE API. -func (d *dataSourcePCI) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +func (d *pciDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var hm modelPCI resp.Diagnostics.Append(req.Config.Get(ctx, &hm)...) @@ -93,7 +93,7 @@ func (d *dataSourcePCI) Read(ctx context.Context, req datasource.ReadRequest, re } // Schema defines the schema for the PCI hardware mapping. -func (d *dataSourcePCI) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (d *pciDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { comment := dataSourceSchemaBaseAttrComment comment.Optional = false comment.Computed = true @@ -162,8 +162,8 @@ func (d *dataSourcePCI) Schema(_ context.Context, _ datasource.SchemaRequest, re } } -// NewDataSourcePCI returns a new data source for a PCI hardware mapping. +// NewPCIDataSource returns a new data source for a PCI hardware mapping. // This is a helper function to simplify the provider implementation. -func NewDataSourcePCI() datasource.DataSource { - return &dataSourcePCI{} +func NewPCIDataSource() datasource.DataSource { + return &pciDataSource{} } diff --git a/fwprovider/hardwaremapping/datasource_usb.go b/fwprovider/hardwaremapping/datasource_usb.go index 86df0ce7..b3cf7719 100644 --- a/fwprovider/hardwaremapping/datasource_usb.go +++ b/fwprovider/hardwaremapping/datasource_usb.go @@ -25,17 +25,17 @@ import ( // Ensure the implementation satisfies the required interfaces. var ( - _ datasource.DataSource = &datasourceUSB{} - _ datasource.DataSourceWithConfigure = &datasourceUSB{} + _ datasource.DataSource = &usbDataSource{} + _ datasource.DataSourceWithConfigure = &usbDataSource{} ) -// datasourceUSB is the data source implementation for a USB hardware mapping. -type datasourceUSB struct { +// usbDataSource is the data source implementation for a USB hardware mapping. +type usbDataSource struct { client *mappings.Client } // Configure adds the provider-configured client to the data source. -func (d *datasourceUSB) Configure( +func (d *usbDataSource) Configure( _ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, @@ -58,12 +58,12 @@ func (d *datasourceUSB) Configure( } // Metadata returns the data source type name. -func (d *datasourceUSB) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { +func (d *usbDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_hardware_mapping_usb" } // Read fetches the specified USB hardware mapping from the Proxmox VE API. -func (d *datasourceUSB) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +func (d *usbDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var hm modelUSB resp.Diagnostics.Append(req.Config.Get(ctx, &hm)...) @@ -91,7 +91,7 @@ func (d *datasourceUSB) Read(ctx context.Context, req datasource.ReadRequest, re } // Schema defines the schema for the USB hardware mapping. -func (d *datasourceUSB) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (d *usbDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { comment := dataSourceSchemaBaseAttrComment comment.Optional = false comment.Computed = true @@ -144,8 +144,8 @@ func (d *datasourceUSB) Schema(_ context.Context, _ datasource.SchemaRequest, re } } -// NewDataSourceUSB returns a new data source for a USB hardware mapping. +// NewUSBDataSource returns a new data source for a USB hardware mapping. // This is a helper function to simplify the provider implementation. -func NewDataSourceUSB() datasource.DataSource { - return &datasourceUSB{} +func NewUSBDataSource() datasource.DataSource { + return &usbDataSource{} } diff --git a/fwprovider/hardwaremapping/resource_pci.go b/fwprovider/hardwaremapping/resource_pci.go index c04b450e..32b64e75 100644 --- a/fwprovider/hardwaremapping/resource_pci.go +++ b/fwprovider/hardwaremapping/resource_pci.go @@ -32,19 +32,19 @@ import ( // Ensure the resource implements the required interfaces. var ( - _ resource.Resource = &resourcePCI{} - _ resource.ResourceWithConfigure = &resourcePCI{} - _ resource.ResourceWithImportState = &resourcePCI{} + _ resource.Resource = &pciResource{} + _ resource.ResourceWithConfigure = &pciResource{} + _ resource.ResourceWithImportState = &pciResource{} ) -// resourcePCI contains the PCI hardware mapping resource's internal data. -type resourcePCI struct { +// pciResource contains the PCI hardware mapping resource's internal data. +type pciResource struct { // client is the hardware mapping API client. client mappings.Client } // read reads information about a PCI hardware mapping from the Proxmox VE API. -func (r *resourcePCI) read(ctx context.Context, hm *modelPCI) (bool, diag.Diagnostics) { +func (r *pciResource) read(ctx context.Context, hm *modelPCI) (bool, diag.Diagnostics) { var diags diag.Diagnostics hmName := hm.Name.ValueString() @@ -66,7 +66,7 @@ func (r *resourcePCI) read(ctx context.Context, hm *modelPCI) (bool, diag.Diagno // readBack reads information about a created or modified PCI hardware mapping from the Proxmox VE API then updates the // response state accordingly. // The Terraform resource identifier must have been set in the state before this method is called! -func (r *resourcePCI) readBack(ctx context.Context, hm *modelPCI, respDiags *diag.Diagnostics, respState *tfsdk.State) { +func (r *pciResource) readBack(ctx context.Context, hm *modelPCI, respDiags *diag.Diagnostics, respState *tfsdk.State) { found, diags := r.read(ctx, hm) respDiags.Append(diags...) @@ -84,7 +84,7 @@ func (r *resourcePCI) readBack(ctx context.Context, hm *modelPCI, respDiags *dia } // Configure adds the provider-configured client to the resource. -func (r *resourcePCI) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *pciResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -101,7 +101,7 @@ func (r *resourcePCI) Configure(_ context.Context, req resource.ConfigureRequest } // Create creates a new PCI hardware mapping. -func (r *resourcePCI) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *pciResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var hm modelPCI resp.Diagnostics.Append(req.Plan.Get(ctx, &hm)...) @@ -127,7 +127,7 @@ func (r *resourcePCI) Create(ctx context.Context, req resource.CreateRequest, re } // Delete deletes an existing PCI hardware mapping. -func (r *resourcePCI) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { +func (r *pciResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var hm modelPCI resp.Diagnostics.Append(req.State.Get(ctx, &hm)...) @@ -154,7 +154,7 @@ func (r *resourcePCI) Delete(ctx context.Context, req resource.DeleteRequest, re } // ImportState imports a PCI hardware mapping from the Proxmox VE API. -func (r *resourcePCI) ImportState( +func (r *pciResource) ImportState( ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, @@ -169,12 +169,12 @@ func (r *resourcePCI) ImportState( } // Metadata defines the name of the PCI hardware mapping. -func (r *resourcePCI) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *pciResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_hardware_mapping_pci" } // Read reads the PCI hardware mapping. -func (r *resourcePCI) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *pciResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var data modelPCI resp.Diagnostics.Append(req.State.Get(ctx, &data)...) @@ -196,7 +196,7 @@ func (r *resourcePCI) Read(ctx context.Context, req resource.ReadRequest, resp * } // Schema defines the schema for the PCI hardware mapping. -func (r *resourcePCI) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *pciResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { comment := resourceSchemaBaseAttrComment comment.Description = "The comment of this PCI hardware mapping." commentMap := comment @@ -272,7 +272,7 @@ func (r *resourcePCI) Schema(_ context.Context, _ resource.SchemaRequest, resp * } // Update updates an existing PCI hardware mapping. -func (r *resourcePCI) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *pciResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var hmCurrent, hmPlan modelPCI resp.Diagnostics.Append(req.Plan.Get(ctx, &hmPlan)...) @@ -301,8 +301,8 @@ func (r *resourcePCI) Update(ctx context.Context, req resource.UpdateRequest, re r.readBack(ctx, &hmPlan, &resp.Diagnostics, &resp.State) } -// NewResourcePCI returns a new resource for managing a PCI hardware mapping. +// NewPCIResource returns a new resource for managing a PCI hardware mapping. // This is a helper function to simplify the provider implementation. -func NewResourcePCI() resource.Resource { - return &resourcePCI{} +func NewPCIResource() resource.Resource { + return &pciResource{} } diff --git a/fwprovider/hardwaremapping/resource_usb.go b/fwprovider/hardwaremapping/resource_usb.go index 6546cc2c..eec1876e 100644 --- a/fwprovider/hardwaremapping/resource_usb.go +++ b/fwprovider/hardwaremapping/resource_usb.go @@ -31,19 +31,19 @@ import ( // Ensure the resource implements the required interfaces. var ( - _ resource.Resource = &resourceUSB{} - _ resource.ResourceWithConfigure = &resourceUSB{} - _ resource.ResourceWithImportState = &resourceUSB{} + _ resource.Resource = &usbResource{} + _ resource.ResourceWithConfigure = &usbResource{} + _ resource.ResourceWithImportState = &usbResource{} ) -// resourceUSB contains the USB hardware mapping resource's internal data. -type resourceUSB struct { +// usbResource contains the USB hardware mapping resource's internal data. +type usbResource struct { // client is the hardware mapping API client. client mappings.Client } // read reads information about a USB hardware mapping from the Proxmox VE API. -func (r *resourceUSB) read(ctx context.Context, hm *modelUSB) (bool, diag.Diagnostics) { +func (r *usbResource) read(ctx context.Context, hm *modelUSB) (bool, diag.Diagnostics) { var diags diag.Diagnostics hmName := hm.Name.ValueString() @@ -65,7 +65,7 @@ func (r *resourceUSB) read(ctx context.Context, hm *modelUSB) (bool, diag.Diagno // readBack reads information about a created or modified USB hardware mapping from the Proxmox VE API then updates the // response state accordingly. // The Terraform resource identifier must have been set in the state before this method is called! -func (r *resourceUSB) readBack(ctx context.Context, hm *modelUSB, respDiags *diag.Diagnostics, respState *tfsdk.State) { +func (r *usbResource) readBack(ctx context.Context, hm *modelUSB, respDiags *diag.Diagnostics, respState *tfsdk.State) { found, diags := r.read(ctx, hm) respDiags.Append(diags...) @@ -83,7 +83,7 @@ func (r *resourceUSB) readBack(ctx context.Context, hm *modelUSB, respDiags *dia } // Configure adds the provider-configured client to the resource. -func (r *resourceUSB) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *usbResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -101,7 +101,7 @@ func (r *resourceUSB) Configure(_ context.Context, req resource.ConfigureRequest } // Create creates a new USB hardware mapping. -func (r *resourceUSB) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *usbResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var hm modelUSB resp.Diagnostics.Append(req.Plan.Get(ctx, &hm)...) @@ -129,7 +129,7 @@ func (r *resourceUSB) Create(ctx context.Context, req resource.CreateRequest, re } // Delete deletes an existing USB hardware mapping. -func (r *resourceUSB) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { +func (r *usbResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { var hm modelUSB resp.Diagnostics.Append(req.State.Get(ctx, &hm)...) @@ -156,7 +156,7 @@ func (r *resourceUSB) Delete(ctx context.Context, req resource.DeleteRequest, re } // ImportState imports a USB hardware mapping from the Proxmox VE API. -func (r *resourceUSB) ImportState( +func (r *usbResource) ImportState( ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, @@ -171,14 +171,14 @@ func (r *resourceUSB) ImportState( } // Metadata defines the name of the USB hardware mapping. -func (r *resourceUSB) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { +func (r *usbResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_hardware_mapping_usb" } // Read reads the USB hardware mapping. // -func (r *resourceUSB) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *usbResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var data modelUSB resp.Diagnostics.Append(req.State.Get(ctx, &data)...) @@ -200,7 +200,7 @@ func (r *resourceUSB) Read(ctx context.Context, req resource.ReadRequest, resp * } // Schema defines the schema for the USB hardware mapping. -func (r *resourceUSB) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *usbResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { comment := resourceSchemaBaseAttrComment comment.Description = "The comment of this USB hardware mapping." commentMap := comment @@ -257,7 +257,7 @@ func (r *resourceUSB) Schema(_ context.Context, _ resource.SchemaRequest, resp * } // Update updates an existing USB hardware mapping. -func (r *resourceUSB) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *usbResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var hmCurrent, hmPlan modelUSB resp.Diagnostics.Append(req.Plan.Get(ctx, &hmPlan)...) @@ -283,8 +283,8 @@ func (r *resourceUSB) Update(ctx context.Context, req resource.UpdateRequest, re r.readBack(ctx, &hmPlan, &resp.Diagnostics, &resp.State) } -// NewResourceUSB returns a new resource for managing a USB hardware mapping. +// NewUSBResource returns a new resource for managing a USB hardware mapping. // This is a helper function to simplify the provider implementation. -func NewResourceUSB() resource.Resource { - return &resourceUSB{} +func NewUSBResource() resource.Resource { + return &usbResource{} } diff --git a/fwprovider/nodes/apt/datasource_repo.go b/fwprovider/nodes/apt/datasource_repo.go index a119bdfd..696f086d 100644 --- a/fwprovider/nodes/apt/datasource_repo.go +++ b/fwprovider/nodes/apt/datasource_repo.go @@ -23,18 +23,18 @@ import ( // Ensure the implementation satisfies the required interfaces. var ( - _ datasource.DataSource = &dataSourceRepo{} - _ datasource.DataSourceWithConfigure = &dataSourceRepo{} + _ datasource.DataSource = &repositoryDataSource{} + _ datasource.DataSourceWithConfigure = &repositoryDataSource{} ) -// dataSourceRepo is the data source implementation for an APT repository. -type dataSourceRepo struct { +// repositoryDataSource is the data source implementation for an APT repository. +type repositoryDataSource struct { // client is the Proxmox VE API client. client proxmox.Client } // Configure adds the provider-configured client to the data source. -func (d *dataSourceRepo) Configure( +func (d *repositoryDataSource) Configure( _ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, @@ -58,7 +58,7 @@ func (d *dataSourceRepo) Configure( } // Metadata returns the data source type name. -func (d *dataSourceRepo) Metadata( +func (d *repositoryDataSource) Metadata( _ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse, @@ -67,7 +67,11 @@ func (d *dataSourceRepo) Metadata( } // Read fetches the specified APT repository from the Proxmox VE API. -func (d *dataSourceRepo) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +func (d *repositoryDataSource) Read( + ctx context.Context, + req datasource.ReadRequest, + resp *datasource.ReadResponse, +) { var rp modelRepo resp.Diagnostics.Append(req.Config.Get(ctx, &rp)...) @@ -93,7 +97,7 @@ func (d *dataSourceRepo) Read(ctx context.Context, req datasource.ReadRequest, r } // Schema defines the schema for the APT repository. -func (d *dataSourceRepo) Schema( +func (d *repositoryDataSource) Schema( _ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse, @@ -159,8 +163,8 @@ func (d *dataSourceRepo) Schema( } } -// NewDataSourceRepo returns a new data source for an APT repository. +// NewRepositoryDataSource returns a new data source for an APT repository. // This is a helper function to simplify the provider implementation. -func NewDataSourceRepo() datasource.DataSource { - return &dataSourceRepo{} +func NewRepositoryDataSource() datasource.DataSource { + return &repositoryDataSource{} } diff --git a/fwprovider/nodes/apt/datasource_standard_repo.go b/fwprovider/nodes/apt/datasource_standard_repo.go index 7bfdf97e..d987cda4 100644 --- a/fwprovider/nodes/apt/datasource_standard_repo.go +++ b/fwprovider/nodes/apt/datasource_standard_repo.go @@ -22,18 +22,18 @@ import ( // Ensure the implementation satisfies the required interfaces. var ( - _ datasource.DataSource = &dataSourceStandardRepo{} - _ datasource.DataSourceWithConfigure = &dataSourceStandardRepo{} + _ datasource.DataSource = &standardRepositoryDataSource{} + _ datasource.DataSourceWithConfigure = &standardRepositoryDataSource{} ) -// dataSourceStandardRepo is the data source implementation for an APT standard repository. -type dataSourceStandardRepo struct { +// standardRepositoryDataSource is the data source implementation for an APT standard repository. +type standardRepositoryDataSource struct { // client is the Proxmox VE API client. client proxmox.Client } // Configure adds the provider-configured client to the data source. -func (d *dataSourceStandardRepo) Configure( +func (d *standardRepositoryDataSource) Configure( _ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse, @@ -57,7 +57,7 @@ func (d *dataSourceStandardRepo) Configure( } // Metadata returns the data source type name. -func (d *dataSourceStandardRepo) Metadata( +func (d *standardRepositoryDataSource) Metadata( _ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse, @@ -66,7 +66,11 @@ func (d *dataSourceStandardRepo) Metadata( } // Read fetches the specified APT standard repository from the Proxmox VE API. -func (d *dataSourceStandardRepo) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { +func (d *standardRepositoryDataSource) Read( + ctx context.Context, + req datasource.ReadRequest, + resp *datasource.ReadResponse, +) { var srp modelStandardRepo resp.Diagnostics.Append(req.Config.Get(ctx, &srp)...) @@ -88,7 +92,7 @@ func (d *dataSourceStandardRepo) Read(ctx context.Context, req datasource.ReadRe } // Schema defines the schema for the APT standard repository. -func (d *dataSourceStandardRepo) Schema( +func (d *standardRepositoryDataSource) Schema( _ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse, @@ -135,8 +139,8 @@ func (d *dataSourceStandardRepo) Schema( } } -// NewDataSourceStandardRepo returns a new data source for an APT standard repository. +// NewStandardRepositoryDataSource returns a new data source for an APT standard repository. // This is a helper function to simplify the provider implementation. -func NewDataSourceStandardRepo() datasource.DataSource { - return &dataSourceStandardRepo{} +func NewStandardRepositoryDataSource() datasource.DataSource { + return &standardRepositoryDataSource{} } diff --git a/fwprovider/nodes/apt/resource_repo.go b/fwprovider/nodes/apt/resource_repo.go index 9599e060..8d64f7a9 100644 --- a/fwprovider/nodes/apt/resource_repo.go +++ b/fwprovider/nodes/apt/resource_repo.go @@ -33,7 +33,7 @@ import ( ) const ( - // ResourceRepoIDPrefix is the prefix for the resource ID of resourceRepo. + // ResourceRepoIDPrefix is the prefix for the resource ID of repositoryResource. ResourceRepoIDPrefix = "apt_repository" // ResourceRepoActivationStatus is the default activation status for newly created or imported APT repositories. @@ -43,20 +43,20 @@ const ( // Ensure the resource implements the required interfaces. var ( - _ resource.Resource = &resourceRepo{} - _ resource.ResourceWithConfigure = &resourceRepo{} - _ resource.ResourceWithImportState = &resourceRepo{} + _ resource.Resource = &repositoryResource{} + _ resource.ResourceWithConfigure = &repositoryResource{} + _ resource.ResourceWithImportState = &repositoryResource{} ) -// resourceRepo contains the APT repository resource's internal data. -type resourceRepo struct { +// repositoryResource contains the APT repository resource's internal data. +type repositoryResource struct { // client is the Proxmox VE API client. client proxmox.Client } // read reads information about an APT repository from the Proxmox VE API. // Note that the name of the node must be set before this method is called! -func (r *resourceRepo) read(ctx context.Context, rp *modelRepo) (bool, diag.Diagnostics) { +func (r *repositoryResource) read(ctx context.Context, rp *modelRepo) (bool, diag.Diagnostics) { var diags diag.Diagnostics data, err := r.client.Node(rp.Node.ValueString()).APT().Repositories().Get(ctx) @@ -78,7 +78,7 @@ func (r *resourceRepo) read(ctx context.Context, rp *modelRepo) (bool, diag.Diag // readBack reads information about an APT repository from the Proxmox VE API and then updates the response state // accordingly. // Note that the Terraform resource identifier must be set in the state before this method is called! -func (r *resourceRepo) readBack(ctx context.Context, rp *modelRepo, diags *diag.Diagnostics, state *tfsdk.State) { +func (r *repositoryResource) readBack(ctx context.Context, rp *modelRepo, diags *diag.Diagnostics, state *tfsdk.State) { found, readDiags := r.read(ctx, rp) diags.Append(readDiags...) @@ -96,7 +96,11 @@ func (r *resourceRepo) readBack(ctx context.Context, rp *modelRepo, diags *diag. } // Configure adds the provider-configured client to the resource. -func (r *resourceRepo) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *repositoryResource) Configure( + _ context.Context, + req resource.ConfigureRequest, + resp *resource.ConfigureResponse, +) { if req.ProviderData == nil { return } @@ -119,7 +123,11 @@ func (r *resourceRepo) Configure(_ context.Context, req resource.ConfigureReques // to the repository lists. // The name of this method might be a bit confusing for this resource, but this is due to the way how the Proxmox VE API // works for APT repositories. -func (r *resourceRepo) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *repositoryResource) Create( + ctx context.Context, + req resource.CreateRequest, + resp *resource.CreateResponse, +) { var rp modelRepo resp.Diagnostics.Append(req.Plan.Get(ctx, &rp)...) @@ -152,11 +160,11 @@ func (r *resourceRepo) Create(ctx context.Context, req resource.CreateRequest, r // // [caveats]: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#caveats // [recommendations]: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#recommendations -func (r *resourceRepo) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse) { +func (r *repositoryResource) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse) { } // ImportState imports an APT repository from the Proxmox VE API. -func (r *resourceRepo) ImportState( +func (r *repositoryResource) ImportState( ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, @@ -206,7 +214,7 @@ func (r *resourceRepo) ImportState( } // Metadata defines the name of the APT repository resource. -func (r *resourceRepo) Metadata( +func (r *repositoryResource) Metadata( _ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse, @@ -215,7 +223,7 @@ func (r *resourceRepo) Metadata( } // Read reads the APT repository. -func (r *resourceRepo) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *repositoryResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { var rp modelRepo resp.Diagnostics.Append(req.State.Get(ctx, &rp)...) @@ -237,7 +245,7 @@ func (r *resourceRepo) Read(ctx context.Context, req resource.ReadRequest, resp } // Schema defines the schema for the APT repository. -func (r *resourceRepo) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *repositoryResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Manages an APT repository of a Proxmox VE node.", Attributes: map[string]schema.Attribute{ @@ -312,7 +320,7 @@ func (r *resourceRepo) Schema(_ context.Context, _ resource.SchemaRequest, resp } // Update updates an existing APT repository. -func (r *resourceRepo) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { +func (r *repositoryResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var rpPlan modelRepo resp.Diagnostics.Append(req.Plan.Get(ctx, &rpPlan)...) @@ -345,8 +353,8 @@ func (r *resourceRepo) Update(ctx context.Context, req resource.UpdateRequest, r r.readBack(ctx, &rpPlan, &resp.Diagnostics, &resp.State) } -// NewResourceRepo returns a new resource for managing an APT repository. +// NewRepositoryResource returns a new resource for managing an APT repository. // This is a helper function to simplify the provider implementation. -func NewResourceRepo() resource.Resource { - return &resourceRepo{} +func NewRepositoryResource() resource.Resource { + return &repositoryResource{} } diff --git a/fwprovider/nodes/apt/resource_standard_repo.go b/fwprovider/nodes/apt/resource_standard_repo.go index 99f8c204..68f9bf12 100644 --- a/fwprovider/nodes/apt/resource_standard_repo.go +++ b/fwprovider/nodes/apt/resource_standard_repo.go @@ -29,26 +29,26 @@ import ( ) const ( - // ResourceStandardRepoIDPrefix is the prefix for the resource ID of resourceStandardRepo. + // ResourceStandardRepoIDPrefix is the prefix for the resource ID of standardRepositoryResource. ResourceStandardRepoIDPrefix = "apt_standard_repository" ) // Ensure the resource implements the required interfaces. var ( - _ resource.Resource = &resourceStandardRepo{} - _ resource.ResourceWithConfigure = &resourceStandardRepo{} - _ resource.ResourceWithImportState = &resourceStandardRepo{} + _ resource.Resource = &standardRepositoryResource{} + _ resource.ResourceWithConfigure = &standardRepositoryResource{} + _ resource.ResourceWithImportState = &standardRepositoryResource{} ) -// resourceStandardRepo contains the APT standard repository resource's internal data. -type resourceStandardRepo struct { +// standardRepositoryResource contains the APT standard repository resource's internal data. +type standardRepositoryResource struct { // client is the Proxmox VE API client. client proxmox.Client } // read reads information about an APT standard repository from the Proxmox VE API. // Note that the name of the node must be set before this method is called! -func (r *resourceStandardRepo) read(ctx context.Context, srp *modelStandardRepo) (bool, diag.Diagnostics) { +func (r *standardRepositoryResource) read(ctx context.Context, srp *modelStandardRepo) (bool, diag.Diagnostics) { var diags diag.Diagnostics data, err := r.client.Node(srp.Node.ValueString()).APT().Repositories().Get(ctx) @@ -74,7 +74,7 @@ func (r *resourceStandardRepo) read(ctx context.Context, srp *modelStandardRepo) // readBack reads information about an APT standard repository from the Proxmox VE API and then updates the response // state accordingly. -func (r *resourceStandardRepo) readBack( +func (r *standardRepositoryResource) readBack( ctx context.Context, srp *modelStandardRepo, diags *diag.Diagnostics, @@ -97,7 +97,7 @@ func (r *resourceStandardRepo) readBack( } // Configure adds the provider-configured client to the resource. -func (r *resourceStandardRepo) Configure( +func (r *standardRepositoryResource) Configure( _ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse, @@ -123,7 +123,11 @@ func (r *resourceStandardRepo) Configure( // Create adds an APT standard repository to the repository source lists. // The name of this method might be a bit confusing for this resource, but this is due to the way how the Proxmox VE API // works for APT standard repositories. -func (r *resourceStandardRepo) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { +func (r *standardRepositoryResource) Create( + ctx context.Context, + req resource.CreateRequest, + resp *resource.CreateResponse, +) { var srp modelStandardRepo resp.Diagnostics.Append(req.Plan.Get(ctx, &srp)...) @@ -153,11 +157,11 @@ func (r *resourceStandardRepo) Create(ctx context.Context, req resource.CreateRe // // [caveats]: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#caveats // [recommendations]: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#recommendations -func (r *resourceStandardRepo) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse) { +func (r *standardRepositoryResource) Delete(_ context.Context, _ resource.DeleteRequest, _ *resource.DeleteResponse) { } // ImportState imports an APT standard repository from the Proxmox VE API. -func (r *resourceStandardRepo) ImportState( +func (r *standardRepositoryResource) ImportState( ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse, @@ -184,7 +188,7 @@ func (r *resourceStandardRepo) ImportState( } // Metadata defines the name of the APT standard repository resource. -func (r *resourceStandardRepo) Metadata( +func (r *standardRepositoryResource) Metadata( _ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse, @@ -193,7 +197,11 @@ func (r *resourceStandardRepo) Metadata( } // Read reads the APT standard repository. -func (r *resourceStandardRepo) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { +func (r *standardRepositoryResource) Read( + ctx context.Context, + req resource.ReadRequest, + resp *resource.ReadResponse, +) { var srp modelStandardRepo resp.Diagnostics.Append(req.State.Get(ctx, &srp)...) @@ -215,7 +223,11 @@ func (r *resourceStandardRepo) Read(ctx context.Context, req resource.ReadReques } // Schema defines the schema for the APT standard repository. -func (r *resourceStandardRepo) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *standardRepositoryResource) Schema( + _ context.Context, + _ resource.SchemaRequest, + resp *resource.SchemaResponse, +) { resp.Schema = schema.Schema{ Description: "Manages an APT standard repository of a Proxmox VE node.", Attributes: map[string]schema.Attribute{ @@ -276,11 +288,11 @@ func (r *resourceStandardRepo) Schema(_ context.Context, _ resource.SchemaReques // // [caveats]: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#caveats // [recommendations]: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#recommendations -func (r *resourceStandardRepo) Update(_ context.Context, _ resource.UpdateRequest, _ *resource.UpdateResponse) { +func (r *standardRepositoryResource) Update(_ context.Context, _ resource.UpdateRequest, _ *resource.UpdateResponse) { } -// NewResourceStandardRepo returns a new resource for managing an APT standard repository. +// NewStandardRepositoryResource returns a new resource for managing an APT standard repository. // This is a helper function to simplify the provider implementation. -func NewResourceStandardRepo() resource.Resource { - return &resourceStandardRepo{} +func NewStandardRepositoryResource() resource.Resource { + return &standardRepositoryResource{} } diff --git a/fwprovider/provider.go b/fwprovider/provider.go index f4a3b3c4..73c0201b 100644 --- a/fwprovider/provider.go +++ b/fwprovider/provider.go @@ -446,14 +446,14 @@ func (p *proxmoxProvider) Resources(_ context.Context) []func() resource.Resourc NewClusterOptionsResource, NewDownloadFileResource, acme.NewACMEAccountResource, - apt.NewResourceRepo, - apt.NewResourceStandardRepo, + apt.NewRepositoryResource, + apt.NewStandardRepositoryResource, access.NewACLResource, access.NewUserTokenResource, ha.NewHAGroupResource, ha.NewHAResourceResource, - hardwaremapping.NewResourcePCI, - hardwaremapping.NewResourceUSB, + hardwaremapping.NewPCIResource, + hardwaremapping.NewUSBResource, network.NewLinuxBridgeResource, network.NewLinuxVLANResource, vm.NewResource, @@ -465,15 +465,15 @@ func (p *proxmoxProvider) DataSources(_ context.Context) []func() datasource.Dat NewVersionDataSource, acme.NewACMEAccountsDataSource, acme.NewACMEAccountDataSource, - apt.NewDataSourceRepo, - apt.NewDataSourceStandardRepo, + apt.NewRepositoryDataSource, + apt.NewStandardRepositoryDataSource, ha.NewHAGroupDataSource, ha.NewHAGroupsDataSource, ha.NewHAResourceDataSource, ha.NewHAResourcesDataSource, hardwaremapping.NewDataSource, - hardwaremapping.NewDataSourcePCI, - hardwaremapping.NewDataSourceUSB, + hardwaremapping.NewPCIDataSource, + hardwaremapping.NewUSBDataSource, vm.NewDataSource, } }