Skip to content

Refactor PowerShell adapter module code for maintainability #1452

@michaeltlombardi

Description

@michaeltlombardi

Summary of the new feature / enhancement

As a maintainer of DSC, I want to be able to readily navigate, understand, and update the PowerShell adapter code so that I can effectively contribute and troubleshoot the adapters.

Currently, the PowerShell adapter implementations share an entrypoint script but define two separate modules with shared implementations for functionality duplicated in both modules.

Additionally, the code organization is a bit difficult to follow and uses long complex statements repeatedly through the code which could potentially be encapsulated into small functions for easier testing and debugging.

Proposed technical implementation details (optional)

I propose that we:

  1. Extract common functions into a common_psDscAdapter module that both psDscAdapter and win_psDscAdapter can depend on.
  2. Standardize and at least minimally document the functions - their parameters, usage, and return data - for easier cognitive loading for maintainers. Even though this code won't be seen or used directly by end users, this reference information can help maintainers and new contributors.
  3. Examine the implementation for code that can be extracted into useful functions for the purposes of testing and making the overall implementation easier to read and follow.
  4. Add unit testing for the private functions to verify behavior and make maintenance easier and safer. We currently rely almost exclusively on acceptance tests that invoke the adapter code through DSC, which is necessarily slower and involves more levels of indirection.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions