Skip to content

Conversation

@tgauth
Copy link
Collaborator

@tgauth tgauth commented Jan 12, 2026

PR Summary

  • renames clobber to purge in various locations
  • adds sshdconfig set support with _purge: false for regular keywords
  • refactors some of the existing code in set_sshd_config() by creating write_config_map_to_text(), a helper function in util.rs
  • refactors writing the config file into 2 distinct parts: global config then match block(s), in order to simplify appending any added keyword(s) to the global config without needing to worry about insertion/order preservation
  • adds Pester tests for set scenarios, including if sshd_config file does not exist - the file creation will be implicit for _purge: true but will result in an error for _purge: false since there would be no existing settings to preserve

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _clobber to _purge across all files for clearer semantics
  • Implemented _purge=false support 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>
@tgauth tgauth requested a review from SteveL-MSFT January 12, 2026 19:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}
let key_contains = key.as_str();

if REPEATABLE_KEYWORDS.contains(&key_contains)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to use SshdConfigValue here to check those properties instead of the contains() checks?

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.

2 participants