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
17 changes: 16 additions & 1 deletion src/code/PSResourceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"],
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' {
Expand Down