names

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: Apache-2.0 Imports: 11 Imported by: 18

Documentation

Overview

Package names has helpers for naming resources and generating strings

Index

Constants

View Source
const (
	// ConfigMap is used in log messages
	ConfigMap = "configmap"
	// Secret is used in log messages
	Secret = "secret"
)
View Source
const GroupName = "quarks.cloudfoundry.org"

GroupName is the k8s API group name

Variables

This section is empty.

Functions

func CSRName

func CSRName(namespace, quarksSecretName string) string

CSRName returns a CertificateSigningRequest name for a given QuarksJob

func CsrPrivateKeySecretName

func CsrPrivateKeySecretName(csrName string) string

CsrPrivateKeySecretName returns a Secret name for a given CertificateSigningRequest private key

func DNSLabelSafe

func DNSLabelSafe(name string) string

DNSLabelSafe filters invalid characters and returns a string that is safe to use as a DNS label. It does not enforce the required string length, see `Sanitize`.

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

func GetDockerSourceName

func GetDockerSourceName(prefix, repo, tag string) (string, error)

GetDockerSourceName returns the name of the docker image More info:

prefix: [<host>[:<port>]/][<org>/] repo: <name> tag :[:<tag>]

func GetStatefulSetName

func GetStatefulSetName(name string) string

GetStatefulSetName gets statefulset name from podName

func JobName

func JobName(eJobName string) (string, error)

JobName returns a unique, short name for a given eJob k8s allows 63 chars, but the job's pod will have -\d{6} (=7 chars) appended. So we return max 56 chars: name39-suffix16

func OrdinalFromPodName

func OrdinalFromPodName(name string) int

OrdinalFromPodName returns ordinal from pod name

func Sanitize

func Sanitize(name string) string

Sanitize produces valid k8s names, i.e. for containers: [a-z0-9]([-a-z0-9]*[a-z0-9])? The result is DNS label compatible and usable as a path segment name.

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

func SanitizeSubdomain

func SanitizeSubdomain(name string) string

SanitizeSubdomain allows more than Sanitize, cannot be used for DNS or path segments.

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

func SpecIndex added in v0.0.2

func SpecIndex(azIndex int, podOrdinal int) int

SpecIndex return the job sepc index. We use a very large value as a maximum number of replicas per instance group, per AZ We do this in lieu of using the actual replica count, which would cause pods to always restart

func TruncateMD5

func TruncateMD5(s string, maxLen int) string

TruncateMD5 truncates the string to n chars and adds a hex encoded md5 sum. Producing a uniq representation of the original string, if maxLen >= 32. Example: names are limited to 63 characters so we recalculate the name as <name trimmed to 30 characters>-<md5 hash of name>

func VolumeName

func VolumeName(secretName string) string

VolumeName generate volume name based on secret name

Types

This section is empty.

Jump to

Keyboard shortcuts

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