utils

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MPL-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexpNameSpecialChar  = regexp.MustCompile(`[^a-z0-9]`)
	RegexpLabelSpecialChar = regexp.MustCompile(`[^a-z0-9A-Z-_\.]`)
	RegexpLabelPrefix      = regexp.MustCompile(`^[^a-z0-9A-Z]*`)
	RegexpLabelSuffix      = regexp.MustCompile(`[^a-z0-9A-Z-_\.]*[^a-z0-9A-Z]*$`)
)

Functions

func ByteArrayToUInt

func ByteArrayToUInt(b []byte) uint64

func CheckRequiredFlag

func CheckRequiredFlag(n, p string)

func CleanLabel

func CleanLabel(value any) string

CleanLabel returns the label value with all special characters replaced with dashes and any character that is not [a-z0-9A-Z] trimmed from start and end. If name is a path only the basename is used.

https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

func CleanName

func CleanName(name string) string

CleanName returns name with all special characters replaced with dashes and set to lowercase. The string is truncated if longer than 63 characters. If name is a path only the basename is used.

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

func EnvDef

func EnvDef(name, def string) string

func First

func First(strs ...string) string

First returns the first non-empty string. If all strings are empty then empty string is returned.

func IsValidName

func IsValidName(name string) bool

func Join

func Join(sep string, elems ...string) string

Join concatenates the elements of its second argument to create a single string. The separator string sep is placed between elements in the resulting string. Empty elements are ignored.

func ResolveFlag

func ResolveFlag(curr, envVar, def string) string

func ResolveFlagBool

func ResolveFlagBool(curr bool, envVar string, def bool) bool

func ResolveFlagInt

func ResolveFlagInt(curr int, envVar string, def int) int

func ShortHash added in v0.6.0

func ShortHash(hash string) string

func UIntToByteArray

func UIntToByteArray(i uint64) []byte

Types

type CertPackage

type CertPackage struct {
	CA              string
	CAPrivKeyPEM    string
	Cert            string
	CertPrivKey     string
	ServerTLSConfig *tls.Config
	ClientTLSConfig *tls.Config
}

func GeneratePKI

func GeneratePKI(cname string, expires time.Time) (*CertPackage, error)

Jump to

Keyboard shortcuts

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