1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-16 09:16:38 +00:00
prometheus-operator/vendor/github.com/gobuffalo/flect/dasherize.go
Paul Gier ce72171c48 use kubebuilder controller-gen for creating CRD yaml files
Replaces the custom po-crdgen command
2019-11-20 15:35:04 -06:00

34 lines
765 B
Go

package flect
import (
"strings"
"unicode"
)
// Dasherize returns an alphanumeric, lowercased, dashed string
// Donald E. Knuth = donald-e-knuth
// Test with + sign = test-with-sign
// admin/WidgetID = admin-widget-id
func Dasherize(s string) string {
return New(s).Dasherize().String()
}
// Dasherize returns an alphanumeric, lowercased, dashed string
// Donald E. Knuth = donald-e-knuth
// Test with + sign = test-with-sign
// admin/WidgetID = admin-widget-id
func (i Ident) Dasherize() Ident {
var parts []string
for _, part := range i.Parts {
var x string
for _, c := range part {
if unicode.IsLetter(c) || unicode.IsDigit(c) {
x += string(c)
}
}
parts = xappend(parts, x)
}
return New(strings.ToLower(strings.Join(parts, "-")))
}