namegen

package
v0.0.0-...-3aa7b29 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 3 Imported by: 14

Documentation

Index

Constants

View Source
const (
	SuffixLength = 9 // 8 bytes of hexadecimal hash/random characters and 1 byte of separator
)

Variables

This section is empty.

Functions

func PrefixedRandShortName

func PrefixedRandShortName(prefix, basename string, maxlen int) string

func RandShortName

func RandShortName(basename string, maxlen int) string

Suffix a string with random letters and numbers, and truncate it to a maximum length.

func ShortName

func ShortName(basename string, maxlen int) (string, error)

Append the string's CRC32 hash to the string and truncate it to a maximum length. Can be used to avoid collisions in the Kubernetes namespace.

e.g. ShortName("foobarbaz", 16) --> "foobarb-12345678"

func SuffixedShortName

func SuffixedShortName(basename, suffix string, maxlen int) (string, error)

SuffixedShortName generates a ShortName and appends a given suffix to this, e.g. an incremental counter. The resulting string is truncated to the given maximum length.

Types

This section is empty.

Jump to

Keyboard shortcuts

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