@@ -43,7 +43,7 @@ internal class ContainerRegistryServerAPICalls : ServerApiCall
43
43
const string containerRegistryOAuthTokenUrlTemplate = "https://{0}/oauth2/token" ; // 0 - registry
44
44
const string containerRegistryManifestUrlTemplate = "https://{0}/v2/{1}/manifests/{2}" ; // 0 - registry, 1 - repo(modulename), 2 - tag(version)
45
45
const string containerRegistryBlobDownloadUrlTemplate = "https://{0}/v2/{1}/blobs/{2}" ; // 0 - registry, 1 - repo(modulename), 2 - layer digest
46
- const string containerRegistryFindImageVersionUrlTemplate = "https://{0}/acr/v1/ {1}/_tags{2} " ; // 0 - registry, 1 - repo(modulename), 2 - /tag(version )
46
+ const string containerRegistryFindImageVersionUrlTemplate = "https://{0}/v2/ {1}/tags/list " ; // 0 - registry, 1 - repo(modulename)
47
47
const string containerRegistryStartUploadTemplate = "https://{0}/v2/{1}/blobs/uploads/" ; // 0 - registry, 1 - packagename
48
48
const string containerRegistryEndUploadTemplate = "https://{0}{1}&digest=sha256:{2}" ; // 0 - registry, 1 - location, 2 - digest
49
49
@@ -413,6 +413,7 @@ internal string GetContainerRegistryAccessToken(out ErrorRecord errRecord)
413
413
else
414
414
{
415
415
_cmdletPassedIn . WriteVerbose ( "Repository is unauthenticated" ) ;
416
+ return null ;
416
417
}
417
418
}
418
419
@@ -572,27 +573,19 @@ internal async Task<HttpContent> GetContainerRegistryBlobAsync(string packageNam
572
573
/// </summary>
573
574
internal JObject FindContainerRegistryImageTags ( string packageName , string version , string containerRegistryAccessToken , out ErrorRecord errRecord )
574
575
{
575
- /* response returned looks something like:
576
- * "registry": "myregistry.azurecr.io"
577
- * "imageName": "hello-world"
578
- * "tags": [
579
- * {
580
- * ""name"": ""1.0.0"",
581
- * ""digest"": ""sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a"",
582
- * ""createdTime"": ""2023-12-23T18:06:48.9975733Z"",
583
- * ""lastUpdateTime"": ""2023-12-23T18:06:48.9975733Z"",
584
- * ""signed"": false,
585
- * ""changeableAttributes"": {
586
- * ""deleteEnabled"": true,
587
- * ""writeEnabled"": true,
588
- * ""readEnabled"": true,
589
- * ""listEnabled"": true
590
- * }
591
- * }]
592
- */
576
+ /*
577
+ {
578
+ "name": "<name>",
579
+ "tags": [
580
+ "<tag1>",
581
+ "<tag2>",
582
+ "<tag3>"
583
+ ]
584
+ }
585
+ */
593
586
_cmdletPassedIn . WriteDebug ( "In ContainerRegistryServerAPICalls::FindContainerRegistryImageTags()" ) ;
594
587
string resolvedVersion = string . Equals ( version , "*" , StringComparison . OrdinalIgnoreCase ) ? null : $ "/{ version } ";
595
- string findImageUrl = string . Format ( containerRegistryFindImageVersionUrlTemplate , Registry , packageName , resolvedVersion ) ;
588
+ string findImageUrl = string . Format ( containerRegistryFindImageVersionUrlTemplate , Registry , packageName ) ;
596
589
var defaultHeaders = GetDefaultHeaders ( containerRegistryAccessToken ) ;
597
590
return GetHttpResponseJObjectUsingDefaultHeaders ( findImageUrl , HttpMethod . Get , defaultHeaders , out errRecord ) ;
598
591
}
@@ -1664,51 +1657,36 @@ private Hashtable[] FindPackagesWithVersionHelper(string packageName, VersionTyp
1664
1657
1665
1658
foreach ( var pkgVersionTagInfo in allPkgVersions )
1666
1659
{
1667
- using ( JsonDocument pkgVersionEntry = JsonDocument . Parse ( pkgVersionTagInfo . ToString ( ) ) )
1660
+ string pkgVersionString = pkgVersionTagInfo . ToString ( ) ;
1661
+ // determine if the package version that is a repository tag is a valid NuGetVersion
1662
+ if ( ! NuGetVersion . TryParse ( pkgVersionString , out NuGetVersion pkgVersion ) )
1668
1663
{
1669
- JsonElement rootDom = pkgVersionEntry . RootElement ;
1670
- if ( ! rootDom . TryGetProperty ( "name" , out JsonElement pkgVersionElement ) )
1671
- {
1672
- errRecord = new ErrorRecord (
1673
- new InvalidOrEmptyResponse ( $ "Response does not contain version element ('name') for package '{ packageName } ' in '{ Repository . Name } '.") ,
1674
- "FindNameFailure" ,
1675
- ErrorCategory . InvalidResult ,
1676
- this ) ;
1677
-
1678
- return null ;
1679
- }
1680
-
1681
- string pkgVersionString = pkgVersionElement . ToString ( ) ;
1682
- // determine if the package version that is a repository tag is a valid NuGetVersion
1683
- if ( ! NuGetVersion . TryParse ( pkgVersionString , out NuGetVersion pkgVersion ) )
1684
- {
1685
- errRecord = new ErrorRecord (
1686
- new ArgumentException ( $ "Version { pkgVersionString } to be parsed from metadata is not a valid NuGet version.") ,
1687
- "FindNameFailure" ,
1688
- ErrorCategory . InvalidArgument ,
1689
- this ) ;
1664
+ errRecord = new ErrorRecord (
1665
+ new ArgumentException ( $ "Version { pkgVersionString } to be parsed from metadata is not a valid NuGet version.") ,
1666
+ "FindNameFailure" ,
1667
+ ErrorCategory . InvalidArgument ,
1668
+ this ) ;
1690
1669
1691
- return null ;
1692
- }
1670
+ return null ;
1671
+ }
1693
1672
1694
- _cmdletPassedIn . WriteDebug ( $ "'{ packageName } ' version parsed as '{ pkgVersion } '") ;
1673
+ _cmdletPassedIn . WriteDebug ( $ "'{ packageName } ' version parsed as '{ pkgVersion } '") ;
1695
1674
1696
- if ( isSpecificVersionSearch )
1675
+ if ( isSpecificVersionSearch )
1676
+ {
1677
+ if ( pkgVersion . ToNormalizedString ( ) == specificVersion . ToNormalizedString ( ) )
1697
1678
{
1698
- if ( pkgVersion . ToNormalizedString ( ) == specificVersion . ToNormalizedString ( ) )
1699
- {
1700
- // accounts for FindVersion() scenario
1701
- sortedPkgs . Add ( pkgVersion , pkgVersionString ) ;
1702
- break ;
1703
- }
1679
+ // accounts for FindVersion() scenario
1680
+ sortedPkgs . Add ( pkgVersion , pkgVersionString ) ;
1681
+ break ;
1704
1682
}
1705
- else
1683
+ }
1684
+ else
1685
+ {
1686
+ if ( versionRange . Satisfies ( pkgVersion ) && ( ! pkgVersion . IsPrerelease || includePrerelease ) )
1706
1687
{
1707
- if ( versionRange . Satisfies ( pkgVersion ) && ( ! pkgVersion . IsPrerelease || includePrerelease ) )
1708
- {
1709
- // accounts for FindVersionGlobbing() and FindName() scenario
1710
- sortedPkgs . Add ( pkgVersion , pkgVersionString ) ;
1711
- }
1688
+ // accounts for FindVersionGlobbing() and FindName() scenario
1689
+ sortedPkgs . Add ( pkgVersion , pkgVersionString ) ;
1712
1690
}
1713
1691
}
1714
1692
}
0 commit comments