Refactor PowerShell adapter module code for maintainability

Open
#1,452 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
42/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Quiet
Tech stack
powershell
Domain
tooling

Research direction

Start by locating the shared entrypoint script and the psDscAdapter and win_psDscAdapter modules, then map their duplicated implementations and existing acceptance tests. Define the shared functions, their parameters and return data, and the private-function unit-test scope before restructuring; done means both adapters use the common module and the new unit tests cover the extracted behavior.

Written by the indexing model from the issue text.

Description

Issue-Enhancement Needs Triage
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.
Dominant language
Rust
Stars
546
Forks
84
Avg merge
2d 9h
Merged PRs (30d)
25

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/DSC

All issues in PowerShell/DSC

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.