Documentation ¶
Overview ¶
the attribute package deals with everything that is related to operations on K8s object labels and env. vars
Index ¶
- Variables
- func Contains[T comparable](elems []T, v T) bool
- func MapsEqual[K comparable, V comparable](a, b map[K]V) bool
- type Handler
- func (h *Handler) ConvertLabels(targetPodLabels map[string]string) map[string][]string
- func (h *Handler) GetLabelsFromEnvVars(envVars map[string]string) (map[string][]string, error)
- func (h *Handler) GetLocalEnvVars(obj metav1.Object) (map[string]string, error)
- func (h *Handler) MergeLabels(targetLabels ...map[string][]string) (map[string][]string, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Contains ¶
func Contains[T comparable](elems []T, v T) bool
helper function to check if []T contains T
func MapsEqual ¶
func MapsEqual[K comparable, V comparable](a, b map[K]V) bool
helper function to check if two maps are equal or not
Types ¶
type Handler ¶
type Handler struct {
Client kubernetes.Interface
}
func (*Handler) ConvertLabels ¶
ConvertMap converts K8s object labels (map[string]string) to map[string][]string. e.g {"label":"value"} -> label: {"value"}
func (*Handler) GetLabelsFromEnvVars ¶
GetLabelsFromEnvVars takes in the environment variables containing "<name>.<namespace>.svc.cluster.local" and "<name>.<namespace>.pod.cluster.local". Then for PODs, it returns all the labels it has and for services it looks at the .spec.Selector (which are esentially the POD labels it targets) and returns those. It returns a map[string][]string because it can happen that two pods have the same label keys with different values.
e.g { "app": ["test", "frontend", "backend"], "version": ["1.0", "2.0"], "env": ["prod"], }
func (*Handler) GetLocalEnvVars ¶
GetLocalEnvVars fetches all env. vars with the values of <name>.<namespace>.svc/pod.cluster.local