utils

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HashRegexp  = regexp.MustCompile(`^[0-9a-f]{7}$`)
	ImageRegexp = regexp.MustCompile(`^.*:[a-z0-9-]{7}$`)
	// TODO use SHA256, switch pattern to ^.*@sha256:[a-z0-9]{64}$
	NameRegexp        = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,28}[a-z0-9]$`)
	TagOrBranchRegexp = regexp.MustCompile(`^[a-z0-9][a-z0-9-\\.]{0,28}[a-z0-9]$`)
	UUIDRegexp        = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
)

Functions

func Contains

func Contains[T Comparable[T]](s []T, e T) bool

func GetCertFromSecret

func GetCertFromSecret(namespace, secret string) (cert tls.Certificate, cp *x509.CertPool, err error)

func GetParamOrHeader

func GetParamOrHeader(httpReq *http.Request, keys ...string) string

GetParamOrHeader looks for query parameters and headers for the provided keys. Keys are checked in order. Query parameters take precedence over headers.

func GetSvcAccountToken

func GetSvcAccountToken(namespace, svcAccount string) (string, error)

func ResolveFlag

func ResolveFlag(curr, envVar, def string) string

func ResolveFlagBool

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

func SystemNamespace

func SystemNamespace(platform, system string) string

SystemNamespace returns the name of the Kubernetes Namespace that contains all System objects. The format is 'kfs-{Instance}-{System}'. The 'kfs' prefix stands for 'KubeFox System'.

If any arg is empty an empty string is returned.

Types

type Comparable

type Comparable[T any] interface {
	Equals(T) bool
}

Jump to

Keyboard shortcuts

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