Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove PATVAR from PipelineGenerator #8369

Merged
merged 12 commits into from
Jun 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public string Organization
[Option('p', "project", Required = false, Default = "internal", HelpText = "Azure DevOps project name. Default: internal")]
public string Project { get; set; }

[Option('t', "patvar", Required = false, HelpText = "Environment variable name containing a Personal Access Token.")]
public string Patvar { get; set; }

[Option("whatif", Required = false, HelpText = "Dry Run changes")]
public bool WhatIf { get; set; }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Extensions.Logging;
using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
Expand All @@ -20,7 +20,6 @@ public class PipelineGenerationContext
{
private string organization;
private string project;
private string patvar;
private string endpoint;
private string agentPool;
private int[] variableGroups;
Expand All @@ -30,7 +29,6 @@ public PipelineGenerationContext(
ILogger logger,
string organization,
string project,
string patvar,
string endpoint,
string repository,
string branch,
Expand All @@ -46,7 +44,6 @@ public PipelineGenerationContext(
this.logger = logger;
this.organization = organization;
this.project = project;
this.patvar = patvar;
this.endpoint = endpoint;
this.Repository = repository;
this.Branch = branch;
Expand Down Expand Up @@ -77,18 +74,9 @@ private async Task<VssConnection> GetConnectionAsync()
if (cachedConnection == null)
{
VssCredentials credentials;
if (string.IsNullOrWhiteSpace(patvar))
{
var azureTokenProvider = new AzureServiceTokenProvider();
var authenticationResult = await azureTokenProvider.GetAuthenticationResultAsync("499b84ac-1321-427f-aa17-267ca6975798");
credentials = new VssAadCredential(new VssAadToken(authenticationResult.TokenType, authenticationResult.AccessToken));
}
else
{
var pat = Environment.GetEnvironmentVariable(patvar);
credentials = new VssBasicCredential("nobody", pat);
}

var azureTokenProvider = new AzureServiceTokenProvider();
JimSuplizio marked this conversation as resolved.
Show resolved Hide resolved
var authenticationResult = await azureTokenProvider.GetAuthenticationResultAsync("499b84ac-1321-427f-aa17-267ca6975798");
credentials = new VssAadCredential(new VssAadToken(authenticationResult.TokenType, authenticationResult.AccessToken));
cachedConnection = new VssConnection(new Uri(organization), credentials);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -43,7 +43,6 @@ public static async Task Run(object commandObj, CancellationTokenSource cancella
g.Project,
g.Prefix,
g.Path,
g.Patvar,
g.Endpoint,
g.Repository,
g.Branch,
Expand Down Expand Up @@ -127,7 +126,6 @@ public async Task<ExitCondition> RunAsync(
string project,
string prefix,
string path,
string patvar,
string endpoint,
string repository,
string branch,
Expand All @@ -154,7 +152,6 @@ public async Task<ExitCondition> RunAsync(
this.logger,
organization,
project,
patvar,
endpoint,
repository,
branch,
Expand Down