a4b6b561d7
* Add Prometheus annotations for Codex Pods (#48) * Remove unnecessary condition (#48) * Update Annotations to be handled via ContainerRecipe (#48) * Wires up metrics port to codex pod annotation * Cleans up handling of pod labels * Fix annotations names (#48) --------- Co-authored-by: benbierens <thatbenbierens@gmail.com>
43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
namespace KubernetesWorkflow
|
|
{
|
|
public class PodLabels
|
|
{
|
|
private readonly Dictionary<string, string> labels = new Dictionary<string, string>();
|
|
|
|
public void Add(string key, string value)
|
|
{
|
|
labels.Add(key, Format(value));
|
|
}
|
|
|
|
public PodLabels Clone()
|
|
{
|
|
var result = new PodLabels();
|
|
foreach (var entry in labels) result.Add(entry.Key, entry.Value);
|
|
return result;
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
labels.Clear();
|
|
}
|
|
|
|
private static string Format(string s)
|
|
{
|
|
var result = s.ToLowerInvariant()
|
|
.Replace(":", "-")
|
|
.Replace("/", "-")
|
|
.Replace("\\", "-")
|
|
.Replace("[", "-")
|
|
.Replace("]", "-")
|
|
.Replace(",", "-");
|
|
|
|
return result.Trim('-');
|
|
}
|
|
|
|
internal Dictionary<string, string> GetLabels()
|
|
{
|
|
return labels;
|
|
}
|
|
}
|
|
}
|