norm

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 1 Imported by: 4

Documentation

Overview

Package norm provides normalization routines for making arbitrary text compatible with Kubernetes's field requirements.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyDNSLabelName

func AnyDNSLabelName(raw string, opts ...AnyDNSLabelNameOption) string

AnyDNSLabelName normalizes a raw string so that it conforms to the structure of a DNS label: it must be all lowercase, contain only alphanumeric characters and dashes; and the last character must be alphanumeric. In the case of RFC 1035, the first character must be alphabetical, while in the case of RFC 1123, the first character must be alphanumeric.

func AnyDNSLabelNameSuffixed added in v0.2.0

func AnyDNSLabelNameSuffixed(prefix, suffix string) string

AnyDNSLabelNameSuffixed calls AnyDNSLabelName ensuring that the entirety of the given suffix is retained if possible.

func AnyDNSSubdomainName

func AnyDNSSubdomainName(raw string) string

AnyDNSSubdomainName normalizes a raw string so that it conforms to the structure of a DNS domain (RFC 1123): it must be all lowercase; contain only alphanumeric characters and dashes; and the first and last characters must be alphanumeric.

func AnyQualifiedName added in v0.6.0

func AnyQualifiedName(raw string) string

AnyQualifiedName normalizes a raw string so that it conforms to the structure of a Kubernetes qualified name.

Qualified names optionally start with a DNS subdomain followed by a slash. They always begin and end with an alphanumeric character, and internally may contain alphanumeric characters, dashes, underscores, and dots up to 63 characters.

func MetaGenerateName

func MetaGenerateName(raw string) string

MetaGenerateName normalizes a Kubernetes metadata generateName field. It is opinionated in that it also forces a dash before the five characters generated by the Kubernetes API.

func MetaName

func MetaName(raw string) string

MetaName normalizes a Kubernetes metadata name field.

func MetaNameSuffixed added in v0.2.0

func MetaNameSuffixed(prefix, suffix string) string

MetaNameSuffixed normalizes a Kubernetes metadata name field ensuring that the entirety of the given suffix is retained if possible.

Types

type AnyDNSLabelNameOption added in v0.6.0

type AnyDNSLabelNameOption interface {
	ApplyToAnyDNSLabelNameOptions(target *AnyDNSLabelNameOptions)
}

type AnyDNSLabelNameOptions added in v0.6.0

type AnyDNSLabelNameOptions struct {
	DNSNameRFC DNSNameRFC
}

func (*AnyDNSLabelNameOptions) ApplyOptions added in v0.6.0

func (o *AnyDNSLabelNameOptions) ApplyOptions(opts []AnyDNSLabelNameOption)

type DNSNameRFC added in v0.6.0

type DNSNameRFC string
const (
	DNSNameRFC1035 DNSNameRFC = "1035"
	DNSNameRFC1123 DNSNameRFC = "1123"
)

type WithDNSNameRFC added in v0.6.0

type WithDNSNameRFC DNSNameRFC

func (WithDNSNameRFC) ApplyToAnyDNSLabelNameOptions added in v0.6.0

func (wdnr WithDNSNameRFC) ApplyToAnyDNSLabelNameOptions(target *AnyDNSLabelNameOptions)

Jump to

Keyboard shortcuts

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