2023-08-10 09:25:22 +00:00
|
|
|
|
using Logging;
|
|
|
|
|
|
|
|
|
|
namespace KubernetesWorkflow
|
2023-08-07 13:51:44 +00:00
|
|
|
|
{
|
|
|
|
|
public class PodLabels
|
|
|
|
|
{
|
|
|
|
|
private readonly Dictionary<string, string> labels = new Dictionary<string, string>();
|
|
|
|
|
|
2023-08-10 09:47:34 +00:00
|
|
|
|
private PodLabels(PodLabels source)
|
|
|
|
|
{
|
|
|
|
|
labels = source.labels.ToDictionary(p => p.Key, p => p.Value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-10 09:25:22 +00:00
|
|
|
|
public PodLabels(string testsType, string codexId)
|
|
|
|
|
{
|
|
|
|
|
Add("tests-type", testsType);
|
|
|
|
|
Add("runid", NameUtils.GetRunId());
|
|
|
|
|
Add("testid", NameUtils.GetTestId());
|
|
|
|
|
Add("category", NameUtils.GetCategoryName());
|
|
|
|
|
Add("codexid", codexId);
|
|
|
|
|
Add("fixturename", NameUtils.GetRawFixtureName());
|
|
|
|
|
Add("testname", NameUtils.GetTestMethodName());
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-10 09:47:34 +00:00
|
|
|
|
public PodLabels GetLabelsForAppName(string appName)
|
2023-08-10 09:25:22 +00:00
|
|
|
|
{
|
2023-08-10 09:47:34 +00:00
|
|
|
|
var pl = new PodLabels(this);
|
|
|
|
|
pl.Add("app", appName);
|
|
|
|
|
return pl;
|
2023-08-10 09:25:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Add(string key, string value)
|
2023-08-07 13:51:44 +00:00
|
|
|
|
{
|
2023-08-10 09:47:34 +00:00
|
|
|
|
labels.Add(key,
|
|
|
|
|
value.ToLowerInvariant()
|
|
|
|
|
.Replace(":","-")
|
|
|
|
|
.Replace("/", "-")
|
|
|
|
|
.Replace("\\", "-")
|
|
|
|
|
);
|
2023-08-07 13:51:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal Dictionary<string, string> GetLabels()
|
|
|
|
|
{
|
|
|
|
|
return labels;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|