Skip to content

Commit

Permalink
Add v2 ado support
Browse files Browse the repository at this point in the history
  • Loading branch information
alerickson committed Oct 2, 2023
1 parent f73f956 commit f84558b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/code/V2ServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal class V2ServerAPICalls : ServerApiCall
private HttpClient _sessionClient { get; set; }
private static readonly Hashtable[] emptyHashResponses = new Hashtable[]{};
public FindResponseType v2FindResponseType = FindResponseType.ResponseString;
private bool _isADORepo;
private bool _isJFrogRepo;

#endregion
Expand All @@ -57,6 +58,7 @@ public V2ServerAPICalls (PSRepositoryInfo repository, PSCmdlet cmdletPassedIn, N
_sessionClient = new HttpClient(handler);
_sessionClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", userAgentString);
var repoURL = repository.Uri.ToString().ToLower();
_isADORepo = repoURL.Contains("pkgs.dev.azure.com") || repoURL.Contains("pkgs.visualstudio.com");
_isJFrogRepo = repoURL.Contains("jfrog");
}

Expand Down Expand Up @@ -674,7 +676,12 @@ public override Stream InstallName(string packageName, string packageVersion, bo
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallName()");
var requestUrlV2 = string.Empty;

if (_isJFrogRepo)
if (_isADORepo)
{
// eg: https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/nuget/v2?id=test_local_mod&version=5.0.0
requestUrlV2 = $"{Repository.Uri}?id={packageName}&version={packageVersion}";
}
else if (_isJFrogRepo)
{
requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{packageVersion}";
}
Expand Down Expand Up @@ -706,7 +713,12 @@ public override Stream InstallVersion(string packageName, string version, out Er
_cmdletPassedIn.WriteDebug("In V2ServerAPICalls::InstallVersion()");
var requestUrlV2 = string.Empty;

if (_isJFrogRepo)
if (_isADORepo)
{
// eg: https://pkgs.dev.azure.com/<org>/<project>/_packaging/<feed>/nuget/v2?id=test_local_mod&version=5.0.0
requestUrlV2 = $"{Repository.Uri}?id={packageName}&version={version}";
}
else if (_isJFrogRepo)
{
requestUrlV2 = $"{Repository.Uri}/Download/{packageName}/{version}";
}
Expand Down

0 comments on commit f84558b

Please sign in to comment.