util

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineFieldErrors added in v0.0.6

func CombineFieldErrors(fieldErrors field.ErrorList) error

func CreateMapForKey added in v0.0.7

func CreateMapForKey[T any](objects []T, key string) (m map[string]T, err error)

Returns a map from a slice of objects of type 'T' Uses the key provided in the arguments Returns an error if the desired key is not a field in any object of the slice

func DeepEqualWithException added in v0.0.7

func DeepEqualWithException(a, b interface{}, exceptionKey string) bool

Returns if two structs/objects are equal with the exception of the field under the exceptionKey

func Filter

func Filter[T any](items []T, fn func(item T) bool) []T

A utility function to filter the items based on the conditions defined in the predicate 'fn'

func FindFirst

func FindFirst[T any](items []T, filter func(item T) bool) (T, error)

A utility function to find the first match for the given filter function in the case of no match, returns an empty struct instance and an error

func GetAllDataFromSecret

func GetAllDataFromSecret(ctx context.Context, client client.Client, name, namespace string) (data map[string][]byte, err error)

Returns all the data in the given secret and namespace combination returns an error if the secret is not found

func GetAllowedAdditionalArguments added in v0.0.8

func GetAllowedAdditionalArguments(isClone bool, dbType string) (map[string]bool, error)

Returns a tuple that consists of the following:

  1. A map where the keys are the allowed additional arguments for the database type, and the corresponding values indicates whether the key is an action argument (where true=yes and false=no). Currently, all additional arguments are action arguments but this might not always be the case, thus this distinction is made so actual action arguments are appended to the appropriate provisioning body property.
  2. An error if there is no allowed additional arguments for the corresponding type, in other words, if the dbType is not MSSQL, MongoDB, PostGres, or MYSQL. Else nil.

func GetAllowedAdditionalArgumentsForClone added in v0.0.8

func GetAllowedAdditionalArgumentsForClone(dbType string) (map[string]bool, error)

func GetAllowedAdditionalArgumentsForDatabase added in v0.0.8

func GetAllowedAdditionalArgumentsForDatabase(dbType string) (map[string]bool, error)

func GetDataFromSecret

func GetDataFromSecret(ctx context.Context, client client.Client, name, namespace, key string) (data string, err error)

Returns the data for a key present in the given secret and namespace combination returns an error if either the secret or the data for the given key is not found

func IsFeatureEnabled added in v0.0.6

func IsFeatureEnabled(key string) bool

func ToString

func ToString(x interface{}) string

A utility function to convert an interface to a string

func ValidateURL added in v0.0.6

func ValidateURL(u string) error

func ValidateUUID added in v0.0.6

func ValidateUUID(u string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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