Documentation ¶
Index ¶
- Variables
- func DeterministicSlug(seed string) string
- func IsValidName(s string) bool
- func IsValidNameMsgs(s string) []string
- func IsValidRFC1123Name(s string) bool
- func IsValidSubdomain(s string) bool
- func KubeSlug() string
- func ToIdentifier(s string) string
- func ToValidCronjobName(s string) (string, error)
- func ToValidName(s string) (string, error)
- func ToValidNameWithSlug(prefix string) (string, error)
- func ToValidSubdomain(s string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidName = errors.New("Invalid Name")
Functions ¶
func DeterministicSlug ¶
func IsValidName ¶
Checks if the given name is a label name as defined by RFC 1035.
func IsValidNameMsgs ¶
func IsValidRFC1123Name ¶
Checks if the given name is a lowercase DNS label as defined in RFC 1123.
func IsValidSubdomain ¶
Checks if the given name is a lowercase DNS subdomain name as defined in RFC 1123.
func KubeSlug ¶
func KubeSlug() string
KubeSlug returns a slug of the length used in kubernetes code. This function is useful for mocking in tests (for stability).
func ToIdentifier ¶
ToIdentifier attempts to convert the provided string into an alternate version that:
- Contains only ASCII alphanumeric characters, or an allowed separator ('-', '_', '.')
- Starts and ends with an alphanumeric character and *not* a separator
- Has each chunk of alphanumeric characters separated by at most one separator (in other words, separators don't repeat)
This function is often helpful as a first pass before stricter transformations
func ToValidCronjobName ¶
func ToValidName ¶
ToValidName attempts to convert the provided string into an alternate version that is a label name as defined in RFC 1123. Basically the string must:
- Contain lowercase alphanumeric characters or '-'
- It must start with an alphabetic character
- It must end with an alphanumeric character
- It must no more than nameMaxLength characters
func ToValidNameWithSlug ¶
ToValidNameWithSlug adds a slug to the `prefix` and converts it to a valid name
func ToValidSubdomain ¶
Best effort attempt to convert the provided string into an alternate version that is a lowercase DNS subdomain name as defined in RFC 1123. Basically the string must:
- Contain lowercase alphanumeric characters, '-' or '.'
- It must start and end with an alphanumeric character.
- Separators '-' and '.' should be followed by an alphanumeric character.
Types ¶
This section is empty.