Skip to content

Fix DSC checks for local repository paths - #2081

Open
Dimitriy Leontev (dleontev) wants to merge 2 commits into
PowerShell:masterfrom
dleontev:fix/dsc-local-repository-uri-2055
Open

Dimitriy Leontev (dleontev) wants to merge 2 commits into
PowerShell:masterfrom
dleontev:fix/dsc-local-repository-uri-2055

Conversation

@dleontev

Copy link
Copy Markdown

PR Summary

Add a native test operation to the DSC Repository resource. Compare absolute local paths and file URIs in the same canonical form so a second dsc config set skips a repository that already matches. Report the differing properties when the URI or another configured property actually changes.

Fixes #2055.

PR Context

Registering a path like C:\Repo stores a URI like file:///C:/Repo. DSC's synthetic test compares the strings and treats the repository as out of state. The native test returns the actual state and the properties that differ. Exported configurations omit the read-only DSC test status.

The new repository lifecycle test failed on upstream and passed with the patch. The Release build passed, followed by 12 Pester repository and schema tests on DSC 3.3.0 and 13 CLI checks each on DSC 3.2.0 and 3.3.0. The CLI checks confirmed that a second apply skips the repository-store write and that a different path still updates the registration. Validation ran on PowerShell 7.6.5 for Windows. PSScriptAnalyzer reported no new findings.

Codex assisted with the implementation and validation.

PR Checklist

  • The title uses the imperative mood.
  • The summary and context explain the change.
  • Changed PowerShell files have the repository copyright and MIT license headers.
  • The patch is ready for review.
  • Existing configuration syntax is supported.
  • The patch restores expected repeat-apply behavior and includes a regression test.
  • The DSC client contract uses the documented native test response and read-only status property.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Repository drift tests omit independent changes to trusted, priority, and repositoryType, leaving unverified whether DSC detects those differences and converges rather than silently skipping updates.

1 open issue
What changed in this PR

Adds native DSC testing for the Repository resource to address #2055, allowing equivalent local paths and file URIs to be recognized as the same repository.

Changes:

  • Compare configured properties with actual repository state and report differences.
  • Add read-only test status while excluding it from exports.
  • Add regression coverage for repeated local-path applies and URI changes.
File Description
test/​DscResource/​PSResourceGetDSCResource.Tests.ps1 Adds local repository lifecycle and export-status assertions.
src/​dsc/​repository.dsc.resource.json Declares the native test operation and read-only status property.
src/​dsc/​psresourceget.ps1 Implements repository comparison, shared retrieval, and export serialization.

Review effort: Balanced

Comment thread src/dsc/psresourceget.ps1 Resolved
Add independent cases for trust, priority and repository type.

Verify exact drift properties, applied values and convergence.

This branch has not been deployed

No deployments
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.

(dsc): Repository with a local path uri is never in desired state

2 participants