Skip to content

Commit 1571e5c

Browse files
Add more logging
1 parent fcbbc8c commit 1571e5c

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/code/FindPSResource.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
2424
public sealed class FindPSResource : PSCmdlet
2525
{
2626
#region Members
27-
27+
2828
private const string NameParameterSet = "NameParameterSet";
2929
private const string CommandNameParameterSet = "CommandNameParameterSet";
3030
private const string DscResourceNameParameterSet = "DscResourceNameParameterSet";
@@ -39,7 +39,7 @@ public sealed class FindPSResource : PSCmdlet
3939
/// Specifies name of a resource or resources to find. Accepts wild card characters.
4040
/// </summary>
4141
[SupportsWildcards]
42-
[Parameter(Position = 0,
42+
[Parameter(Position = 0,
4343
ValueFromPipeline = true,
4444
ValueFromPipelineByPropertyName = true,
4545
ParameterSetName = NameParameterSet)]
@@ -115,15 +115,20 @@ public sealed class FindPSResource : PSCmdlet
115115

116116
protected override void BeginProcessing()
117117
{
118+
WriteVerbose("Beginning Find-PSResource processing");
118119
_cancellationTokenSource = new CancellationTokenSource();
119120

120121
var networkCred = Credential != null ? new NetworkCredential(Credential.UserName, Credential.Password) : null;
121122

123+
WriteVerbose("Creating FindHelper instance");
124+
122125
_findHelper = new FindHelper(
123126
cancellationToken: _cancellationTokenSource.Token,
124127
cmdletPassedIn: this,
125128
networkCredential: networkCred);
126129

130+
WriteVerbose("FindHelper instance created successfully");
131+
127132
// Create a repository story (the PSResourceRepository.xml file) if it does not already exist
128133
// This is to create a better experience for those who have just installed v3 and want to get up and running quickly
129134
RepositorySettings.CheckRepositoryStore();
@@ -192,7 +197,7 @@ private void ProcessResourceNameParameterSet()
192197

193198
WriteDebug("Filtering package name(s) on wildcards");
194199
Name = Utils.ProcessNameWildcards(Name, removeWildcardEntries:false, out string[] errorMsgs, out bool nameContainsWildcard);
195-
200+
196201
foreach (string error in errorMsgs)
197202
{
198203
WriteError(new ErrorRecord(
@@ -208,7 +213,7 @@ private void ProcessResourceNameParameterSet()
208213
{
209214
WriteDebug("Package name(s) could not be resolved");
210215
return;
211-
}
216+
}
212217

213218
// determine/parse out Version param
214219
VersionType versionType = VersionType.VersionRange;
@@ -232,7 +237,7 @@ private void ProcessResourceNameParameterSet()
232237
"IncorrectVersionFormat",
233238
ErrorCategory.InvalidArgument,
234239
this));
235-
240+
236241
return;
237242
}
238243
}
@@ -289,7 +294,7 @@ private void ProcessCommandOrDscParameterSet(bool isSearchingForCommands)
289294
WriteDebug("Command or DSCResource name(s) could not be resolved");
290295
return;
291296
}
292-
297+
293298
foreach (PSCommandResourceInfo cmdPkg in _findHelper.FindByCommandOrDscResource(
294299
isSearchingForCommands: isSearchingForCommands,
295300
prerelease: Prerelease,
@@ -325,7 +330,7 @@ private void ProcessTags()
325330
WriteDebug("Tags(s) could not be resolved");
326331
return;
327332
}
328-
333+
329334
foreach (PSResourceInfo tagPkg in _findHelper.FindByTag(
330335
type: Type,
331336
prerelease: Prerelease,

test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
2424
Register-PSResourceRepository -Name $ACRRepoName -ApiVersion 'ContainerRegistry' -Uri $ACRRepoUri -Verbose
2525
Write-Verbose -Verbose "Registering ACR repository with Az authentication completed"
2626
Get-PSResourceRepository -Name $ACRRepoName -Verbose
27+
Write-Verbose -Verbose "Get-PSResourceRepository completed"
2728
}
2829
else
2930
{
@@ -38,7 +39,9 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
3839

3940
It "Find resource given specific Name, Version null" {
4041
# FindName()
41-
$res = Find-PSResource -Name $testModuleName -Repository $ACRRepoName
42+
Write-Verbose -Verbose "Finding resource with Name: $testModuleName"
43+
$res = Find-PSResource -Name $testModuleName -Repository $ACRRepoName -Verbose -Debug
44+
Write-Verbose -Verbose "Find-PSResource completed"
4245
$res.Name | Should -Be $testModuleName
4346
$res.Version | Should -Be "5.0.0"
4447
}

0 commit comments

Comments
 (0)