Documentation
¶
Index ¶
- Constants
- func CopyOf(originalMap map[string]map[string]string) map[string]map[string]string
- func GetBool(value *bool, defaultValue bool) bool
- func GetCachedConfig() (runtime.Object, map[string]map[string]string)
- func GetConfig(cl client.Client, configObj client.Object) (runtime.Object, map[string]map[string]string, error)
- func GetDuration(value *string, defaultValue time.Duration) time.Duration
- func GetInt(value *int, defaultValue int) int
- func GetInt32(value *int32, defaultValue int32) int32
- func GetOperatorName() (string, error)
- func GetString(value *string, defaultValue string) string
- func GetUint(value *uint, defaultValue uint) uint
- func GetWatchNamespace() (string, error)
- func LoadFromConfigMap(prefix, resourceKey string, cl client.Client) error
- func LoadFromSecret(resourceKey string, cl client.Client) (map[string]string, error)
- func LoadLatest(cl client.Client, configObj client.Object) (runtime.Object, map[string]map[string]string, error)
- func LoadSecrets(cl client.Client, namespace string) (map[string]map[string]string, error)
- func NewMemberOperatorConfigWithReset(t *testing.T, options ...testconfig.MemberOperatorConfigOption) *toolchainv1alpha1.MemberOperatorConfig
- func NewToolchainConfigObjWithReset(t *testing.T, options ...testconfig.ToolchainConfigOption) *toolchainv1alpha1.ToolchainConfig
- func ResetCache()
- func UpdateConfig(config runtime.Object, secrets map[string]map[string]string)
- func UpdateMemberOperatorConfigWithReset(t *testing.T, cl client.Client, ...) *toolchainv1alpha1.MemberOperatorConfig
- func UpdateToolchainConfigObjWithReset(t *testing.T, cl client.Client, options ...testconfig.ToolchainConfigOption) *toolchainv1alpha1.ToolchainConfig
Constants ¶
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 GetCachedConfig ¶
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 ¶
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 GetOperatorName ¶
GetOperatorName return the operator name
func GetWatchNamespace ¶
GetWatchNamespace returns the namespace the operator should be watching for changes
func LoadFromConfigMap ¶
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 ¶
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 ¶
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 NewMemberOperatorConfigWithReset ¶
func NewMemberOperatorConfigWithReset(t *testing.T, options ...testconfig.MemberOperatorConfigOption) *toolchainv1alpha1.MemberOperatorConfig
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 UpdateMemberOperatorConfigWithReset ¶
func UpdateMemberOperatorConfigWithReset(t *testing.T, cl client.Client, options ...testconfig.MemberOperatorConfigOption) *toolchainv1alpha1.MemberOperatorConfig
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.