Skip to content

Commit e8a5dd3

Browse files
committed
Remove non-relevant edge case
1 parent 8f5abad commit e8a5dd3

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

src/code/FindHelper.cs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public IEnumerable<PSResourceInfo> FindByResourceName(
105105
if (repository != null)
106106
{
107107
// Write error and disregard repository entries containing wildcards.
108-
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries:false, out string[] errorMsgs, out _repositoryNameContainsWildcard);
108+
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries: false, out string[] errorMsgs, out _repositoryNameContainsWildcard);
109109
foreach (string error in errorMsgs)
110110
{
111111
_cmdletPassedIn.WriteError(new ErrorRecord(
@@ -156,7 +156,7 @@ public IEnumerable<PSResourceInfo> FindByResourceName(
156156
if (repositoriesToSearch != null && repositoriesToSearch.Count == 0)
157157
{
158158
_cmdletPassedIn.ThrowTerminatingError(new ErrorRecord(
159-
new PSArgumentException ("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
159+
new PSArgumentException("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
160160
"RepositoryNameIsNotResolved",
161161
ErrorCategory.InvalidArgument,
162162
this));
@@ -222,7 +222,8 @@ public IEnumerable<PSResourceInfo> FindByResourceName(
222222
bool shouldReportErrorForEachRepo = !suppressErrors && !_repositoryNameContainsWildcard;
223223
foreach (PSResourceInfo currentPkg in SearchByNames(currentServer, currentResponseUtil, currentRepository, shouldReportErrorForEachRepo))
224224
{
225-
if (currentPkg == null) {
225+
if (currentPkg == null)
226+
{
226227
_cmdletPassedIn.WriteDebug("No packages returned from server");
227228
continue;
228229
}
@@ -244,7 +245,7 @@ public IEnumerable<PSResourceInfo> FindByResourceName(
244245
{
245246
// Scenarios: Find-PSResource -Name "pkg" -> write error only if pkg wasn't found in any registered repositories
246247
// Scenarios: Find-PSResource -Name "pkg" -Repository *Gallery -> write error if only if pkg wasn't found in any matching repositories.
247-
foreach(string pkgName in pkgsDiscovered)
248+
foreach (string pkgName in pkgsDiscovered)
248249
{
249250
var msg = repository == null ? $"Package '{pkgName}' could not be found in any registered repositories." :
250251
$"Package '{pkgName}' could not be found in registered repositories: '{string.Join(", ", repositoryNamesToSearch)}'.";
@@ -256,7 +257,7 @@ public IEnumerable<PSResourceInfo> FindByResourceName(
256257
this));
257258
}
258259
}
259-
}
260+
}
260261

261262
public IEnumerable<PSCommandResourceInfo> FindByCommandOrDscResource(
262263
bool isSearchingForCommands,
@@ -283,12 +284,12 @@ public IEnumerable<PSCommandResourceInfo> FindByCommandOrDscResource(
283284
// Error out if repository array of names to be searched contains wildcards.
284285
if (repository != null)
285286
{
286-
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries:false, out string[] errorMsgs, out _repositoryNameContainsWildcard);
287+
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries: false, out string[] errorMsgs, out _repositoryNameContainsWildcard);
287288

288289
if (string.Equals(repository[0], "*"))
289290
{
290291
_cmdletPassedIn.ThrowTerminatingError(new ErrorRecord(
291-
new PSArgumentException ("-Repository parameter does not support entry '*' with -CommandName and -DSCResourceName parameters."),
292+
new PSArgumentException("-Repository parameter does not support entry '*' with -CommandName and -DSCResourceName parameters."),
292293
"RepositoryDoesNotSupportWildcardEntryWithCmdOrDSCName",
293294
ErrorCategory.InvalidArgument,
294295
this));
@@ -337,7 +338,7 @@ public IEnumerable<PSCommandResourceInfo> FindByCommandOrDscResource(
337338
if (repositoriesToSearch != null && repositoriesToSearch.Count == 0)
338339
{
339340
_cmdletPassedIn.ThrowTerminatingError(new ErrorRecord(
340-
new PSArgumentException ("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
341+
new PSArgumentException("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
341342
"RepositoryNameIsNotResolved",
342343
ErrorCategory.InvalidArgument,
343344
this));
@@ -487,12 +488,12 @@ public IEnumerable<PSResourceInfo> FindByTag(
487488

488489
if (repository != null)
489490
{
490-
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries:false, out string[] errorMsgs, out _repositoryNameContainsWildcard);
491+
repository = Utils.ProcessNameWildcards(repository, removeWildcardEntries: false, out string[] errorMsgs, out _repositoryNameContainsWildcard);
491492

492493
if (string.Equals(repository[0], "*"))
493494
{
494495
_cmdletPassedIn.ThrowTerminatingError(new ErrorRecord(
495-
new PSArgumentException ("-Repository parameter does not support entry '*' with -Tag parameter."),
496+
new PSArgumentException("-Repository parameter does not support entry '*' with -Tag parameter."),
496497
"RepositoryDoesNotSupportWildcardEntryWithTag",
497498
ErrorCategory.InvalidArgument,
498499
this));
@@ -541,7 +542,7 @@ public IEnumerable<PSResourceInfo> FindByTag(
541542
if (repositoriesToSearch != null && repositoriesToSearch.Count == 0)
542543
{
543544
_cmdletPassedIn.ThrowTerminatingError(new ErrorRecord(
544-
new PSArgumentException ("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
545+
new PSArgumentException("Cannot resolve -Repository name. Run 'Get-PSResourceRepository' to view all registered repositories."),
545546
"RepositoryNameIsNotResolved",
546547
ErrorCategory.InvalidArgument,
547548
this));
@@ -635,7 +636,7 @@ public IEnumerable<PSResourceInfo> FindByTag(
635636
if (currentResult.exception != null && !currentResult.exception.Message.Equals(string.Empty))
636637
{
637638
errRecord = new ErrorRecord(
638-
new ResourceNotFoundException($"Tags '{String.Join(", ", _tag)}' could not be found" , currentResult.exception),
639+
new ResourceNotFoundException($"Tags '{String.Join(", ", _tag)}' could not be found", currentResult.exception),
639640
"FindTagConvertToPSResourceFailure",
640641
ErrorCategory.InvalidResult,
641642
this);
@@ -729,7 +730,7 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
729730
}
730731
}
731732
}
732-
else if(pkgName.Contains("*"))
733+
else if (pkgName.Contains("*"))
733734
{
734735
// Example: Find-PSResource -Name "Az*"
735736
// Example: Find-PSResource -Name "Az*" -Tag "Storage"
@@ -1000,12 +1001,6 @@ private IEnumerable<PSResourceInfo> SearchByNames(ServerApiCall currentServer, R
10001001
// After retrieving all packages find their dependencies
10011002
if (_includeDependencies)
10021003
{
1003-
if (currentServer.Repository.ApiVersion == PSRepositoryInfo.APIVersion.V3)
1004-
{
1005-
_cmdletPassedIn.WriteWarning("Installing dependencies is not currently supported for V3 server protocol repositories. The package will be installed without installing dependencies.");
1006-
yield break;
1007-
}
1008-
10091004
foreach (PSResourceInfo currentPkg in parentPkgs)
10101005
{
10111006
_cmdletPassedIn.WriteDebug($"Finding dependency packages for '{currentPkg.Name}'");
@@ -1102,7 +1097,8 @@ internal IEnumerable<PSResourceInfo> FindDependencyPackages(
11021097
{
11031098
_cmdletPassedIn.WriteVerbose(errRecord.Exception.Message);
11041099
}
1105-
else {
1100+
else
1101+
{
11061102
_cmdletPassedIn.WriteError(errRecord);
11071103
}
11081104
yield return null;
@@ -1164,7 +1160,8 @@ internal IEnumerable<PSResourceInfo> FindDependencyPackages(
11641160
{
11651161
_cmdletPassedIn.WriteVerbose(errRecord.Exception.Message);
11661162
}
1167-
else {
1163+
else
1164+
{
11681165
_cmdletPassedIn.WriteError(errRecord);
11691166
}
11701167
yield return null;
@@ -1199,7 +1196,8 @@ internal IEnumerable<PSResourceInfo> FindDependencyPackages(
11991196
// Check to see if version falls within version range
12001197
PSResourceInfo foundDep = currentResult.returnedObject;
12011198
string depVersionStr = $"{foundDep.Version}";
1202-
if (foundDep.IsPrerelease) {
1199+
if (foundDep.IsPrerelease)
1200+
{
12031201
depVersionStr += $"-{foundDep.Prerelease}";
12041202
}
12051203

@@ -1222,7 +1220,8 @@ internal IEnumerable<PSResourceInfo> FindDependencyPackages(
12221220
yield return depRes;
12231221
}
12241222
}
1225-
else {
1223+
else
1224+
{
12261225
List<string> pkgVersions = _packagesFound[depPkg.Name] as List<string>;
12271226
// _packagesFound has depPkg.name in it, but the version is not the same
12281227
if (!pkgVersions.Contains(FormatPkgVersionString(depPkg)))

0 commit comments

Comments
 (0)