diff --git a/src/code/PSResourceInfo.cs b/src/code/PSResourceInfo.cs index 6a07eb451..0bc651cf5 100644 --- a/src/code/PSResourceInfo.cs +++ b/src/code/PSResourceInfo.cs @@ -1082,6 +1082,15 @@ public static bool TryConvertFromContainerRegistryJson( { "NormalizedVersion", metadata["NormalizedVersion"].ToString() } }; + ParseHttpMetadataType(metadata["Tags"] as string[], out ArrayList commandNames, out ArrayList cmdletNames, out ArrayList dscResourceNames); + var resourceHashtable = new Hashtable { + { nameof(PSResourceInfo.Includes.Command), new PSObject(commandNames) }, + { nameof(PSResourceInfo.Includes.Cmdlet), new PSObject(cmdletNames) }, + { nameof(PSResourceInfo.Includes.DscResource), new PSObject(dscResourceNames) } + }; + + var includes = new ResourceIncludes(resourceHashtable); + psGetInfo = new PSResourceInfo( additionalMetadata: additionalMetadataHashtable, author: metadata["Authors"] as String, @@ -1090,7 +1099,7 @@ public static bool TryConvertFromContainerRegistryJson( dependencies: metadata["Dependencies"] as Dependency[], description: metadata["Description"] as String, iconUri: null, - includes: null, + includes: includes, installedDate: null, installedLocation: null, isPrerelease: (bool)metadata["IsPrerelease"], @@ -1709,6 +1718,12 @@ private static ResourceType ParseHttpMetadataType( dscResourceNames = new ArrayList(); ResourceType pkgType = ResourceType.Module; + + if (tags == null) + { + return pkgType; + } + foreach (string tag in tags) { if (String.Equals(tag, "PSScript", StringComparison.InvariantCultureIgnoreCase)) diff --git a/test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1 b/test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1 index 5b2de751b..5f2ab7c32 100644 --- a/test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1 +++ b/test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1 @@ -12,6 +12,7 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' { $testModuleParentName = "test_parent_mod" $testModuleDependencyName = "test_dependency_mod" $testScriptName = "test-script" + $testModuleWithIncludes = "test-resourcewithincludes" $ACRRepoName = "ACRRepo" $ACRRepoUri = "https://psresourcegettest.azurecr.io" Get-NewPSResourceRepositoryFile @@ -262,6 +263,14 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' { $res.ReleaseNotes.Length | Should -Not -Be 0 $res.Tags.Length | Should -Be 5 } + + It "Should find resource and its associated Includes property" { + $res = Find-PSResource $testModuleWithIncludes -Repository $ACRRepoName + $res.Includes | Should -Not -BeNullOrEmpty + $res.Includes.Cmdlet | Should -Be "cmdlet1" + $res.Includes.Command | Should -Be "cmd1" + $res.Includes.DscResource | Should -Be "dsc1" + } } Describe 'Test Find-PSResource for MAR Repository' -tags 'CI' {