cs-codex-dist-tests/Framework/KubernetesWorkflow/K8sNameUtils.cs

23 lines
582 B
C#
Raw Normal View History

2023-09-15 10:25:10 +00:00
namespace KubernetesWorkflow
{
public static class K8sNameUtils
{
public static string Format(string s)
{
var result = s.ToLowerInvariant()
.Replace(" ", "-")
.Replace(":", "-")
.Replace("/", "-")
.Replace("\\", "-")
.Replace("[", "-")
.Replace("]", "-")
.Replace(",", "-");
result = result.Trim('-');
if (result.Length > 62) result = result.Substring(0, 62);
return result;
2023-09-15 10:25:10 +00:00
}
}
}