utils

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManagerHostPathMount = "/local/plugins"
	PluginDirectoryPath  = "PLUGIN_PATH"
	PluginHostPath       = "/greenhouse/local/plugins"
)

Variables

View Source
var DefaultElapsedTime = 30 * time.Second

Functions

func CheckIfFileExists

func CheckIfFileExists(f string) bool

func CleanUp

func CleanUp(files ...string)

func FromK8sObjectToYaml

func FromK8sObjectToYaml(obj client.Object, gvk schema.GroupVersion) ([]byte, error)

FromK8sObjectToYaml - Converts a Kubernetes object to a YAML document

func FromYamlToK8sObject

func FromYamlToK8sObject(doc string, resources ...any) error

FromYamlToK8sObject - Converts a YAML document to a Kubernetes object if yaml contains multiple documents, then corresponding kubernetes objects should be provided

func GetHostPlatform

func GetHostPlatform() string

func GetManagerHelmValues

func GetManagerHelmValues() map[string]interface{}

GetManagerHelmValues - returns the default values for the manager helm chart

func Int32P

func Int32P(i int32) *int32

func Log

func Log(args ...any)

func LogErr

func LogErr(format string, args ...any)

func Logf

func Logf(format string, args ...any)

func NewKLog

func NewKLog(ctx context.Context) logr.Logger

func RandomWriteToTmpFolder

func RandomWriteToTmpFolder(fileName, content string) (string, error)

RandomWriteToTmpFolder - writes the provided content to temp folder in OS Concurrent writes do not conflict as the file name is appended with a random string

func RawK8sInterface

func RawK8sInterface(yamlBytes []byte) (map[string]interface{}, error)

RawK8sInterface - unmarshalls the provided YAML bytes into a map[string]interface{}

func SliceContains

func SliceContains(slice []string, item string) bool

func StringP

func StringP(s string) *string

func Stringify

func Stringify(data []map[string]interface{}) (string, error)

func Stringy

func Stringy(data map[string]interface{}) (string, error)

func WaitUntilJobSucceeds

func WaitUntilJobSucceeds(ctx context.Context, k8sClient client.Client, name, namespace string) error

WaitUntilJobSucceeds - waits until a job succeeds in the given namespace with a backoff strategy

func WaitUntilSecretCreated

func WaitUntilSecretCreated(ctx context.Context, k8sClient client.Client, name, namespace string) error

WaitUntilSecretCreated - waits until a secret is created in the given namespace with a backoff strategy

func WriteToPath

func WriteToPath(dir, fileName, content string) error

Types

type Shell

type Shell struct {
	Cmd  string
	Vars map[string]string
}

func (Shell) Exec

func (s Shell) Exec() error

Exec executes a single shell command

func (Shell) ExecWithResult

func (s Shell) ExecWithResult() (string, error)

ExecWithResult executes the shell command and returns the output of the command

type ShellPipe

type ShellPipe struct {
	Shells []Shell
}

func (ShellPipe) Exec

func (s ShellPipe) Exec() error

Exec executes a set of commands serially and pipes the output of each command to the next

Jump to

Keyboard shortcuts

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