Skip to content

Conversation

@tgauth
Copy link
Collaborator

@tgauth tgauth commented Nov 19, 2025

PR Summary

  • note: to minimize PR size this is only intended to support: clobber: true and regular keyword (no objects/arrays yet)
  • general flow of set command: create temp file based on input, validate temp file using sshd -T, back-up any existing sshd_config file (only if it is not already managed by this resource), then update/create sshd_config file
  • add Pester tests

@tgauth tgauth requested a review from Copilot November 19, 2025 21:51
Copilot finished reviewing on behalf of tgauth November 19, 2025 21:57
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 implements the set command functionality for the sshdconfig resource, focusing on support for clobber: true mode with regular (non-repeatable, non-multi-arg) SSH configuration keywords. The implementation includes comprehensive validation using sshd -T, automatic backup of existing non-DSC-managed configurations, and integration of the -s (setting) parameter to distinguish between sshd_config and windows-global settings.

Key Changes

  • Added set_sshd_config function that creates temporary config files, validates them with sshd -T, backs up existing configs if not DSC-managed, and writes the new configuration
  • Refactored filepath handling from String to PathBuf throughout the codebase for better type safety
  • Added comprehensive Pester tests covering valid configurations, backup creation, DSC-managed file detection, and error handling scenarios

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
resources/sshdconfig/tests/sshdconfig.set.tests.ps1 New comprehensive test suite for sshd_config set operations, testing valid configs, backup behavior, and error cases
resources/sshdconfig/tests/defaultshell.tests.ps1 Updated all set command calls to include -s windows-global flag; corrected test name for empty string handling
resources/sshdconfig/sshd-windows.dsc.resource.json Added -s windows-global arguments to set command configuration
resources/sshdconfig/src/util.rs Added get_default_sshd_config_path helper, refactored to use PathBuf, added get_bool_or_default helper for cleaner boolean extraction
resources/sshdconfig/src/set.rs Implemented set_sshd_config function with temp file validation, backup logic, and DSC header detection; updated set_default_shell signature
resources/sshdconfig/src/metadata.rs Added constants for DSC header and default config paths for both Unix and Windows
resources/sshdconfig/src/main.rs Updated set command to pass setting parameter to invoke_set
resources/sshdconfig/src/inputs.rs Added clobber field to CommandInfo; changed filepath types from String to PathBuf
resources/sshdconfig/src/args.rs Added required setting parameter to Set command with hidden flag
resources/sshdconfig/locales/en-us.toml Added new localization strings for set operations, debug messages, and error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tgauth tgauth requested a review from SteveL-MSFT November 19, 2025 22:05
Removed unsupported input message for sshd config.
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