Skip to content

Conversation

bpg
Copy link
Owner

@bpg bpg commented Jul 14, 2025

Contributor's Note

Split up #1995 into smaller pieces.

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated acceptance tests in /fwprovider/tests for any new or updated resources / data sources.
  • I have ran make example to verify that the change works as expected.

Proof of Work

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #817

Summary by CodeRabbit

  • New Features
    • Added configurable variables for Proxmox node name and storage, allowing customization of these settings.
  • Improvements
    • Replaced hardcoded storage and node name references with variables for increased flexibility.
  • Removals
    • Removed the resource for downloading the Debian ISO image.

Co-authored-by: MacherelR <[email protected]>
Signed-off-by: Pavel Boldyrev <[email protected]>
Signed-off-by: MacherelR <[email protected]>
Signed-off-by: Pavel Boldyrev <[email protected]>
@bpg bpg force-pushed the tests-cleanup branch from d8495b1 to af6fcb6 Compare July 14, 2025 23:42
@bpg bpg enabled auto-merge (squash) July 14, 2025 23:49
Copy link

coderabbitai bot commented Jul 14, 2025

## Walkthrough

The changes introduce two new variables for Proxmox node name and storage, replacing hardcoded values in multiple Terraform resources to use these variables instead. Additionally, a resource for downloading a Debian ISO image is removed, and references to image resources are updated for consistency.

## Changes

| Files/Paths                                                                | Change Summary                                                                                                  |
|----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| example/resource_virtual_environment_container.tf, example/resource_virtual_environment_vm.tf | Replaced hardcoded "local-lvm" storage references with `var.virtual_environment_storage`; updated disk/image references. |
| example/resource_virtual_environment_download_file.tf                      | Replaced hardcoded node name "pve" with `var.virtual_environment_node_name`; removed Debian ISO image resource.  |
| example/variables.tf                                                       | Added variables: `virtual_environment_node_name` and `virtual_environment_storage` with defaults and descriptions. |

## Possibly related PRs

- bpg/terraform-provider-proxmox#1883: Simplifies example datastore references by consolidating outputs and replacing dynamic indexing with static strings; related through datastore reference modifications.

## Suggested labels

`size/S`
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tests-cleanup

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@bpg
Copy link
Owner Author

bpg commented Jul 14, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Jul 14, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bpg
Copy link
Owner Author

bpg commented Jul 14, 2025

@coderabbitai full review

Copy link

coderabbitai bot commented Jul 14, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
example/variables.tf (1)

16-26: Add validation blocks for the newly-introduced variables

The defaults work, but nothing prevents a caller from passing an empty / malformed node or storage name. A tiny validation guard would fail fast and surface the problem during terraform validate, instead of at apply-time on the Proxmox side.

 variable "virtual_environment_node_name" {
   description = "Name of the Proxmox node"
   type        = string
   default     = "pve"
+
+  validation {
+    condition     = can(regex("^[a-zA-Z0-9._-]+$", var.virtual_environment_node_name))
+    error_message = "Node name may only contain letters, numbers, dots, underscores and dashes."
+  }
 }
 
 variable "virtual_environment_storage" {
   description = "Name of the Proxmox storage"
   type        = string
   default     = "local-lvm"
+
+  validation {
+    condition     = can(regex("^[a-zA-Z0-9._-]+$", var.virtual_environment_storage))
+    error_message = "Storage name may only contain letters, numbers, dots, underscores and dashes."
+  }
 }
example/resource_virtual_environment_container.tf (1)

68-70: Minor: mirror the template changes in the clone block?

proxmox_virtual_environment_container.example’s mount_point block still hard-codes the bind-mount path, which is fine, but if you ever add more disks here you might want to reuse var.virtual_environment_storage for consistency the same way you did in the template resource.

example/resource_virtual_environment_download_file.tf (1)

5-11: Node name made configurable – great; storage still hard-coded

The switch to var.virtual_environment_node_name removes the last reference to "pve" – nice.
For parity with other changes, you might also expose datastore_id as a variable (many installations don’t have the default local directory storage enabled).

A minimal tweak:

-  datastore_id        = "local"
+  datastore_id        = var.virtual_environment_download_datastore

(where the new variable could default to "local").

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9fcd6b and af6fcb6.

📒 Files selected for processing (4)
  • example/resource_virtual_environment_container.tf (2 hunks)
  • example/resource_virtual_environment_download_file.tf (2 hunks)
  • example/resource_virtual_environment_vm.tf (2 hunks)
  • example/variables.tf (1 hunks)
🔇 Additional comments (3)
example/resource_virtual_environment_container.tf (1)

6-15: Good move to parameterise storage-specific fields

Switching both disk.datastore_id and mount_point.volume to var.virtual_environment_storage removes the last hard-coded "local-lvm" dependency and keeps the example self-contained.

example/resource_virtual_environment_vm.tf (2)

2-3: Storage abstraction applied consistently – nice

Replacing the literal "local-lvm" in locals { datastore_id = … } aligns the VM stack with the new variable.


48-56: Cross-datastore import may surprise users

The QCOW2 image is downloaded to the fixed datastore_id = "local" (see download_file.tf), yet the disks that import it are created on var.virtual_environment_storage (default "local-lvm"). Proxmox can copy between stores, but on clusters without a local dir storage or when virtual_environment_storage is also local, the import path might break.

Consider parameterising the download datastore as well, or at least document the expectation:

-  datastore_id        = "local"
+  datastore_id        = var.virtual_environment_download_datastore # new variable with default "local"

or add a note in README/examples.

Also applies to: 232-236

@bpg bpg merged commit 09e3cd6 into main Jul 14, 2025
8 checks passed
@bpg bpg deleted the tests-cleanup branch July 14, 2025 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant