Skip to content

Commit

Permalink
fix org uri (#176)
Browse files Browse the repository at this point in the history
Co-authored-by: Azure DevOps CI <[email protected]>
  • Loading branch information
f2calv and Azure DevOps CI authored Dec 22, 2022
1 parent 70501fc commit c3d5547
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/CasCap.Apis.AzureDevOps/Services/ApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace CasCap.Services;

public interface IApiService
{
Task<List<TaskObj>> GetAllExtensions(string organisation);
Task<List<TaskObj>> GetAllExtensions(string organisationUri);
Task<string> Validate(string organisation, string project, int pipelineId, string pipelineYaml);
}

Expand All @@ -22,10 +22,10 @@ public ApiService(ILogger<ApiService> logger, string PAT) : base()
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(bytes));
}

public async Task<List<TaskObj>> GetAllExtensions(string organisation)
public async Task<List<TaskObj>> GetAllExtensions(string organisationUri)
{
_logger.LogInformation("Retrieving all extensions for organisation '{organisation}'", organisation);
var res = await Get<Tasks, object>($"https://dev.azure.com/{organisation}/_apis/distributedtask/tasks/");
_logger.LogInformation("Retrieving all extensions for organisation '{organisation}'", organisationUri);
var res = await Get<Tasks, object>($"{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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/CasCap.DevOpsYamlizrCli/Commands/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ protected async Task<bool> 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
{
Expand Down
10 changes: 5 additions & 5 deletions src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public GenerateCommand(ILogger<GenerateCommand> 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.")]
Expand Down Expand Up @@ -58,9 +58,9 @@ public async Task<int> 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;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task<int> OnExecuteAsync()
_console.ForegroundColor = fgColor;
#endregion

if (!Connect(PAT, organisation))
if (!Connect(PAT, organisationUri))
return 1;

if (!await GetProject(project))
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<int> OnExecuteAsync()
var taskGroupTemplateMap = new ConcurrentDictionary<TaskGroupVersion, Template>();

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.");
Expand Down

0 comments on commit c3d5547

Please sign in to comment.