util

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogLevelDebug : Log level constants for debug level. Larger numbers represent less important logs.
	LogLevelDebug = 1

	// LogLevelWarning : Log level constants for warning level. Larger numbers represent less important logs.
	LogLevelWarning = -1
)
View Source
const (
	BlueprintDirectoryName      = "blueprint"
	BlueprintFileName           = v1alpha1.BlueprintFileName
	ComponentDescriptorFileName = "component-descriptor.yaml"
	ResourcesFileName           = "resources.yaml"
)

Variables

This section is empty.

Functions

func BlueprintDirectoryPath

func BlueprintDirectoryPath(componentPath string) string

func BlueprintFilePath

func BlueprintFilePath(componentPath string) string

func BuildKubeClientFromConfigOrCurrentClusterContext added in v0.17.0

func BuildKubeClientFromConfigOrCurrentClusterContext(kubeconfig string, scheme *runtime.Scheme) (client.Client, string, error)

func BuildKubernetesClusterTarget

func BuildKubernetesClusterTarget(name, namespace, kubeconfigPath, secretName string) (*lsv1alpha1.Target, *corev1.Secret, error)

func BuildTargetWithContent added in v0.20.0

func BuildTargetWithContent(name, namespace string, targetType lsv1alpha1.TargetType, content []byte, secretName string) (*lsv1alpha1.Target, *corev1.Secret)

func CheckAndWaitUntilAllPodsAreReady

func CheckAndWaitUntilAllPodsAreReady(k8sClient client.Client, namespace string, sleepTime time.Duration, maxRetries int) (bool, error)

CheckAndWaitUntilAllPodsAreReady checks and wait until all pods have the ready condition set to true. Returns an error on failure or if timeout (sleepTime and maxRetries is reached). Returns a boolean indicating if all pods have the ready condition true on return.

func CheckAndWaitUntilLandscaperInstallationSucceeded

func CheckAndWaitUntilLandscaperInstallationSucceeded(k8sClient client.Client, key types.NamespacedName, sleepTime time.Duration, maxRetries int) (bool, error)

CheckAndWaitUntilLandscaperInstallationSucceeded checks and wait until the installation is on status succeeded. Returns an error on failure or if timeout (sleepTime and maxRetries is reached). Returns a boolean indicating if the installation succeeded.

func CheckAndWaitUntilNoInstallationsInNamespaceExists

func CheckAndWaitUntilNoInstallationsInNamespaceExists(k8sClient client.Client, namespace string, sleepTime time.Duration, maxRetries int) (bool, error)

CheckAndWaitUntilNoInstallationsInNamespaceExists periodically checks and wait until no installation in the namespace remains. Returns an error on failure or if timeout (sleepTime and maxRetries is reached). Returns a boolean indicating if no installations remains on return.

func CheckAndWaitUntilObjectNotExistAnymore

func CheckAndWaitUntilObjectNotExistAnymore(k8sClient client.Client, objKey types.NamespacedName, obj client.Object, sleepTime time.Duration, maxRetries int) (bool, error)

CheckAndWaitUntilObjectNotExistAnymore periodically checks and wait until the object does not exist anymore. Returns an error on failure or if timeout (sleepTime and maxRetries is reached). Returns a boolean indicating if the object remains on return.

func CheckConditionPeriodically

func CheckConditionPeriodically(conditionFunc func() (bool, error), sleepTime time.Duration, maxRetries int) (bool, error)

CheckConditionPeriodically checks the success of a function peridically. Returns timeout(bool) to indicate the success of the function and propagates possible errors of the function.

func CheckIngressReady added in v0.33.0

func CheckIngressReady(k8sClient client.Client, namespace string, sleepTime time.Duration, maxRetries int) (string, error)

func ComponentDescriptorFilePath

func ComponentDescriptorFilePath(componentPath string) string

func DeleteNamespace

func DeleteNamespace(k8sClient client.Client, namespace string, sleepTime time.Duration, maxRetries int) error

DeleteNamespace deletes a namespace (if it exists). First, a graceful delete will be tried with a timeout. On timeout, the namespace will be deleted forcefully by removing the finalizers on the Landscaper CRs.

func ExecCommandBlocking

func ExecCommandBlocking(command string) error

ExecCommandBlocking executes a command and wait for its completion.

func ExecCommandNonBlocking

func ExecCommandNonBlocking(command string, resultCh chan<- CmdResult) (*exec.Cmd, error)

ExecCommandNonBlocking executes a command without without blocking. Returns a Cmd that can be used to stop the command. When the command has stopped or failed, the result is written into the channel resultCh.

func ExecutionFileName

func ExecutionFileName(executionName string) string

func ExecutionFilePath

func ExecutionFilePath(componentPath, executionName string) string

func FindNodeByPath

func FindNodeByPath(node *yamlv3.Node, path string) (*yamlv3.Node, *yamlv3.Node)

func GetBlueprintResourceName added in v0.24.0

func GetBlueprintResourceName(cd *modeltypes.ComponentDescriptor) (string, error)

GetBlueprintResourceName returns the name of the blueprint resource in the provided component descriptor, provided the component descriptor contains exactly one blueprint resource.

func GetK8sClientFromCurrentConfiguredCluster added in v0.4.0

func GetK8sClientFromCurrentConfiguredCluster() (client.Client, string, error)

GetK8sClientFromCurrentConfiguredCluster returns a k8sClient and a namespace from the current context of the kubectl program.

func GetKubernetesClusterTargetContent added in v0.20.0

func GetKubernetesClusterTargetContent(kubeconfigPath string) ([]byte, error)

func IsDirectoryEmpty

func IsDirectoryEmpty(path string) (bool, error)

func MarshalYaml

func MarshalYaml(node *yamlv3.Node) ([]byte, error)

func ResourcesFilePath

func ResourcesFilePath(componentPath string) string

Types

type CmdResult

type CmdResult struct {
	Error  error
	Stdout string
	StdErr string
}

Jump to

Keyboard shortcuts

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