names

package
v0.0.152 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Overview

Package names defines facilities to work with Kubernetes names

It lets clients validate, transform and process names that can be used in Kubernetes. An example of such transformations would be transforming an Instance ID to a slug. A slug is a human-readable, friendly representation of the full instance ID which is also designed to be compatible with Kubernetes conventions for resource names.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSlug = errors.New("Current inputs produce an invalid slug")
)

Functions

func GetNamespaceLessSlug added in v0.0.139

func GetNamespaceLessSlug(slug, namespace string) (string, error)

func ImageInfoToSlug

func ImageInfoToSlug(image, imageHash string) (string, error)

ImageInfoToSlug returns a human-friendly representation for a given image information

If the given inputs would produce an invalid slug, it returns an appropriate error

func InstanceIDToSlug

func InstanceIDToSlug(name, namespace, kind, hashedID string) (string, error)

InstanceIDToSlug retuns a human-friendly representation given a description of an instance ID

If the given inputs would produce an invalid slug, it returns an appropriate error

func IsValidDNSLabelName

func IsValidDNSLabelName(s string) bool

IsValidDNSLabelName returns true if a given string is a valid DNS label name as defined in the Kubernetes docs

func IsValidDNSSubdomainName

func IsValidDNSSubdomainName(s string) bool

IsValidDNSSubdomainName returns true if a given string is a valid DNS Subdomain name as defined in the Kubernetes docs

func IsValidLabelValue added in v0.0.143

func IsValidLabelValue(value string) bool

isValidLabelValue checks if a string is a valid Kubernetes label value as defined in the Kubernetes docs

func IsValidSlug

func IsValidSlug(s string) bool

IsValidSlug returns true if a given string is a valid slug, else false

A string is considered a valid slug if it can be used as a name of a Kubernetes resource

func ResourceToSlug added in v0.0.144

func ResourceToSlug(resource workloadinterface.IMetadata) (string, error)

ResourceToSlug returns a human-friendly representation for a given resource The slug is generated based on the API version, kind, namespace and name of the resource

func RoleBindingResourceToSlug added in v0.0.144

func RoleBindingResourceToSlug(subject workloadinterface.IMetadata, role workloadinterface.IMetadata, roleBinding workloadinterface.IMetadata) (string, error)

RoleBindingResourceToSlug returns a human-friendly representation for a given role binding resource The slug is generated based on the subject, role and role binding resources of the role binding

func SanitizeLabelValues added in v0.0.143

func SanitizeLabelValues(labels map[string]string)

func StringToSlug added in v0.0.144

func StringToSlug(str string) (string, error)

StringToSlug receives any string and returns a human-friendly representation of it as a slug

If the given inputs would produce an invalid slug, it returns an appropriate error

func ToValidDNSSubdomainName added in v0.0.143

func ToValidDNSSubdomainName(input string) (string, error)

func ToValidLabelValue added in v0.0.143

func ToValidLabelValue(input string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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