names

package
v1.11.0 Latest Latest
Warning

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

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

Documentation

Overview

Package names collects functions encapsulating the rules for constructing a variety of kube resource names

Index

Constants

View Source
const (
	Sha1sumLength = 40 // The length of a sha1sum checksum
)

Variables

This section is empty.

Functions

func DNSLabelSafe added in v0.8.0

func DNSLabelSafe(name string) string

DNSLabelSafe filters invalid characters and returns a string that is safe to use as Kubernetes resource name.

https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names

func GenerateResourceName added in v0.0.22

func GenerateResourceName(names ...string) string

func GenerateResourceNameTruncated added in v0.8.0

func GenerateResourceNameTruncated(originalName string, maxLen int) string

GenerateResourceNameTruncated joins the input strings with dashes("-") and returns the checksum of the produced string after removing any characters that are invalid for kubernetes resource names and prefixing the checksum with up to (maxLen - Sha1sumLength) characters of the original string. It concatenates the prefix with the checksum with a "-". This way the generated name: - is always valid for a resource name - is never longer than maxLen characters - has low probability of collisions NOTE: Since the checksum must always be included, this function shouldn't be used to produce names shorter than Sha1sumLength characters.

func MD5String added in v1.1.0

func MD5String(value string, length int) string

MD5String compute the hash of the passed value and returns the first 'length' characters If the length is -1 or greater than the md5 hash then the whole hash is returned

func ReleaseName added in v0.6.0

func ReleaseName(base string) string

ReleaseName returns the name of a helm release derived from the base string.

func ServiceHelmChartName added in v0.9.0

func ServiceHelmChartName(name, namespace string) string

COMPATIBILITY SUPPORT for services from before https://github.com/epinio/epinio/issues/1704 fix

func ServiceReleaseName added in v1.4.0

func ServiceReleaseName(base string) string

ServiceReleaseName returns the name of a helm release derived from the base string.

func Truncate added in v0.8.0

func Truncate(s string, maxLen int) string

Truncate truncates the input string s to the maxLen, if necessary. Shorter strings are passed through unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

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