Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion extensions/powershell/powershell.discover.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ function Invoke-DscResourceDiscovery {
$manifests = $cache.Manifests
} else {
$manifests = $psPaths | ForEach-Object -Parallel {
$searchPatterns = @('*.dsc.resource.json', '*.dsc.resource.yaml', '*.dsc.resource.yml')
$searchPatterns = @(
'*.dsc.resource.json'
'*.dsc.resource.yaml'
'*.dsc.resource.yml'
'*.dsc.adaptedresource.json'
'*.dsc.adaptedresource.yaml'
'*.dsc.adaptedresource.yml'
)
$enumOptions = [System.IO.EnumerationOptions]@{ IgnoreInaccessible = $true; RecurseSubdirectories = $true }
foreach ($pattern in $searchPatterns) {
try {
Expand Down
35 changes: 35 additions & 0 deletions extensions/powershell/powershell.discover.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,35 @@ BeforeAll {

$manifestPath = Join-Path $TestDrive "fake.dsc.resource.json"
$fakeManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $manifestPath

$fakeAdaptedManifest = @{
'$schema' = "https://aka.ms/dsc/schemas/v3/bundled/adaptedresource/manifest.json"
type = "Test/FakeAdaptedResource"
kind = "resource"
version = "0.1.0"
capabilities = @("get", "set", "test")
description = "A fake adapted resource for regression testing."
requireAdapter = "Microsoft.Adapter/PowerShell"
path = "FakeAdapted.psd1"
schema = @{
embedded = @{
'$schema' = "https://json-schema.org/draft/2020-12/schema"
title = "Test/FakeAdaptedResource"
type = "object"
required = @("Name")
additionalProperties = $false
properties = @{
Name = @{ type = "string"; title = "Name"; description = "The name." }
}
}
}
}

$adaptedManifestPath = Join-Path $TestDrive "fake.dsc.adaptedresource.json"
$fakeAdaptedManifest | ConvertTo-Json -Depth 10 | Set-Content -Path $adaptedManifestPath

$fakePsd1Path = Join-Path $TestDrive "FakeAdapted.psd1"
Set-Content -Path $fakePsd1Path -Value "@{ ModuleVersion = '0.1.0' }"
$script:OldPSModulePath = $env:PSModulePath
$env:PSModulePath += [System.IO.Path]::PathSeparator + $TestDrive

Expand Down Expand Up @@ -127,4 +156,10 @@ Describe 'Tests for PowerShell resource discovery' {
$out = & $script:discoverScript | ConvertFrom-Json
$out.manifestPath | Should -Contain $manifestPath
}

It 'Should discover adapted resource manifest files' {
Remove-Item -Force -ErrorAction SilentlyContinue -Path $script:cacheFilePath
$out = & $script:discoverScript | ConvertFrom-Json
$out.manifestPath | Should -Contain $adaptedManifestPath
}
}
Loading