utils

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StepNameHashLength = 10

	S3MaxConformNameLength = 63
	K8sMaxNameLength       = names.MaxGeneratedNameLength - 1 // We keep extra space for a "-"

)

Variables

This section is empty.

Functions

func HasString

func HasString(value string, values []string) bool

func Hash

func Hash(value string, hashLength int) string

Hash generates a name based on the unique identifier

func HelmConformName

func HelmConformName(name string) string

Conforms a string to be a Helm-compatible. Currently only shortens the name. Helm has stricter restrictions than K8s and restricts release names to 53 characters.

func Intersection

func Intersection(set1, set2 []string) []string

Intersection finds a common subset of two given sets of strings

func IsPathExists

func IsPathExists(path string) bool

Given a path this function returns true if such path exists. Otherwise it returns false.

func K8sConformName

func K8sConformName(name string, logger *zerolog.Logger) string

Conforms a string to be a k8s compatible for an object name. The method first validates the name is a valid DNS subdomain, and hashes otherwise. In case the string is a valid DNS subdmain, the method shortens the name keeping a prefix and adds a hash of the suffix. The final output length is ActualMaxGeneratedNameLength.

func ListeningAddress

func ListeningAddress(port int) string

func S3ConformName added in v1.3.0

func S3ConformName(name string) string

Conforms a string to be a S3-compatible bucket name. Currently only shortens the name.

func ShortenedName

func ShortenedName(name string, maxLength, hashLength int) string

This function shortens a name to the maximum length given and uses rest of the string that is too long as hash that gets added to the valid name.

func StructToMap

func StructToMap(data interface{}) (map[string]interface{}, error)

StructToMap converts a struct to a map using JSON marshal

Types

This section is empty.

Jump to

Keyboard shortcuts

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