sanitize

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

View Source
const MaxDNSNameLength = 63

MaxDNSNameLength is the limit for some resources Name fields where they can be used as DNS names per RFC 1035.

View Source
const MaxK8SValueLength = 253

MaxK8sValueLength is the limit for names that can be used as DNS subdomain values per RFC 1123. https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names

Variables

View Source
var ErrEmptyName = invalidName("DNS name can not be empty")

ErrEmptyName is returned if an empty string is provided for sanitising.

Functions

func SanitizeDNSDomain

func SanitizeDNSDomain(name string) (string, error)

DNS subdomains are DNS labels separated by '.', max 253 characters.

func SanitizeDNSName

func SanitizeDNSName(name string) (string, error)

SanitizeDNSName sanitizes a string suitable for use in K8s resources that require a DNS 1035 compatible name.

The name returned from here must conform to following rules (as per RFC 1035):

  • length must be <= 63 characters
  • must be all lower case alphanumeric characters or '-'
  • must start with an alphabet
  • must end with an alphanumeric character

Types

type InvalidNameError

type InvalidNameError struct {
	// contains filtered or unexported fields
}

InvalidNameError is returned when a name can't be sanitized.

func (InvalidNameError) Error

func (m InvalidNameError) Error() string

Jump to

Keyboard shortcuts

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