util

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: Apache-2.0 Imports: 24 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 BuildKubernetesClusterTarget

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

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 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 GetBlueprintResource added in v0.3.0

func GetBlueprintResource(cd *cdv2.ComponentDescriptor, blueprintResourceName string) (*cdv2.Resource, error)

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 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