From 6a2381f5256550f7e2effef29764a8220f773af5 Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Wed, 20 Sep 2023 10:50:09 -0400 Subject: [PATCH] Remove unused code in AgentManager. (#2866) --- src/Runner.Worker/ActionManager.cs | 54 ------------------------------ 1 file changed, 54 deletions(-) diff --git a/src/Runner.Worker/ActionManager.cs b/src/Runner.Worker/ActionManager.cs index 5236b3f61..f5575684b 100644 --- a/src/Runner.Worker/ActionManager.cs +++ b/src/Runner.Worker/ActionManager.cs @@ -52,7 +52,6 @@ namespace GitHub.Runner.Worker //81920 is the default used by System.IO.Stream.CopyTo and is under the large object heap threshold (85k). private const int _defaultCopyBufferSize = 81920; - private const string _dotcomApiUrl = "https://api.github.com"; private readonly Dictionary _cachedActionContainers = new(); public Dictionary CachedActionContainers => _cachedActionContainers; @@ -739,10 +738,7 @@ namespace GitHub.Runner.Worker ArgUtil.NotNull(actionDownloadInfos, nameof(actionDownloadInfos)); ArgUtil.NotNull(actionDownloadInfos.Actions, nameof(actionDownloadInfos.Actions)); - var apiUrl = GetApiUrl(executionContext); var defaultAccessToken = executionContext.GetGitHubContext("token"); - var configurationStore = HostContext.GetService(); - var runnerSettings = configurationStore.GetSettings(); foreach (var actionDownloadInfo in actionDownloadInfos.Actions.Values) { @@ -785,26 +781,6 @@ namespace GitHub.Runner.Worker await DownloadRepositoryActionAsync(executionContext, downloadInfo, destDirectory); } - private string GetApiUrl(IExecutionContext executionContext) - { - string apiUrl = executionContext.GetGitHubContext("api_url"); - if (!string.IsNullOrEmpty(apiUrl)) - { - return apiUrl; - } - // Once the api_url is set for hosted, we can remove this fallback (it doesn't make sense for GHES) - return _dotcomApiUrl; - } - - private static string BuildLinkToActionArchive(string apiUrl, string repository, string @ref) - { -#if OS_WINDOWS - return $"{apiUrl}/repos/{repository}/zipball/{@ref}"; -#else - return $"{apiUrl}/repos/{repository}/tarball/{@ref}"; -#endif - } - private async Task DownloadRepositoryActionAsync(IExecutionContext executionContext, WebApi.ActionDownloadInfo downloadInfo, string destDirectory) { //download and extract action in a temp folder and rename it on success @@ -991,29 +967,6 @@ namespace GitHub.Runner.Worker } } - private void ConfigureAuthorizationFromContext(IExecutionContext executionContext, HttpClient httpClient) - { - var authToken = Environment.GetEnvironmentVariable("_GITHUB_ACTION_TOKEN"); - if (string.IsNullOrEmpty(authToken)) - { - // TODO: Deprecate the PREVIEW_ACTION_TOKEN - authToken = executionContext.Global.Variables.Get("PREVIEW_ACTION_TOKEN"); - } - - if (!string.IsNullOrEmpty(authToken)) - { - HostContext.SecretMasker.AddValue(authToken); - var base64EncodingToken = Convert.ToBase64String(Encoding.UTF8.GetBytes($"PAT:{authToken}")); - httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64EncodingToken); - } - else - { - var accessToken = executionContext.GetGitHubContext("token"); - var base64EncodingToken = Convert.ToBase64String(Encoding.UTF8.GetBytes($"x-access-token:{accessToken}")); - httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64EncodingToken); - } - } - private string GetWatermarkFilePath(string directory) => directory + ".completed"; private ActionSetupInfo PrepareRepositoryActionAsync(IExecutionContext executionContext, Pipelines.ActionStep repositoryAction) @@ -1186,13 +1139,6 @@ namespace GitHub.Runner.Worker return $"{repositoryReference.Name}@{repositoryReference.Ref}"; } - private static string GetDownloadInfoLookupKey(WebApi.ActionDownloadInfo info) - { - ArgUtil.NotNullOrEmpty(info.NameWithOwner, nameof(info.NameWithOwner)); - ArgUtil.NotNullOrEmpty(info.Ref, nameof(info.Ref)); - return $"{info.NameWithOwner}@{info.Ref}"; - } - private AuthenticationHeaderValue CreateAuthHeader(string token) { if (string.IsNullOrEmpty(token))