utils

package
v0.0.0-...-560103a Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabel

func AddLabel(labels, addLabels map[string]string)

func AsSecrets

func AsSecrets(namespace string, owner metav1.OwnerReference, certdata *certs.Certificates) ([]*corev1.Secret, error)

This function is borrowed from projectcountour AsSecrets transforms the given Certificates struct into a slice of Secrets in in compact Secret format, which is compatible with both cert-manager and Contour.

func BuildOutsideClusterConfig

func BuildOutsideClusterConfig() (*rest.Config, error)

BuildOutsideClusterConfig returns k8s config

func CloneAndAddLabel

func CloneAndAddLabel(labels, addLabels map[string]string) map[string]string

func CloneLabel

func CloneLabel(labels map[string]string) map[string]string

func ComputeHash

func ComputeHash(object interface{}) string

func Contains

func Contains(list []string, s string) bool

func DeepHashObject

func DeepHashObject(hasher hash.Hash, objectToWrite interface{})

func GetClientsOrDie

func GetClientsOrDie(inCluster bool, scheme *runtime.Scheme) (
	kubernetes.Interface,
	versioned.Interface,
	client.Client)

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultValue string) string

func GetEnvVarFromMap

func GetEnvVarFromMap(envVars map[string]string) []corev1.EnvVar

func GetFullImageName

func GetFullImageName(registry, imageName, tag string) string

func GetInstanceOfObj

func GetInstanceOfObj(obj interface{}) client.Object

func GetKeyFromEnvVar

func GetKeyFromEnvVar(envVars []corev1.EnvVar, key string) string

func GetMapFromEnvVar

func GetMapFromEnvVar(envVarLists ...[]corev1.EnvVar) map[string]string

func GetPatchData

func GetPatchData(oldObj, newObj interface{}) ([]byte, error)

func GetScheme

func GetScheme() *runtime.Scheme

func IsDeploymentPaused

func IsDeploymentPaused(ctx context.Context, client kubernetes.Interface, name, namespace string) bool

IsDeploymentPaused checks if the deployment is paused

func IsDeploymentReady

func IsDeploymentReady(ctx context.Context, client kubernetes.Interface, name, namespace string) bool

IsDeploymentReady checks if the number of required replicas is equal to number of created replicas

func IsPodActive

func IsPodActive(ctx context.Context, client kubernetes.Interface, pod *corev1.Pod) bool

func MergeEnvVars

func MergeEnvVars(envVarLists ...[]corev1.EnvVar) []corev1.EnvVar

func OutputCerts

func OutputCerts(ctx context.Context, namespace string, owner metav1.OwnerReference,
	client kubernetes.Interface, certs *certs.Certificates) error

This function is borrowed from projectcountour OutputCerts outputs the certs in certs as directed by config.

func Remove

func Remove(list []string, s string) []string

func UpsertEnvVariable

func UpsertEnvVariable(envVarList *[]corev1.EnvVar, eEnvVarMap map[string]string, update bool) bool

UpsertEnvVariable inserts the env variable from map to the list is not exist or update it if replace it true and returns true if changed the envVarList

func WriteSecretsKube

func WriteSecretsKube(ctx context.Context, client kubernetes.Interface, secrets []*corev1.Secret) error

This function is borrowed from projectcountour WriteSecretsKube writes all the keypairs out to Kubernetes Secrets in the compact format which is compatible with Secrets generated by cert-manager.

Types

type KubernetesDistros

type KubernetesDistros string
const (
	CACertificateKey = "ca.crt"

	// Kubernetes distributions
	NotDetected   KubernetesDistros = ""
	Minikube      KubernetesDistros = "minikube"
	Microk8s      KubernetesDistros = "microk8s"
	EKS           KubernetesDistros = "eks"
	GKE           KubernetesDistros = "gke"
	K3s           KubernetesDistros = "k3s"
	DockerDesktop KubernetesDistros = "docker-desktop"
)

func DetectK8sDistribution

func DetectK8sDistribution(client kubernetes.Interface) KubernetesDistros

Jump to

Keyboard shortcuts

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