Skip to content

Commit 8128769

Browse files
authored
Merge pull request #1505 from Gijsreyn/gh-1504/main/allow-manifest-psdiscovery
Add manifest patterns for DSC resource discovery
2 parents 86b2e35 + 38da436 commit 8128769

4 files changed

Lines changed: 45 additions & 3 deletions

File tree

dsc/tests/dsc_extension_discover.tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Describe 'Discover extension tests' {
2626
if ($IsWindows) {
2727
$out.Count | Should -Be 3 -Because ($out | Out-String)
2828
$out[0].type | Should -BeExactly 'Microsoft.PowerShell/Discover'
29-
$out[0].version | Should -BeExactly '0.1.0'
29+
$out[0].version | Should -BeExactly '0.1.1'
3030
$out[0].capabilities | Should -BeExactly @('discover')
3131
$out[0].manifest | Should -Not -BeNullOrEmpty
3232
$out[1].type | Should -BeExactly 'Microsoft.Windows.Appx/Discover'
@@ -40,7 +40,7 @@ Describe 'Discover extension tests' {
4040
} else {
4141
$out.Count | Should -Be 2 -Because ($out | Out-String)
4242
$out[0].type | Should -BeExactly 'Microsoft.PowerShell/Discover'
43-
$out[0].version | Should -BeExactly '0.1.0'
43+
$out[0].version | Should -BeExactly '0.1.1'
4444
$out[0].capabilities | Should -BeExactly @('discover')
4545
$out[0].manifest | Should -Not -BeNullOrEmpty
4646
$out[1].type | Should -BeExactly 'Test/Discover'

extensions/powershell/powershell.discover.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ function Invoke-DscResourceDiscovery {
8181
'*.dsc.adaptedresource.json'
8282
'*.dsc.adaptedresource.yaml'
8383
'*.dsc.adaptedresource.yml'
84+
'*.dsc.manifests.json'
85+
'*.dsc.manifests.yaml'
86+
'*.dsc.manifests.yml'
8487
)
8588
$enumOptions = [System.IO.EnumerationOptions]@{ IgnoreInaccessible = $true; RecurseSubdirectories = $true }
8689
foreach ($pattern in $searchPatterns) {

extensions/powershell/powershell.discover.tests.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,39 @@ BeforeAll {
4747
$adaptedManifestPath = Join-Path $TestDrive "fake.dsc.adaptedresource.json"
4848
$fakeAdaptedManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $adaptedManifestPath
4949

50+
$fakeManifestList = @{
51+
'$schema' = "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json"
52+
resources = @(
53+
@{
54+
type = "Test/FakeListedResource"
55+
version = "0.1.0"
56+
kind = "resource"
57+
get = @{
58+
executable = "fakeListedResource"
59+
args = @(
60+
"get",
61+
@{
62+
jsonInputArg = "--input"
63+
mandatory = $true
64+
}
65+
)
66+
}
67+
}
68+
)
69+
adaptedResources = @(
70+
@{
71+
type = "Test/FakeListedAdaptedResource"
72+
kind = "resource"
73+
version = "0.1.0"
74+
requireAdapter = "Microsoft.Adapter/PowerShell"
75+
path = "FakeAdapted.psd1"
76+
}
77+
)
78+
}
79+
80+
$manifestListPath = Join-Path $TestDrive "fake.dsc.manifests.json"
81+
$fakeManifestList | ConvertTo-Json -Depth 10 | Set-Content -Path $manifestListPath
82+
5083
$fakePsd1Path = Join-Path $TestDrive "FakeAdapted.psd1"
5184
Set-Content -Path $fakePsd1Path -Value "@{ ModuleVersion = '0.1.0' }"
5285
$script:OldPSModulePath = $env:PSModulePath
@@ -162,4 +195,10 @@ Describe 'Tests for PowerShell resource discovery' {
162195
$out = & $script:discoverScript | ConvertFrom-Json
163196
$out.manifestPath | Should -Contain $adaptedManifestPath
164197
}
198+
199+
It 'Should discover *.dsc.manifests.* manifest-list files' {
200+
Remove-Item -Force -ErrorAction SilentlyContinue -Path $script:cacheFilePath
201+
$out = & $script:discoverScript | ConvertFrom-Json
202+
$out.manifestPath | Should -Contain $manifestListPath
203+
}
165204
}

extensions/powershell/powershell.dsc.extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json",
33
"type": "Microsoft.PowerShell/Discover",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"description": "Discovers DSC resources packaged in PowerShell 7 modules.",
66
"condition": "[not(equals(tryWhich('pwsh'), null()))]",
77
"discover": {

0 commit comments

Comments
 (0)