Skip to content

Commit 8f2f145

Browse files
Add debug statements
1 parent e2a238b commit 8f2f145

3 files changed

Lines changed: 29 additions & 18 deletions

File tree

src/code/RegisterPSResourceRepository.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class RegisterPSResourceRepository : PSCmdlet
102102
/// </summary>
103103
[Parameter]
104104
public SwitchParameter PassThru { get; set; }
105-
105+
106106
/// <summary>
107107
/// When specified, will overwrite information for any existing repository with the same name.
108108
/// </summary>
@@ -115,10 +115,14 @@ class RegisterPSResourceRepository : PSCmdlet
115115

116116
protected override void BeginProcessing()
117117
{
118+
WriteVerbose("In RegisterPSResourceRepository::BeginProcessing()");
118119
RepositorySettings.CheckRepositoryStore();
120+
WriteVerbose("Done RegisterPSResourceRepository::BeginProcessing()");
121+
119122
}
120123
protected override void ProcessRecord()
121124
{
125+
WriteVerbose("In RegisterPSResourceRepository::ProcessRecord()");
122126
List<PSRepositoryInfo> items = new List<PSRepositoryInfo>();
123127

124128
PSRepositoryInfo.APIVersion? repoApiVersion = null;
@@ -130,6 +134,7 @@ protected override void ProcessRecord()
130134
switch (ParameterSetName)
131135
{
132136
case NameParameterSet:
137+
WriteDebug("In RegisterPSResourceRepository::NameParameterSet");
133138
if (!Utils.TryCreateValidUri(uriString: Uri,
134139
cmdletPassedIn: this,
135140
uriResult: out _uri,
@@ -140,6 +145,7 @@ protected override void ProcessRecord()
140145

141146
try
142147
{
148+
WriteDebug($"Registering repository '{Name}' with uri '{_uri}'");
143149
items.Add(RepositorySettings.AddRepository(Name, _uri, Priority, Trusted, repoApiVersion, CredentialInfo, Force, this, out string errorMsg));
144150

145151
if (!string.IsNullOrEmpty(errorMsg))
@@ -177,6 +183,7 @@ protected override void ProcessRecord()
177183
break;
178184

179185
case RepositoriesParameterSet:
186+
WriteDebug("In RegisterPSResourceRepository::RepositoriesParameterSet");
180187
try
181188
{
182189
items = RepositoriesParameterSetHelper();
@@ -212,14 +219,14 @@ private PSRepositoryInfo PSGalleryParameterSetHelper(int repoPriority, bool repo
212219
WriteDebug("In RegisterPSResourceRepository::PSGalleryParameterSetHelper()");
213220
Uri psGalleryUri = new Uri(PSGalleryRepoUri);
214221
WriteDebug("Internal name and uri values for PSGallery are hardcoded and validated. Priority and trusted values, if passed in, also validated");
215-
var addedRepo = RepositorySettings.AddToRepositoryStore(PSGalleryRepoName,
216-
psGalleryUri,
217-
repoPriority,
218-
repoTrusted,
222+
var addedRepo = RepositorySettings.AddToRepositoryStore(PSGalleryRepoName,
223+
psGalleryUri,
224+
repoPriority,
225+
repoTrusted,
219226
apiVersion: null,
220-
repoCredentialInfo: null,
221-
Force,
222-
this,
227+
repoCredentialInfo: null,
228+
Force,
229+
this,
223230
out string errorMsg);
224231

225232
if (!string.IsNullOrEmpty(errorMsg))
@@ -313,7 +320,7 @@ private PSRepositoryInfo RepoValidationHelper(Hashtable repo)
313320
"NullUriForRepositoriesParameterSetRegistration",
314321
ErrorCategory.InvalidArgument,
315322
this));
316-
323+
317324
return null;
318325
}
319326

@@ -337,10 +344,10 @@ private PSRepositoryInfo RepoValidationHelper(Hashtable repo)
337344
return null;
338345
}
339346

340-
if (repo.ContainsKey("ApiVersion") &&
347+
if (repo.ContainsKey("ApiVersion") &&
341348
(repo["ApiVersion"] == null || String.IsNullOrEmpty(repo["ApiVersion"].ToString()) ||
342-
!(repo["ApiVersion"].ToString().Equals("Local", StringComparison.OrdinalIgnoreCase) || repo["ApiVersion"].ToString().Equals("V2", StringComparison.OrdinalIgnoreCase) ||
343-
repo["ApiVersion"].ToString().Equals("V3", StringComparison.OrdinalIgnoreCase) || repo["ApiVersion"].ToString().Equals("NugetServer", StringComparison.OrdinalIgnoreCase) ||
349+
!(repo["ApiVersion"].ToString().Equals("Local", StringComparison.OrdinalIgnoreCase) || repo["ApiVersion"].ToString().Equals("V2", StringComparison.OrdinalIgnoreCase) ||
350+
repo["ApiVersion"].ToString().Equals("V3", StringComparison.OrdinalIgnoreCase) || repo["ApiVersion"].ToString().Equals("NugetServer", StringComparison.OrdinalIgnoreCase) ||
344351
repo["ApiVersion"].ToString().Equals("Unknown", StringComparison.OrdinalIgnoreCase))))
345352
{
346353
WriteError(new ErrorRecord(

src/code/Utils.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ public static bool TryCreateValidUri(
429429
out Uri uriResult,
430430
out ErrorRecord errorRecord)
431431
{
432+
cmdletPassedIn.WriteVerbose($"Validating Uri: {uriString}");
433+
432434
errorRecord = null;
433435
if (Uri.TryCreate(uriString, UriKind.Absolute, out uriResult))
434436
{
@@ -1874,9 +1876,9 @@ public static Hashtable GetMetadataFromNuspec(string nuspecFilePath, PSCmdlet cm
18741876
catch (Exception e)
18751877
{
18761878
errorRecord = new ErrorRecord(
1877-
exception: e,
1878-
"GetHashtableForNuspecFailure",
1879-
ErrorCategory.ReadError,
1879+
exception: e,
1880+
"GetHashtableForNuspecFailure",
1881+
ErrorCategory.ReadError,
18801882
cmdletPassedIn);
18811883
}
18821884

@@ -1895,9 +1897,9 @@ public static XmlDocument LoadXmlDocument(string filePath, PSCmdlet cmdletPassed
18951897
catch (Exception e)
18961898
{
18971899
errRecord = new ErrorRecord(
1898-
exception: e,
1899-
"LoadXmlDocumentFailure",
1900-
ErrorCategory.ReadError,
1900+
exception: e,
1901+
"LoadXmlDocumentFailure",
1902+
ErrorCategory.ReadError,
19011903
cmdletPassedIn);
19021904
}
19031905

test/FindPSResourceTests/FindPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
2222
{
2323
Write-Verbose -Verbose "Using Az module for authentication"
2424
Register-PSResourceRepository -Name $ACRRepoName -ApiVersion 'ContainerRegistry' -Uri $ACRRepoUri -Verbose
25+
Write-Verbose -Verbose "Registering ACR repository with Az authentication completed"
26+
Get-PSResourceRepository
2527
}
2628
else
2729
{

0 commit comments

Comments
 (0)