kubevalidate

package
v0.0.0-...-2dfab7d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidName = errors.New("Invalid Name")

Functions

func DeterministicSlug

func DeterministicSlug(seed string) string

func IsValidName

func IsValidName(s string) bool

Checks if the given name is a label name as defined by RFC 1035.

func IsValidNameMsgs

func IsValidNameMsgs(s string) []string

func IsValidRFC1123Name

func IsValidRFC1123Name(s string) bool

Checks if the given name is a lowercase DNS label as defined in RFC 1123.

func IsValidSubdomain

func IsValidSubdomain(s string) bool

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

func ToIdentifier(s string) string

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 ToValidCronjobName(s string) (string, error)

func ToValidName

func ToValidName(s string) (string, error)

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

func ToValidNameWithSlug(prefix string) (string, error)

ToValidNameWithSlug adds a slug to the `prefix` and converts it to a valid name

func ToValidSubdomain

func ToValidSubdomain(s string) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL