cs-codex-dist-tests/ContinuousTests/Configuration.cs

48 lines
1.7 KiB
C#
Raw Normal View History

2023-06-26 12:44:21 +00:00
using ArgsUniform;
using DistTestCore.Codex;
2023-06-23 08:14:16 +00:00
using Newtonsoft.Json;
namespace ContinuousTests
{
public class Configuration
{
2023-06-26 12:44:21 +00:00
[Uniform("log-path", "l", "LOGPATH", true, "Path where log files will be written.")]
public string LogPath { get; set; } = "logs";
2023-06-26 12:44:21 +00:00
[Uniform("data-path", "d", "DATAPATH", true, "Path where temporary data files will be written.")]
public string DataPath { get; set; } = "data";
2023-06-26 12:44:21 +00:00
[Uniform("codex-deployment", "c", "CODEXDEPLOYMENT", true, "Path to codex-deployment JSON file.")]
public string CodexDeploymentJson { get; set; } = string.Empty;
2023-06-26 12:44:21 +00:00
[Uniform("keep", "k", "KEEP", false, "Set to '1' to retain logs of successful tests.")]
public bool KeepPassedTestLogs { get; set; } = false;
2023-06-27 08:16:59 +00:00
[Uniform("kube-config", "kc", "KUBECONFIG", true, "Path to Kubeconfig file. Use 'null' (default) to use local cluster.")]
public string KubeConfigFile { get; set; } = "null";
2023-06-26 13:37:16 +00:00
2023-06-26 12:44:21 +00:00
public CodexDeployment CodexDeployment { get; set; } = null!;
}
2023-06-26 12:44:21 +00:00
public class ConfigLoader
{
public Configuration Load(string[] args)
{
2023-06-26 12:44:21 +00:00
var uniformArgs = new ArgsUniform<Configuration>(args);
2023-06-25 08:50:01 +00:00
2023-06-27 08:16:59 +00:00
var result = uniformArgs.Parse(true);
2023-06-26 12:44:21 +00:00
result.CodexDeployment = ParseCodexDeploymentJson(result.CodexDeploymentJson);
2023-06-26 12:44:21 +00:00
return result;
}
2023-06-26 12:44:21 +00:00
2023-06-23 08:14:16 +00:00
private CodexDeployment ParseCodexDeploymentJson(string filename)
{
var d = JsonConvert.DeserializeObject<CodexDeployment>(File.ReadAllText(filename))!;
if (d == null) throw new Exception("Unable to parse " + filename);
return d;
}
}
}