naming

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShortenName

func ShortenName(s string, l int) (string, error)

ShortenName deterministically shortens the provided string to the maximum of l characters. The function cannot shorten below a length of 8. This needs to be deterministic, as we use it to find existing resources. ShortenName name will eihter choose CRC64 or CRC32 depending on the requested length l

func ShortenName32

func ShortenName32(s string, l int) (string, error)

ShortenName32 deterministically shortens the provided string to the maximum of l characters. The function cannot shorten below a length of 8. It does this by taking the CRC32 has of the complete string, truncate the name to the first l-8 characters, and appending the hash in hex. When using this function for jobs, if we have 10000 active jobs in one namespace, each copying between pvc that start with the same 19 letters, the likelihood of a collision, which would cause the resize operation to fail is about 1 in 10'000. For 1000 active jobs, the likelihood is about 1 in 100'000'000.

func ShortenName64

func ShortenName64(s string, l int) (string, error)

ShortenName64 deterministically shortens the provided string to the maximum of l characters. The function cannot shorten below a length of 16. It does this by taking the CRC64 has of the complete string, truncate the name to the first l-16 characters, and appending the hash in hex. When using this function for backup pvcs, if we have 100'000 backups of pvcs, that start with the same ~37 letters, that are longer than ~53 letters, and have the same size, in one namespace, the likelihood of a collision, which would cause old backups to be overwritten is less than 1 in 1 Billion.

Types

This section is empty.

Jump to

Keyboard shortcuts

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