toolkit

package
v0.0.0-...-ae32cb6 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindConfigTemplate = `` /* 193-byte string literal not displayed */

	// https://github.com/kubernetes-sigs/kind/releases/tag/v0.14.0
	KindNodeImageLatest = KindNodeImageV24
	KindNodeImageV24    = "kindest/node:v1.24.0@sha256:0866296e693efe1fed79d5e6c7af8df71fc73ae45e3679af05342239cdc5bc8e"
	KindNodeImageV23    = "kindest/node:v1.23.6@sha256:b1fa224cc6c7ff32455e0b1fd9cbfd3d3bc87ecaa8fcb06961ed1afb3db0f9ae"
	KindNodeImageV22    = "kindest/node:v1.22.9@sha256:8135260b959dfe320206eb36b3aeda9cffcb262f4b44cda6b33f7bb73f453105"
	KindNodeImageV21    = "kindest/node:v1.21.12@sha256:f316b33dd88f8196379f38feb80545ef3ed44d9197dca1bfd48bcb1583210207"
	KindNodeImageV20    = "kindest/node:v1.20.15@sha256:6f2d011dffe182bad80b85f6c00e8ca9d86b5b8922cdf433d53575c4c5212248"
	KindNodeImageV19    = "kindest/node:v1.19.16@sha256:d9c819e8668de8d5030708e484a9fdff44d95ec4675d136ef0a0a584e587f65c"
	KindNodeImageV18    = "kindest/node:v1.18.20@sha256:738cdc23ed4be6cc0b7ea277a2ebcc454c8373d7d8fb991a7fcdbd126188e6d7"
)

Variables

This section is empty.

Functions

func ExitWithError

func ExitWithError(logger *log.Logger, err error)

ExitWithError will call os.Exit(1) if the given err is not nil, logging that something bad happened.

func GetFunctionName

func GetFunctionName(i any) (string, error)

GetFunctionName takes in a function and uses reflect to get its name as a string.

func MakeRange

func MakeRange[T interface {
	constraints.Integer | constraints.Float
}](min, max, step T) []T

MakeRange is a generic that creates a slice of numbers in the range [min, max), separated by the given step value.

func NewKindConfig

func NewKindConfig(
	logger *log.Logger, name string, nWorkers int, nControlPlanes int, withCNI bool, image string,
) (string, error)

NewKindConfig uses given parameters to render a kind configuration (kind.x-k8s.io/v1alpha4). name will set the cluster's name. nWorkers determines how many worker nodes will be created. nControlPlanes determines how many control plane nodes will be created. withCNI toggles kind setting up its default CNI upon cluster creation. image determines which container image will be used for nodes.

func PPrint

func PPrint(n interface{}) error

PPrint takes the given value, marshalls it using json and prints it using fmt.

func PathExists

func PathExists(path string) bool

PathExists return true if the given path exists on disk. Simple wrapper around os.Stat.

func PathIsDir

func PathIsDir(path string) bool

PathIsDir returns if the given path is a directory.

func PullStrKey

func PullStrKey(k string, m map[string]interface{}) (string, error)

PullStrKey returns the string value of the given key within the given string to interface map. Useful when working with unstructured kubernetes objects.

func RandomString

func RandomString(n int) string

RandomString returns a string of random characters of length n.

func SimpleRetry

func SimpleRetry(target func() error, maxAttempts int, delay time.Duration, logger ...*log.Logger) error

SimpleRetry will run the target function maxAttempts times, waiting delay in-between attempts. If a logger is given, then attempts will be logged.

func SliceContains

func SliceContains[T comparable](slice []T, target T) bool

SliceContains is a generic that checks if the given slices contains the given target.

Types

type KindConfigNodeParams

type KindConfigNodeParams struct {
	Role  string `json:"role"`
	Image string `json:"image"`
}

KindConfigNodeParams is a bare-bones representation of various parameters which can be set to configure a kind node within the `KindConfigTemplate`. It is eventually passed into `KindConfigTemplate` through `KindConfigTemplateParams`.

type KindConfigTemplateParams

type KindConfigTemplateParams struct {
	Name  string                 `json:"name"`
	NoCNI bool                   `json:"noCNI"`
	Nodes []KindConfigNodeParams `json:"nodes"`
}

KindConfigTemplateParams is used to set values within the `KindConfigTemplate`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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