utils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: Apache-2.0 Imports: 18 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAll

func ApplyAll(ctx context.Context, cl client.Client, updates map[client.Object]Updater) error

ApplyAll applies all the update objects in the list called updates.

func Atoi32

func Atoi32(s string) (int32, error)

Atoi32 converts string to int32 in a safe way. You get error when the value is out of the 32-bit range.

This is a wrapper function of strconv.ParseInt.

func B64Decode

func B64Decode(s *core.Secret, key string) (string, error)

B64Decode decodes the provided secret

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to the passed boolean.

func Contains added in v0.0.2

func Contains(list []string, s string) bool

func CopySecret

func CopySecret(ctx context.Context, client client.Client, srcSecretRef types.NamespacedName, dstSecretRef types.NamespacedName) (error, *core.Secret)

CopySecret will return a *core.Secret that is copied from a source NamespaceName and intended to be applied into a destination NamespacedName

func FalsePtr

func FalsePtr() *bool

FalsePtr returns a pointer to True

func GetCustomLabeler

func GetCustomLabeler(labels map[string]string, nn types.NamespacedName, baseResource client.Object) func(metav1.Object)

// GetCustomLabeler takes a set of labels and returns a labeler function that // will apply those labels to a reource.

func GetKindFromObj

func GetKindFromObj(scheme *runtime.Scheme, object runtime.Object) (schema.GroupVersionKind, error)

GetKindFromObj retrieves GVK associated with registered runtime.Object

func Int32

func Int32(i int) (int32, error)

Int32 converts int to int32 in a safe way. You get error when the value is out of the 32-bit range.

func Int32Ptr

func Int32Ptr(n int) *int32

Int32Ptr returns a pointer to an int32 version of n

func Int64Ptr

func Int64Ptr(n int64) *int64

Int64Ptr returns a pointer to an int64

func IntMax

func IntMax(listStrInts []string) (string, error)

IntMax takes a list of integers as strings and returns the maximum.

func IntMin

func IntMin(listStrInts []string) (string, error)

IntMin takes a list of integers as strings and returns the minimum.

func IntPtr

func IntPtr(i int) *int

IntPtr returns a pointer to the passed integer.

func ListMerge

func ListMerge(listStrs []string) (string, error)

ListMerge takes a list comma separated strings and performs a set union on them.

func MakeLabeler

func MakeLabeler(nn types.NamespacedName, labels map[string]string, obj client.Object) func(metav1.Object)

MakeLabeler creates a function that will label objects with metadata from the given namespaced name and labels

func MakeOwnerReference

func MakeOwnerReference(i client.Object) metav1.OwnerReference

func MakePVC

func MakePVC(pvc *core.PersistentVolumeClaim, nn types.NamespacedName, labels map[string]string, size string, baseResource client.Object)

// MakePVC takes a PVC object and applies the correct ownership and labels to it.

func MakeService

func MakeService(service *core.Service, nn types.NamespacedName, labels map[string]string, ports []core.ServicePort, baseResource client.Object, nodePort bool)

// MakeService takes a service object and applies the correct ownership and labels to it.

func RandString

func RandString(n int) string

RandString generates a random string of length n

func StringPtr

func StringPtr(str string) *string

StringPtr returns a pointer to True

func TruePtr

func TruePtr() *bool

TruePtr returns a pointer to True

func UpdateAllOrErr

func UpdateAllOrErr(ctx context.Context, cl client.Client, nn types.NamespacedName, obj ...client.Object) (map[client.Object]Updater, error)

UpdateAllOrErr queries the client for a range of objects and returns updater objects for each.

Types

type Updater

type Updater bool

Updater is a bool type object with functions attached that control when a resource should be created or applied.

func UpdateOrErr

func UpdateOrErr(err error) (Updater, error)

UpdateOrErr returns an update object if the err supplied is nil.

func (*Updater) Apply

func (u *Updater) Apply(ctx context.Context, cl client.Client, obj client.Object) error

Apply will apply the resource if it already exists, and create it if it does not. This is based on the bool value of the Update object.

Jump to

Keyboard shortcuts

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