dsccommunity / dsccommunity/NetworkingDsc

NetAdapterBinding: Use of State & CurrentState Properties is non-idiomatic

Open
#486 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion
Dominant language
PowerShell
Stars
235
Forks
93
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you tried and the problem that is occurring

The schema for the NetAdapterBinding Resource includes both State (writable enum) and CurrentState (read-only enum) for the same information on the Resource:

https://github.com/dsccommunity/NetworkingDsc/blob/8df30e4d16b058fd02fd8305f99e0d14dba7ec81/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.schema.mof#L6-L7

This runs counter to the idiomatic design of a DSC Resource which presumes that any property of a Resource which is stateful and ensurable have a single writable property for it and that this property be returned in Get-TargetResource.

The current implementation of Get-TargetResource returns both State and CurrentState, though those values may be different because State returns the value of the parameter passed to that function (defaults to Enabled) while CurrentState returns the actual state of the adapter binding.

https://github.com/dsccommunity/NetworkingDsc/blob/8df30e4d16b058fd02fd8305f99e0d14dba7ec81/source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.psm1#L56-L77

Test-TargetResource does not utilize the Get-TargetResource function but instead reimplements the check and returns a boolean result.

Suggested solution to the issue

I suggest:

  1. Removing the CurrentState property entirely from the schema
  2. Removing the State parameter from Get-TargetResource
  3. Reworking Get-TargetResource to return the current state of the adapter binding for State
Version of the DSC module that was used ('dev' if using current dev branch)

Contributor guide

Open the contributing guide

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.

Research direction

Start with source/DSCResources/DSC_NetAdapterBinding/DSC_NetAdapterBinding.schema.mof and DSC_NetAdapterBinding.psm1, especially the schema properties and Get-TargetResource implementation linked in the issue. Done means CurrentState is removed, Get-TargetResource no longer accepts State, and State reports the adapter binding's current state while Test-TargetResource continues to return the correct result.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
devops, networking
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.