utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1024
	MB = KB * 1024
	GB = MB * 1024
)
View Source
const (
	EnvNamespaceKey = "POD_NAMESPACE"
)

Variables

This section is empty.

Functions

func AddOrSwapString

func AddOrSwapString(strings []string, str string) (bool, []string)

AddOrSwapString Add an element to the string array, swap it with the last element if it is in the array, or append it directly to the end if it does not exist. Gives whether the array has changed

Example:
[], "a" -> true, []string{"a"}
["a"], "b" -> true, []string{"a", "b"}
["a", "b"], "a" -> true, []string{"b", "a"}
["a", "b", "a"], "a" -> false, []string{"a", "b", "a"}

func AddString

func AddString(finalizers []string, f string) []string

func BytesToSizedStr

func BytesToSizedStr(bytes int64) string

BytesToSize converts size(byte as the unit) to string with appropriate unit ending

func ContainString

func ContainString(finalizers []string, f string) bool

func GetCurrentNamespace

func GetCurrentNamespace() string

func RFC3339Time

func RFC3339Time(timeStr string) (time.Time, error)

RFC3339Time parses a time string to a Time with RFC3339 format

func RemoveString

func RemoveString(finalizers []string, f string) []string

func UnstructuredToStructured

func UnstructuredToStructured(unstructuredObj *unstructured.Unstructured, target any) error

UnstructuredToStructured convert unstructured object to a structured target(must be a pointer)

func ValidateClient

func ValidateClient(c client.Client, cli dynamic.Interface) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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