configuration

package
v0.0.0-...-e5246a7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 11

Documentation

Index

Constants

View Source
const (
	// WatchNamespaceEnvVar is the constant for env variable WATCH_NAMESPACE
	// which is the namespace where the watch activity happens.
	// this value is empty if the operator is running with clusterScope.
	WatchNamespaceEnvVar = "WATCH_NAMESPACE"

	// OperatorNameEnvVar is the constant for env variable OPERATOR_NAME
	// which is the name of the current operator
	OperatorNameEnvVar = "OPERATOR_NAME"
)

Variables

This section is empty.

Functions

func CopyOf

func CopyOf(originalMap map[string]map[string]string) map[string]map[string]string

func GetBool

func GetBool(value *bool, defaultValue bool) bool

func GetCachedConfig

func GetCachedConfig() (runtime.Object, map[string]map[string]string)

getCachedConfig returns the cached toolchainconfig or a toolchainconfig with default values

func GetConfig

func GetConfig(cl client.Client, configObj client.Object) (runtime.Object, map[string]map[string]string, error)

getConfig returns a cached configuration object If no config is stored in the cache, then it retrieves it from the cluster using the provided LoadConfiguration func and stores in the cache. If the resource is not found, then returns nil for the configuration and secret. If any failure happens while getting the configuration object or secrets, then returns an error.

func GetDuration

func GetDuration(value *string, defaultValue time.Duration) time.Duration

GetDuration parses the given value as a Duration and returns the value. The default value is returned if the value is nil or cannot be parsed as a duration.

func GetInt

func GetInt(value *int, defaultValue int) int

func GetInt32

func GetInt32(value *int32, defaultValue int32) int32

func GetOperatorName

func GetOperatorName() (string, error)

GetOperatorName return the operator name

func GetString

func GetString(value *string, defaultValue string) string

func GetWatchNamespace

func GetWatchNamespace() (string, error)

GetWatchNamespace returns the namespace the operator should be watching for changes

func LoadFromConfigMap

func LoadFromConfigMap(prefix, resourceKey string, cl client.Client) error

LoadFromConfigMap retrieves the host operator configmap and sets environment variables in order to override default configurations. If no configmap is found, then configuration will use all defaults. Returns error if WATCH_NAMESPACE is not set, if the resource GET request failed (for other reasons apart from isNotFound) and if setting env vars fails.

prefix: represents the operator prefix (HOST_OPERATOR/MEMBER_OPERATOR) resourceKey: is the env var which contains the configmap resource name. cl: is the client that should be used to retrieve the configmap.

func LoadFromSecret

func LoadFromSecret(resourceKey string, cl client.Client) (map[string]string, error)

LoadFromSecret retrieves an operator secret, loads all keys and values from the secret and stores them in a map. This map is then returned by the function. The function doesn't take into account any default values - this has to be handled while getting the values in the configuration object.

resourceKey: is the env var which contains the secret resource name. cl: is the client that should be used to retrieve the secret.

func LoadLatest

func LoadLatest(cl client.Client, configObj client.Object) (runtime.Object, map[string]map[string]string, error)

loadLatest retrieves the latest configuration object and secrets using the provided client and updates the cache. If the resource is not found, then returns nil for the configuration and secret. If any failure happens while getting the configuration object or secrets, then returns an error.

func LoadSecrets

func LoadSecrets(cl client.Client, namespace string) (map[string]map[string]string, error)

LoadSecrets lists all secrets in the provided namespace and indexes them into a map by name along with its secret data. Service account secrets are skipped.

func NewToolchainConfigObjWithReset

func NewToolchainConfigObjWithReset(t *testing.T, options ...testconfig.ToolchainConfigOption) *toolchainv1alpha1.ToolchainConfig

NewToolchainConfigObjWithReset creates a ToolchainConfig object and adds the cache Reset to the test cleanup. It is located here to prevent import cycles between this package and the test package.

func ResetCache

func ResetCache()

Reset resets the cache. Should be used only in tests, but since it has to be used in other packages, then the function has to be exported and placed here.

func UpdateConfig

func UpdateConfig(config runtime.Object, secrets map[string]map[string]string)

func UpdateToolchainConfigObjWithReset

func UpdateToolchainConfigObjWithReset(t *testing.T, cl client.Client, options ...testconfig.ToolchainConfigOption) *toolchainv1alpha1.ToolchainConfig

UpdateToolchainConfigObjWithReset updates the ToolchainConfig resource with the name "config" found using the provided client and updated using the provided options. Also adds the cache Reset to the test cleanup. It is located here to prevent import cycles between this package and the test package.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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