utilities

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTenantPrefix

func AddTenantPrefix(name string, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) string

func ArgsAddFlagValue added in v0.1.0

func ArgsAddFlagValue(args map[string]string, flag, value string) bool

ArgsAddFlagValue performs upsert of a flag in the arguments map, returning true if created.

func ArgsFromMapToSlice added in v0.1.0

func ArgsFromMapToSlice(args map[string]string) (slice []string)

ArgsFromMapToSlice create the slice of args, and sorting the resulting output in order to make it idempotent. Along with that, if a flag doesn't have a value, it's presented barely without a value assignment.

func ArgsFromSliceToMap added in v0.1.0

func ArgsFromSliceToMap(args []string) (m map[string]string)

ArgsFromSliceToMap transforms a slice of string into a map, simplifying the subsequent mangling.

func ArgsRemoveFlag added in v0.1.0

func ArgsRemoveFlag(args map[string]string, flag string) bool

ArgsRemoveFlag removes a flag from the arguments map, returning true if found and removed.

func CalculateMapChecksum added in v0.1.0

func CalculateMapChecksum(data any) string

CalculateMapChecksum orders the map according to its key, and calculating the overall md5 of the values. It's expected to work with ConfigMap (map[string]string) and Secrets (map[string][]byte).

func CreateOrUpdateWithConflict added in v0.1.0

func CreateOrUpdateWithConflict(ctx context.Context, client client.Client, resource client.Object, f controllerutil.MutateFn) (res controllerutil.OperationResult, err error)

CreateOrUpdateWithConflict is a helper function that wraps the RetryOnConflict around the CreateOrUpdate function: this allows to fetch from the cache the latest modified object an try to apply the changes defined in the MutateFn without enqueuing back the request in order to get the latest changes of the resource.

func DecodeFromJSON added in v0.1.0

func DecodeFromJSON(o string, to runtime.Object) (err error)

func DecodeFromYAML added in v0.1.0

func DecodeFromYAML(o string, to runtime.Object) (err error)

func DecodeKubeconfig added in v0.3.3

func DecodeKubeconfig(secret corev1.Secret, key string) (*clientcmdapiv1.Config, error)

func DecodeKubeconfigYAML added in v0.3.3

func DecodeKubeconfigYAML(bytes []byte) (*clientcmdapiv1.Config, error)

func EncodeToJSON added in v0.1.0

func EncodeToJSON(o runtime.Object) ([]byte, error)

EncodeToJSON returns the given object in JSON format and the error, respecting the Kubernetes struct tags.

func EncodeToYaml added in v0.1.0

func EncodeToYaml(o runtime.Object) ([]byte, error)

EncodeToYaml returns the given object in yaml format and the error.

func GetControlPlaneAddressAndPortFromHostname added in v0.3.3

func GetControlPlaneAddressAndPortFromHostname(hostname string, defaultPort int32) (address string, port int32)

func GetObjectChecksum added in v0.2.1

func GetObjectChecksum(obj client.Object) string

GetObjectChecksum returns the annotation checksum in case this is set, otherwise, an empty string.

func GetRESTClientConfig added in v0.2.0

func GetRESTClientConfig(ctx context.Context, client client.Client, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (*restclient.Config, error)

func GetTenantClient added in v0.1.0

func GetTenantClient(ctx context.Context, c client.Client, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (client.Client, error)

func GetTenantClientSet added in v0.1.0

func GetTenantClientSet(ctx context.Context, client client.Client, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (*clientset.Clientset, error)

func GetTenantKubeconfig added in v0.1.0

func GetTenantKubeconfig(ctx context.Context, client client.Client, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (*clientcmdapiv1.Config, error)

func HasNamedContainer added in v0.1.0

func HasNamedContainer(container []corev1.Container, name string) (found bool, index int)

HasNamedContainer finds the Container in the provided slice by its name, returning a boolean if found, and its index.

func HasNamedVolume added in v0.1.0

func HasNamedVolume(volumes []corev1.Volume, name string) (found bool, index int)

HasNamedVolume finds the Volume in the provided slice by its name, returning a boolean if found, and its index.

func HasNamedVolumeMount added in v0.1.0

func HasNamedVolumeMount(volumeMounts []corev1.VolumeMount, name string) (found bool, index int)

HasNamedVolumeMount finds the VolumeMount in the provided slice by its name, returning a boolean if found, and its index.

func KamajiLabels

func KamajiLabels(tcpName, resourceName string) map[string]string

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

func SetObjectChecksum added in v0.2.1

func SetObjectChecksum(obj client.Object, data any)

SetObjectChecksum calculates the checksum for the given map and store it in the object annotations.

Types

This section is empty.

Jump to

Keyboard shortcuts

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