From c3d55478ac6b679db41ba6b7628b4be11b11b159 Mon Sep 17 00:00:00 2001 From: Alex Vincent Date: Thu, 22 Dec 2022 14:34:18 +0100 Subject: [PATCH] fix org uri (#176) Co-authored-by: Azure DevOps CI --- src/CasCap.Apis.AzureDevOps/Services/ApiService.cs | 8 ++++---- src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs | 4 ++-- .../Commands/GenerateCommand.cs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs b/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs index ba43b4a..e06310b 100644 --- a/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs +++ b/src/CasCap.Apis.AzureDevOps/Services/ApiService.cs @@ -6,7 +6,7 @@ namespace CasCap.Services; public interface IApiService { - Task> GetAllExtensions(string organisation); + Task> GetAllExtensions(string organisationUri); Task Validate(string organisation, string project, int pipelineId, string pipelineYaml); } @@ -22,10 +22,10 @@ public ApiService(ILogger logger, string PAT) : base() _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(bytes)); } - public async Task> GetAllExtensions(string organisation) + public async Task> GetAllExtensions(string organisationUri) { - _logger.LogInformation("Retrieving all extensions for organisation '{organisation}'", organisation); - var res = await Get($"https://dev.azure.com/{organisation}/_apis/distributedtask/tasks/"); + _logger.LogInformation("Retrieving all extensions for organisation '{organisation}'", organisationUri); + var res = await Get($"{organisationUri}/_apis/distributedtask/tasks/"); return res.result is not null && res.result is not null && res.result.value is not null ? res.result.value : null; } diff --git a/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs b/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs index 238a447..f7d3862 100644 --- a/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs +++ b/src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs @@ -87,9 +87,9 @@ protected async Task GetProject(string project) return _project is not null; } - protected bool Connect(string PAT, string organisation) + protected bool Connect(string PAT, string organisationUri) { - var uri = new Uri(organisation); + var uri = new Uri(organisationUri); _console.Write($"Connecting to DevOps REST API, {uri} ..."); try { diff --git a/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs b/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs index da5a746..7befee7 100644 --- a/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs +++ b/src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs @@ -25,7 +25,7 @@ public GenerateCommand(ILogger logger, ILoggerFactory loggerFac [Required] [Option("-org|--organisation", Description = "Azure DevOps Organisation Uri.")] - public string organisation { get; } + public string organisationUri { get; } [Required] [Option("-proj|--project", Description = "Azure DevOps Project Name.")] @@ -58,9 +58,9 @@ public async Task OnExecuteAsync() _logger.LogError($"{nameof(PAT)} missing or invalid!"); return 1; } - if (string.IsNullOrWhiteSpace(organisation)) + if (string.IsNullOrWhiteSpace(organisationUri)) { - _logger.LogError($"{nameof(organisation)} missing or invalid!"); + _logger.LogError($"{nameof(organisationUri)} missing or invalid!"); return 1; } @@ -89,7 +89,7 @@ public async Task OnExecuteAsync() _console.ForegroundColor = fgColor; #endregion - if (!Connect(PAT, organisation)) + if (!Connect(PAT, organisationUri)) return 1; if (!await GetProject(project)) @@ -127,7 +127,7 @@ public async Task OnExecuteAsync() var taskGroupTemplateMap = new ConcurrentDictionary(); pbar = new ProgressBar(1, $"Loading extensions...", pbarOptions); - var tasks = await _apiSvc.GetAllExtensions(organisation); + var tasks = await _apiSvc.GetAllExtensions(organisationUri); foreach (var task in tasks) task.inputMap = task.inputs.ToDictionary(k => k.name, v => v); pbar.Tick($"{tasks.Count} installed extension(s) retrieved.");