Skip to content

feat: allow generated files to have custom permissions set via YAML#163

Merged
cbrgm merged 3 commits into
mainfrom
add-permissions-feat
Jan 27, 2026
Merged

feat: allow generated files to have custom permissions set via YAML#163
cbrgm merged 3 commits into
mainfrom
add-permissions-feat

Conversation

@cbrgm

@cbrgm cbrgm commented Jan 27, 2026

Copy link
Copy Markdown
Owner

This pull request adds support for specifying file permissions (such as 0755 for executables) in the FileStructure configuration, allowing generated files to have custom permissions set via YAML. It introduces a new FileMode type to handle octal permissions, updates the file creation logic to respect these permissions, and provides comprehensive tests for the new functionality.

File permissions support and propagation:

  • Introduced a FileMode type for file permissions, supporting YAML unmarshaling from octal strings (e.g., "0755", "0644") or integers, and added a Permissions field to FileStructure to allow specifying file permissions per file. [1] [2]
  • Updated file creation and copying logic in cmd/structuresmith/app.go to apply the specified permissions when writing files, defaulting to 0644 if none are provided. [1] [2] [3]
  • Ensured that directory processing (processDirectory) propagates the Permissions field to all files within the directory.

YAML configuration and validation:

  • Updated the example anvil.yml to demonstrate how to specify permissions for scripts, making them executable by default.
  • Added and extended tests in config_test.go to validate correct parsing, stringification, and propagation of permissions in YAML, including handling invalid values. [1] [2]

Testing and correctness:

  • Added extensive tests in app_test.go to verify that files are created with the correct permissions, that templated and copied files respect permissions, and that permission propagation and merging logic work as expected.

@cbrgm
cbrgm enabled auto-merge January 27, 2026 15:40
@cbrgm
cbrgm merged commit 192224f into main Jan 27, 2026
13 checks passed
@cbrgm
cbrgm deleted the add-permissions-feat branch January 27, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant