generated from hashicorp/packer-plugin-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common: use name for field access with reflect
Accessing the fields of a structure through reflection is possible through several means, namely by index, or by name. Index-based access can be relevant, but is rather susceptible to reordering changes later in the life of the product, and given that it occurs at runtime only, we lose the possibility to statically detect those changes. Name-based access is slightly more robust, as we are avoiding issues like new fields changing the access, and the named fields generally change only in case of a refactor, which is rarer. Besides named accesses are somewhat self-documentational, and refect better on what we're trying to achieve in this code. Therefore, we change how the reflection accesses happen for generateProxmoxDisks, defaulting on named-based accesses instead of index-based ones for filling in the disks.
- Loading branch information
1 parent
34a6751
commit 581f739
Showing
2 changed files
with
164 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters