Add sshdconfig _purge=false support for regular keywords#1348
Add sshdconfig _purge=false support for regular keywords#1348SteveL-MSFT merged 17 commits intoPowerShell:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR renames the _clobber parameter to _purge and implements support for _purge=false to preserve existing SSH daemon configuration settings while updating specific keywords. The implementation refactors configuration writing into a dedicated helper function and adds comprehensive test coverage for various set scenarios.
Changes:
- Renamed
_clobberto_purgeacross all files for clearer semantics - Implemented
_purge=falsesupport for regular (non-repeatable, non-multi-value) keywords - Refactored config file writing logic by extracting
write_config_map_to_text()helper function
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/sshdconfig/tests/sshdconfig.set.tests.ps1 | Updated all test cases to use _purge instead of _clobber; added comprehensive test cases for _purge=false scenarios including file existence checks, multi-value keyword restrictions, and various keyword update/preserve/remove operations |
| resources/sshdconfig/tests/sshdconfig.get.tests.ps1 | Added test case for handling non-existent config files |
| resources/sshdconfig/src/util.rs | Refactored format_sshd_value() to be private; changed format_value_as_string() to return String instead of Result; added write_config_map_to_text() helper function; added file existence check in invoke_sshd_config_validation(); updated error handling to use new FileNotFound error type |
| resources/sshdconfig/src/set.rs | Implemented _purge=false logic that retrieves existing config, validates keywords are not repeatable/multi-value, and merges changes; updated to use new write_config_map_to_text() helper |
| resources/sshdconfig/src/inputs.rs | Renamed clobber field to purge in CommandInfo struct |
| resources/sshdconfig/src/error.rs | Added new FileNotFound error variant |
| resources/sshdconfig/locales/en-us.toml | Updated error messages: removed clobberFalseUnsupported, added fileNotFound, purgeFalseRequiresExistingFile, and purgeFalseUnsupported |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Summary
clobbertopurgein various locationssetsupport with_purge: falsefor regular keywordsset_sshd_config()by creatingwrite_config_map_to_text(), a helper function in util.rs_purge: truebut will result in an error for_purge: falsesince there would be no existing settings to preserve