From 5124950991ef94311cdc1710050b7b6ae7786bb0 Mon Sep 17 00:00:00 2001 From: anamnavi Date: Sun, 24 Aug 2025 16:29:21 -0400 Subject: [PATCH 1/4] retrieve Includes package metadata for ContainerRegistry server --- src/code/PSResourceInfo.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/code/PSResourceInfo.cs b/src/code/PSResourceInfo.cs index 6a07eb451..cd04af310 100644 --- a/src/code/PSResourceInfo.cs +++ b/src/code/PSResourceInfo.cs @@ -1082,6 +1082,15 @@ public static bool TryConvertFromContainerRegistryJson( { "NormalizedVersion", metadata["NormalizedVersion"].ToString() } }; + var typeInfo = 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"], From 85176846e1a2a230f76fa625fa7d3af774f17c64 Mon Sep 17 00:00:00 2001 From: anamnavi Date: Sun, 24 Aug 2025 16:45:46 -0400 Subject: [PATCH 2/4] add test --- .../FindPSResourceContainerRegistryServer.Tests.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) 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' { From c888a95554a6d880dafece29b821e649f0c38e87 Mon Sep 17 00:00:00 2001 From: anamnavi Date: Mon, 25 Aug 2025 13:27:41 -0400 Subject: [PATCH 3/4] add error handling for tags being null to return default cmdlets, cmds, dscresource arrays so default ResourceIncludes is created --- src/code/PSResourceInfo.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/code/PSResourceInfo.cs b/src/code/PSResourceInfo.cs index cd04af310..768cf92cf 100644 --- a/src/code/PSResourceInfo.cs +++ b/src/code/PSResourceInfo.cs @@ -1082,7 +1082,7 @@ public static bool TryConvertFromContainerRegistryJson( { "NormalizedVersion", metadata["NormalizedVersion"].ToString() } }; - var typeInfo = ParseHttpMetadataType(metadata["Tags"] as string[], out ArrayList commandNames, out ArrayList cmdletNames, out ArrayList dscResourceNames); + 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) }, @@ -1708,16 +1708,22 @@ private static ResourceType ParseHttpMetadataType( out ArrayList dscResourceNames) { // possible type combinations: - // M, C - // M, D - // M - // S + // M, C + // M, D + // M + // S commandNames = new ArrayList(); cmdletNames = new ArrayList(); dscResourceNames = new ArrayList(); ResourceType pkgType = ResourceType.Module; + + if (tags == null) + { + return pkgType; + } + foreach (string tag in tags) { if (String.Equals(tag, "PSScript", StringComparison.InvariantCultureIgnoreCase)) From 43a516d2e5afca941a33164e07a071953960dcb1 Mon Sep 17 00:00:00 2001 From: anamnavi Date: Mon, 25 Aug 2025 14:59:27 -0400 Subject: [PATCH 4/4] remove extra space added --- src/code/PSResourceInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/code/PSResourceInfo.cs b/src/code/PSResourceInfo.cs index 768cf92cf..0bc651cf5 100644 --- a/src/code/PSResourceInfo.cs +++ b/src/code/PSResourceInfo.cs @@ -1708,10 +1708,10 @@ private static ResourceType ParseHttpMetadataType( out ArrayList dscResourceNames) { // possible type combinations: - // M, C - // M, D - // M - // S + // M, C + // M, D + // M + // S commandNames = new ArrayList(); cmdletNames = new ArrayList();