From 1b142828e642e51169f7df1b8c391a41b206d49c Mon Sep 17 00:00:00 2001 From: alerickson <25858831+alerickson@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:21:32 -0800 Subject: [PATCH] ACR Integration: Publish-PSResource methods (#1501) --- src/code/ACRServerAPICalls.cs | 2 +- src/code/PublishPSResource.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/code/ACRServerAPICalls.cs b/src/code/ACRServerAPICalls.cs index 2633e1aaa..279c77a91 100644 --- a/src/code/ACRServerAPICalls.cs +++ b/src/code/ACRServerAPICalls.cs @@ -960,7 +960,7 @@ private static Collection> GetDefaultHeaders(string }; } - private bool PushNupkgACR(string outputNupkgDir, string pkgName, NuGetVersion pkgVersion, PSRepositoryInfo repository, out ErrorRecord errRecord) + internal bool PushNupkgACR(string outputNupkgDir, string pkgName, NuGetVersion pkgVersion, PSRepositoryInfo repository, out ErrorRecord errRecord) { errRecord = null; // Push the nupkg to the appropriate repository diff --git a/src/code/PublishPSResource.cs b/src/code/PublishPSResource.cs index bd132fc6c..cb6fac1ae 100644 --- a/src/code/PublishPSResource.cs +++ b/src/code/PublishPSResource.cs @@ -15,8 +15,6 @@ using System.Management.Automation; using System.Net; using System.Net.Http; -using System.Security.Cryptography; -using System.Text; using System.Threading; using System.Xml; @@ -138,6 +136,8 @@ public PSCredential ProxyCredential { private string pathToModuleDirToPublish = string.Empty; private ResourceType resourceType = ResourceType.None; private NetworkCredential _networkCredential; + string userAgentString = UserAgentInfo.UserAgentString(); + #endregion #region Method overrides @@ -482,16 +482,16 @@ out string[] _ string repositoryUri = repository.Uri.AbsoluteUri; - if (repository.RepositoryProvider == PSRepositoryInfo.RepositoryProviderType.ACR) + if (repository.ApiVersion == PSRepositoryInfo.APIVersion.acr) { - // TODO: Create instance of ACR server class and call PushNupkgACR - /* - if (!PushNupkgACR(outputNupkgDir, repository, out ErrorRecord pushNupkgACRError)) + ACRServerAPICalls acrServer = new ACRServerAPICalls(repository, this, _networkCredential, userAgentString); + + if (!acrServer.PushNupkgACR(outputNupkgDir, _pkgName, _pkgVersion, repository, out ErrorRecord pushNupkgACRError)) { WriteError(pushNupkgACRError); + // exit out of processing return; } - */ } else {