From 313cb891e3f5913dfaafbfbd54006f1b36fe9be2 Mon Sep 17 00:00:00 2001 From: Simon Murray Date: Thu, 29 Feb 2024 09:58:59 +0000 Subject: [PATCH] Add Label Priorities (#4) Makes sense to live here with the labels. --- pkg/constants/constants.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 42169eb..14229df 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -119,3 +119,19 @@ const ( // a go. DefaultYieldTimeout = 10 * time.Second ) + +// LabelPriorities assigns a priority to the labels for sorting. Most things +// use the labels to uniquely identify a resource. For example, when we create +// a remote cluster in ArgoCD we use a tuple of project, control plane and optionally +// the cluster. This gives a unique identifier given projects and control planes +// provide a namespace abstraction, and a deterministic one as the order is defined. +// This function is required because labels are given as a map, and thus are +// no-deterministically ordered when iterating in go. +func LabelPriorities() []string { + return []string{ + KubernetesClusterLabel, + ControlPlaneLabel, + ProjectLabel, + OrganizationLabel, + } +}