bpg / terraform-provider-proxmox

Terraform / OpenTofu Provider for Proxmox VE
https://registry.terraform.io/providers/bpg/proxmox
Mozilla Public License 2.0
892 stars 140 forks source link

feat(file): add support to set the file mode #1478

Closed svengreb closed 3 months ago

svengreb commented 3 months ago

Contributor's Note

Summary

733 implemented basic support for hook scripts, but the authors "did not manage to find time to work on" also including support to set the file mode. This small but important feature makes the use of the proxmox_virtual_environment_container.hook_script_file_id and virtual_environment_vm.hook_script_file_id attributes basically useless when not combined with the manual step of making the uploaded file executable (manually running chmod +x /path/to/script or using other methods, based on the storage backend). Using the hook_script_file_id on its own also causes all planned and applied changes in the same execution to not be saved in the state because the Proxmox VE API responses with a HTTP 500 error since the uploaded and assigned file is not executable.

This pull request implements the missing feature to set the file mode by adding a new file_mode attribute of type string where an octal-formatted value can be passed, e.g. 0700 or only 600. Note that the octal prefixes 0o and 0x are not supported to reduce the complexity, even though the used os.FileMode type supports it. Changing the file mode also causes the file to be replaced, which is true for almost any attribute in the proxmox_virtual_environment_file resource, to ensure that the file mode can also be changed after the initial creation.

Off-Topic @bpg Sorry for the silence in my last PR for the APT repository support! Life kicked in again and I had not time to resolve the review changes. I'll fix these in a new PR 😄

Community Note

Relates #570 Relates #733

svengreb commented 3 months ago

I travel for 2 days starting today, so I'll update it next week 😄

svengreb commented 3 months ago

@bpg I've completed all PR review changes. Let me know if there's anything else you'd like to adjust.