name

package
v0.7.1-debug-1842-4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package name provides functions for truncating and hashing strings and for generating valid k8s resource names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelmReleaseName

func HelmReleaseName(str string) string

HelmReleaseName uses the provided string to create a unique name. The resulting name is DNS label safe (RFC1123) and complies with Helm's regex for release names.

func Hex

func Hex(s string, length int) string

Hex returns a hex-encoded hash of the string and truncates it to length. Warning: truncating the 32 character hash makes collisions more likely.

func KeyHash added in v0.7.1

func KeyHash(s string) string

KeyHash returns the first 12 hex characters of the hash of the first 100 chars of the input string

func Limit

func Limit(s string, count int) string

Limit the length of a string to count characters. If the string's length is greater than count, it will be truncated and a separator will be appended to the end, followed by a hash. If the last character of the truncated string is the separator, then the separator itself is omitted. This prevents the result from containing two consecutive separators. In such a case, the result will be [count -1] characters long. If count is too small to include the shortened hash the string is simply truncated.

Types

This section is empty.

Jump to

Keyboard shortcuts

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