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(",", "-");
|
|
|
|
|
|
2023-09-28 10:22:35 +00:00
|
|
|
|
result = result.Trim('-');
|
|
|
|
|
if (result.Length > 62) result = result.Substring(0, 62);
|
|
|
|
|
|
|
|
|
|
return result;
|
2023-09-15 10:25:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|