(dsc): `PSResourceList` ignores `scope` when resolving `_exist`
还没有人认领这个 Issue。
评估
调研方向
Start with ConvertInputToPSResource and GetPSResourceList, then reproduce the two scope cases from the issue using the shown PSResourceList configurations. Trace how omitted and explicit scope values are represented during resource matching and set operations. Done means explicit scope limits _exist, test, and set to that scope while omitted scope preserves the current any-scope behavior.
由索引模型根据 Issue 内容生成。
描述
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
As a user, I want scope to act as a filter when it is specified on a PSResourceList resource entry, so that _exist reflects whether the resource is present in that scope and set only touches that scope.
Today ConvertInputToPSResource defaults scope to CurrentUser when it is omitted, and GetPSResourceList collects installed resources from both scopes and matches on name and version only. The script cannot tell "the user asked for CurrentUser" from "the user said nothing", so scope is ignored when resolving the current state.
Two visible consequences:
-
getreports_exist: truewith a scope that differs from the desired one.resources: - name: PSResourceList scope test type: Microsoft.PowerShell.PSResourceGet/PSResourceList properties: repositoryName: PSGallery resources: - name: Pester version: '5.7.1' scope: CurrentUserWith Pester 5.7.1 installed only in
AllUsers,dsc resource getreturns:{ "name": "Pester", "version": "5.7.1", "scope": "AllUsers", "_exist": true }testthen reports_inDesiredState: falsebecause the scope differs, andsetreinstalls intoCurrentUser. Thegetoutput and thetestresult disagree about whether the resource exists. -
_exist: falsewith an explicit scope removes the resource from a different scope.resources: - name: PSResourceList scope test type: Microsoft.PowerShell.PSResourceGet/PSResourceList properties: repositoryName: PSGallery resources: - name: Pester scope: CurrentUser _exist: falseWith Pester installed only in
AllUsers,dsc resource setrunsUninstall-PSResource -Name Pester -Scope AllUsers. A configuration that only asked aboutCurrentUsermodifies the machine-wide scope and needs elevation to do so.
Expected behavior
When scope is specified, only resources installed in that scope are considered for _exist, test and set. When scope is omitted, the current behaviour (any scope) is kept.
Actual behavior
See the JSON snippet and the Uninstall-PSResource call above.
Error details
Environment data
Directory: C:\Program Files\PowerShell\Modules
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Binary 1.3.0 preview1 Microsoft.PowerShell.PSResourceGet Core,Desk {Compress-PSResource, Find-PSResource, …
Binary 1.2.0 preview5 Microsoft.PowerShell.PSResourceGet Core,Desk {Compress-PSResource, Find-PSResource, …
Directory: C:\program files\powershell\7\Modules
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Binary 1.2.0 Microsoft.PowerShell.PSResourceGet Core,Desk {Compress-PSResource, Find-PSResource, …
Key : PSVersion
Value : 7.6.6
Name : PSVersion
Key : PSEdition
Value : Core
Name : PSEdition
Key : GitCommitId
Value : 7.6.6
Name : GitCommitId
Key : OS
Value : Microsoft Windows 10.0.26200
Name : OS
Key : Platform
Value : Win32NT
Name : Platform
Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0…}
Name : PSCompatibleVersions
Key : PSRemotingProtocolVersion
Value : 2.4
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
Visuals
No response
- 主要语言
- C#
- 星标
- 576
- 派生
- 114
- 平均合并
- 23 小时 17 分钟
- 30 天内合并 PR
- 8
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PowerShell/PSResourceGet 的其他 Issue
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
PowerShell/PSResourceGet#2056 ·
-
feature_request
难度 2/5 1-3 小时 新手友好度 68/100
PowerShell/PSResourceGet#2013 · 3 条评论 ·
-
feature_request Needs-Triage
PowerShell/PSResourceGet#2057 · 已指派 1 人 ·
-
Needs-Triage
难度 3/5 1-2 天 新手友好度 68/100
PowerShell/PSResourceGet#2055 ·
-
(dsc): Export ignores `--input` filter for `Repository` and `PSResourceList` on DSC 3.3.* or above 未关闭Needs-Triage
难度 3/5 1-2 天 新手友好度 72/100
PowerShell/PSResourceGet#2053 ·
查看 PowerShell/PSResourceGet 的全部 Issue
相似的 Issue
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
-
t/bug
难度 2/5 1-3 小时 新手友好度 82/100
-
ci-failure-cause test-failure
难度 2/5 1-3 小时 新手友好度 82/100
-
area:auth FE mvp P3
难度 2/5 1-3 小时 新手友好度 88/100
klasolsson81/jobbliggaren#1788 ·