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

Fix broken input flags and allow empty files #448

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/Runner.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ public static async Task<string> ExpandCurrentPipeline(Parameters handle, string
};
Dictionary<string, TemplateToken> cparameters = new Dictionary<string, TemplateToken>(StringComparer.OrdinalIgnoreCase);
if(handle.InputFiles?.Length > 0) {
foreach(var file in handle.InputFiles) {
foreach(var file in handle.InputFiles.Where(f => f != "")) {
Util.ReadEnvFile(file, (varname, varval) => cparameters[varname] = AzurePipelinesUtils.ConvertStringToTemplateToken(varval));
}
}
Expand Down Expand Up @@ -1093,6 +1093,8 @@ static int Main(string[] args)
environmentSecretFileOpt,
environmentVarOpt,
environmentVarFileOpt,
workflowInputsOpt,
workflowInputFilesOpt,
jobOpt,
matrixOpt,
listOpt,
Expand Down Expand Up @@ -1761,7 +1763,7 @@ await Task.WhenAny(Task.Run(() => {
List<string> wenv = new List<string>();
List<string> wsecrets = new List<string>();
if(parameters.EnvFile?.Length > 0) {
foreach(var file in parameters.EnvFile) {
foreach(var file in parameters.EnvFile.Where(f => f != "")) {
try {
wenv.AddRange(Util.ReadEnvFile(file));
} catch(Exception ex) {
Expand All @@ -1771,7 +1773,7 @@ await Task.WhenAny(Task.Run(() => {
}
}
if(parameters.SecretFiles?.Length > 0) {
foreach(var file in parameters.SecretFiles) {
foreach(var file in parameters.SecretFiles.Where(f => f != "")) {
try {
wsecrets.AddRange(Util.ReadEnvFile(file));
} catch(Exception ex) {
Expand Down Expand Up @@ -1976,7 +1978,7 @@ await Task.WhenAny(Task.Run(() => {
var inputs = payloadContent.TryGetValue("inputs", out var oinputs) ? (JObject)oinputs : new JObject();
payloadContent["inputs"] = inputs;
if(parameters.InputFiles?.Length > 0) {
foreach(var file in parameters.InputFiles) {
foreach(var file in parameters.InputFiles.Where(f => f != "")) {
try {
Util.ReadEnvFile(file, (k, v) => inputs[k] = v);
} catch(Exception ex) {
Expand All @@ -1998,7 +2000,7 @@ await Task.WhenAny(Task.Run(() => {
if(!ffVars.ContainsKey("system.runner.server.parameters")) {
var inputs = new JObject();
if(parameters.InputFiles?.Length > 0) {
foreach(var file in parameters.InputFiles) {
foreach(var file in parameters.InputFiles.Where(f => f != "")) {
try {
Util.ReadEnvFile(file, (k, v) => inputs[k] = v);
} catch(Exception ex) {
Expand Down Expand Up @@ -2538,10 +2540,6 @@ await Task.WhenAny(Task.Run(() => {
cmd.AddOption(opt);
}
}
if(ev == "workflow_dispatch" || ev == "azexpand" || ev == "azpipelines") {
cmd.AddOption(workflowInputsOpt);
cmd.AddOption(workflowInputFilesOpt);
}
}
var startserver = new Command("startserver", "Starts a server listening on the supplied address or selects a random free http address.");
rootCommand.AddCommand(startserver);
Expand Down Expand Up @@ -2617,7 +2615,7 @@ await Task.WhenAny(Task.Run(() => {
{
var envSecrets = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
if(parameters.EnvironmentSecretFiles?.Length > 0) {
foreach(var opt in parameters.EnvironmentSecretFiles) {
foreach(var opt in parameters.EnvironmentSecretFiles.Where(f => f != "")) {
var subopt = opt.Split('=', 2);
string name = subopt.Length == 2 ? subopt[0] : "";
string filename = subopt.Length == 2 ? subopt[1] : subopt[0];
Expand All @@ -2643,7 +2641,7 @@ await Task.WhenAny(Task.Run(() => {
}
var envVars = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
if(parameters.EnvironmentVarFiles?.Length > 0) {
foreach(var opt in parameters.EnvironmentVarFiles) {
foreach(var opt in parameters.EnvironmentVarFiles.Where(f => f != "")) {
var subopt = opt.Split('=', 2);
string name = subopt.Length == 2 ? subopt[0] : "";
string filename = subopt.Length == 2 ? subopt[1] : subopt[0];
Expand All @@ -2652,7 +2650,7 @@ await Task.WhenAny(Task.Run(() => {
}
}
if(parameters.VarFiles?.Length > 0) {
foreach(var opt in parameters.VarFiles) {
foreach(var opt in parameters.VarFiles.Where(f => f != "")) {
string name = "";
string filename = opt;
var dict = envVars[name] = envVars.TryGetValue(name, out var v) ? v : new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Expand Down
Loading