Skip to content
Snippets Groups Projects

Add Kubernetes pod label sanitization

Merged Theodor van Nahl requested to merge (removed):Adding_kubernetes_label_sanitation into main
1 unresolved thread
Compare and Show latest version
2 files
+ 27
5
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -357,5 +357,12 @@ func sanitizeLabel(value string) string {
standardized := re.ReplaceAllLiteralString(value, "")
final := strings.ReplaceAll(standardized, " ", "-")
// Logic of replacing start and end chars if not alphanumerical
beg := regexp.MustCompile(`^[^A-Za-z0-9]+`)
end := regexp.MustCompile(`[^A-Za-z0-9]+$`)
final = beg.ReplaceAllLiteralString(final, "")
final = end.ReplaceAllLiteralString(final, "")
return final
}
Loading