36643b77b4
- upgrade from apiextension v1beta1 to v1 - generate yaml manifest for crd intead of applying it at runtime - users will have to apply the manifest with kubectl - kg and kgctl log an error if the crd is not present - now validation should actually work Signed-off-by: leonnicolas <leonloechner@gmx.de>
49 lines
915 B
Go
49 lines
915 B
Go
package flect
|
|
|
|
import (
|
|
"strings"
|
|
"unicode"
|
|
)
|
|
|
|
// Camelize returns a camelize version of a string
|
|
// bob dylan = bobDylan
|
|
// widget_id = widgetID
|
|
// WidgetID = widgetID
|
|
func Camelize(s string) string {
|
|
return New(s).Camelize().String()
|
|
}
|
|
|
|
// Camelize returns a camelize version of a string
|
|
// bob dylan = bobDylan
|
|
// widget_id = widgetID
|
|
// WidgetID = widgetID
|
|
func (i Ident) Camelize() Ident {
|
|
var out []string
|
|
for i, part := range i.Parts {
|
|
var x string
|
|
var capped bool
|
|
if strings.ToLower(part) == "id" {
|
|
out = append(out, "ID")
|
|
continue
|
|
}
|
|
for _, c := range part {
|
|
if unicode.IsLetter(c) || unicode.IsDigit(c) {
|
|
if i == 0 {
|
|
x += string(unicode.ToLower(c))
|
|
continue
|
|
}
|
|
if !capped {
|
|
capped = true
|
|
x += string(unicode.ToUpper(c))
|
|
continue
|
|
}
|
|
x += string(c)
|
|
}
|
|
}
|
|
if x != "" {
|
|
out = append(out, x)
|
|
}
|
|
}
|
|
return New(strings.Join(out, ""))
|
|
}
|