util

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 17 Imported by: 19

Documentation

Index

Constants

View Source
const (
	NamespaceSeparator = '_'
)

Variables

View Source
var (
	InternalLabelPrefixes = []string{
		"kiyot.",
		"io.kubernetes",
		"kubernetes.io",
	}
)
View Source
var (
	// VERSION is set during the build from "git describe --dirty".
	VERSION string = ""
)

Functions

func AWSEnvVarsSet

func AWSEnvVarsSet() bool

func AzureEnvVarsSet

func AzureEnvVarsSet() bool

func CIDRInsideCIDR

func CIDRInsideCIDR(cidrA string, cidrB string) bool

func CIDRInsideCIDRs

func CIDRInsideCIDRs(cidrA string, cidrs []string) bool

func CPUCoresFraction

func CPUCoresFraction(q *resource.Quantity) float32

func CreateBoundNodeNameTag

func CreateBoundNodeNameTag(nametag, podName string) string

func CreateClusterResourceGroupName

func CreateClusterResourceGroupName(controllerID string) string

func CreateClusterResourcePrefix

func CreateClusterResourcePrefix(controllerID string) string

func CreateEtcHosts

func CreateEtcHosts(dnsConfigurer *dns.Configurer, podName, namespace, specHostname, specSubdomain string, podIPs []string, hostAliases []api.HostAlias, useHostNetwork bool) ([]byte, error)

CreateEtcHosts creates an /etc/hosts file for the pod.

func CreateResourceGroupName

func CreateResourceGroupName(region string) string

func CreateSecurityGroupName

func CreateSecurityGroupName(controllerID, svcName string) string

GCP requires names to follow the regex: [a-z]([-a-z0-9]*[a-z0-9])?

func CreateUnboundNodeNameTag

func CreateUnboundNodeNameTag(nametag string) string

func EnvVarsToMap

func EnvVarsToMap(envs []api.EnvVar) map[string]string

func ExpandCommandAndArgs

func ExpandCommandAndArgs(spec api.PodSpec) api.PodSpec

func FilterKeysWithPrefix

func FilterKeysWithPrefix(m map[string]string, prefixes []string) map[string]string

If we cared, would be a good place to use a prefix tree...

func GCEEnvVarsSet added in v1.0.0

func GCEEnvVarsSet() bool

func GeneratePodHostname

func GeneratePodHostname(dnsConfigurer *dns.Configurer, podName, namespace, specHostname, specSubdomain string) (string, error)

func GetNameFromString

func GetNameFromString(n string) string

func GetNamespaceFromString

func GetNamespaceFromString(n string) string

func GetStructStringField

func GetStructStringField(objs []interface{}, field string) []string

func GetVersionInfo

func GetVersionInfo() api.VersionInfo

func MakeTempFile

func MakeTempFile(prefix string) (*os.File, func())

func MakeTempFileName

func MakeTempFileName(prefix string) (string, func())

func MapDiff

func MapDiff(spec, status map[string]interface{}) ([]string, []string, []string)

func MapUserDiff

func MapUserDiff(spec, status map[string]interface{}, differ func(a, b interface{}) bool) ([]string, []string, []string)

func NextIP

func NextIP(ip net.IP, inc uint) net.IP

func ParseImageSpec

func ParseImageSpec(image string) (string, string, error)

Most registry URLs don't have a leading scheme (e.g. http://). This means that we can't use url.Parse to find the host name from the image's path. We'll use some heuristics to get the server and image path.

func PartitionSlice

func PartitionSlice(slice interface{}, isFront func(i int) bool)

take a slice and move all elements that satisfy isFront to the front of the slice. isFront is a function that, given an index of an element, looks up that elemenet in the slice and returns true if the element should be at the front of the slice.

func Retry

func Retry(timeout time.Duration, f func() error, isRetryable func(error) bool) error

This got written after a few Old Rasputins. I highly recommend the beer but not as much as I recommend reading this code with a critical eye

func SplitNamespaceAndName

func SplitNamespaceAndName(n string) (string, string)

func StringInSlice

func StringInSlice(s string, slice []string) bool

func StringMapDifference

func StringMapDifference(a, b map[string]string) map[string]string

func StringMapIntersection

func StringMapIntersection(a, b map[string]string) map[string]string

func StringMapKeys

func StringMapKeys(a map[string]string) []string

func StringMapUnion

func StringMapUnion(a, b map[string]string) map[string]string

func StringMapValues

func StringMapValues(a map[string]string) []string

func StringSetKeys

func StringSetKeys(a map[string]struct{}) []string

func StringSliceDifference

func StringSliceDifference(a, b []string) []string

func StringSliceEqual

func StringSliceEqual(a, b []string) bool

func StringSliceIntersection

func StringSliceIntersection(a, b []string) []string

func StringSliceMapKeys

func StringSliceMapKeys(a map[string][]string) []string

func StringSliceRemove

func StringSliceRemove(s []string, r string) []string

func StringSliceUnion

func StringSliceUnion(a, b []string) []string

func StringSliceUnique

func StringSliceUnique(a []string) []string

func ToGBFloat32

func ToGBFloat32(q *resource.Quantity) float32

func ToGBRoundUp

func ToGBRoundUp(q *resource.Quantity) int32

func ToGiBFloat32

func ToGiBFloat32(q *resource.Quantity) float32

func ToGiBRoundUp

func ToGiBRoundUp(q *resource.Quantity) int32

func ToMiBFloat32

func ToMiBFloat32(q *resource.Quantity) float32

func ToMiBRoundUp

func ToMiBRoundUp(q *resource.Quantity) int32

func Version

func Version() string

func WithNamespace

func WithNamespace(ns, name string) string

func WrapError

func WrapError(err error, format string, args ...interface{}) error

Types

type WrappedError

type WrappedError struct {
	// contains filtered or unexported fields
}

func (WrappedError) Cause

func (e WrappedError) Cause() error

func (WrappedError) Error

func (e WrappedError) Error() string

Directories

Path Synopsis
Useful for 1 allowing the user to update the cloud-init file without restarting the serer.
Useful for 1 allowing the user to update the cloud-init file without restarting the serer.
Package errors implements various utility functions and types around errors.
Package errors implements various utility functions and types around errors.
k8s
Package rand provides utilities related to randomization.
Package rand provides utilities related to randomization.
Create a map that will timeout entries and call a callback when an object in the map has expired
Create a map that will timeout entries and call a callback when an object in the map has expired

Jump to

Keyboard shortcuts

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