util

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package util contains common definition and utils used across liqoctl

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractValuesFromArgumentList added in v0.8.0

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 ParseArgsMultipleValues added in v0.7.0

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 RetrieveLiqoAuthDeploymentArgs added in v0.7.0

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

RetrieveLiqoAuthDeploymentArgs retrieves the list of arguments associated with the liqo auth deployment.

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.

Jump to

Keyboard shortcuts

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