PowershellFrameworkCollective / psframework

A module that provides tools for other modules and scripts
MIT License
424 stars 41 forks source link

Configuration: Support multiple files for automatic import #419

Closed FriedrichWeinmann closed 3 years ago

FriedrichWeinmann commented 4 years ago

As referenced in #417

Currently, each file-based location only supports a single file. This is on the one hand inconvenient for file-oriented users, that would prefer editing their config in files, rather than using the commands. On the other, it also makes it hard for a management-process to deploy config to a file-based location without replacing anything the users themselves might have defined.

Proposed Change:

In the config folders, do name based detection of any number of additional files, so long as they meet a specific pattern (to avoid collision with the module cache scenario/feature).

Extend Register-PSFConfig & Unregister-PSFConfig to support targeting the specific files. Example syntax:

# Register to default file
Register-PSFConfig -FullName MyModule.Setting1 -Scope FileUserShared

# Register to specific named file
Register-PSFConfig -FullName MyModule.Setting1 -Scope FileUserShared -Container MyModule

Additional considerations

FriedrichWeinmann commented 3 years ago

Implemented in 1.5.168 Docs pending, in the meantime a quick guidance: Store the additional json files in the same folder as the current folder. Name them to match this pattern: psf_config_*.json (e.g. "psf_config_mymodule.json") Then those files will too be picked up and applied. The default file will take precedence however in case of a conflict, to limit user confusion that interactively use Register-PSFConfig to set a setting at the same scope.