utils

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package utils contains common definition and utils used across liqoctl

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommand added in v1.0.1

func AddCommand(cmd, subCmd *cobra.Command)

AddCommand wraps the cobra AddCommand function, it adds a subcommand to a command and patches the description with the current executable name.

func DescWithTemplate added in v1.0.1

func DescWithTemplate(str, executable string) string

DescWithTemplate returns a string that has the liqoctl name templated out with the current executable name. DescWithTemplate templates on the '{{ .Executable }}' variable.

func ExtractValuesFromArgumentList

func ExtractValuesFromArgumentList(key string, argumentList []string) (values string, err error)

ExtractValuesFromArgumentList extracts the argument value from an argument list. When the argument is found, ok is true and the value is returned. When the argument is found but no value is provided, ok is true and an empty string is returned. When the argument is not found, ok is false and the value is an empty string.

func ExtractValuesFromArgumentListOrDefault

func ExtractValuesFromArgumentListOrDefault(key string, argumentList []string, defaultValue string) string

ExtractValuesFromArgumentListOrDefault extracts the argument value from an argument list or returns a default value.

func ExtractValuesFromNestedMaps

func ExtractValuesFromNestedMaps(m map[string]interface{}, keys ...string) (val interface{}, err error)

ExtractValuesFromNestedMaps takes a map and a list of keys and visits a tree of nested maps using the keys in the order provided. At each iteration, if the number of non-visited keys is 1, the function returns the value associated to the last key, else if it is greater than 1, the function expects the value to be a map and a new recursive iteration happens. In case the key is not found, an empty string is returned. In case no keys are provided, an error is returned. Example:

m := map[string]interface{}{
	"first": map[string]interface{}{
		"second": map[string]interface{}{
			"third": "value",
		},
	},
}
ValueFor(m, "first", "second", "third") // returns "value", nil
ValueFor(m, "first", "second") // returns map[string]interface{}{ "third": "value" }, nil
ValueFor(m, "first", "third") // returns "", nil
ValueFor(m) // returns nil, "At least one key is required"

func GetCommandName added in v1.0.1

func GetCommandName() string

GetCommandName gets the command name to be used in the help message.

func GetCtrlManagerContainer

func GetCtrlManagerContainer(ctrlDeployment *appsv1.Deployment) (*corev1.Container, error)

GetCtrlManagerContainer retrieves the container of the controller manager from the deployment.

func ParseArgsMultipleValues

func ParseArgsMultipleValues(values, separator string) (map[string]string, error)

ParseArgsMultipleValues parse a string containing multiple key/value couples separated by ',' (eg. key1=value1,key2=value2).

func PatchCommandWithTemplate added in v1.0.1

func PatchCommandWithTemplate(cmd *cobra.Command) *cobra.Command

PatchCommandWithTemplate patches the command description with the current executable name.

func RetrieveLiqoControllerManagerDeploymentArgs

func RetrieveLiqoControllerManagerDeploymentArgs(ctx context.Context, cl client.Client, namespace string) ([]string, error)

RetrieveLiqoControllerManagerDeploymentArgs retrieves the list of arguments associated with the liqo controller manager deployment.

Types

This section is empty.

Directories

Path Synopsis
Package pod provides utilities to work with pods.
Package pod provides utilities to work with pods.

Jump to

Keyboard shortcuts

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