diff --git a/pkg/operator/client/deploy.go b/pkg/operator/client/deploy.go index deced95a3c..c08710ddcf 100644 --- a/pkg/operator/client/deploy.go +++ b/pkg/operator/client/deploy.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os/exec" "path/filepath" + "sort" "strings" "time" @@ -662,14 +663,17 @@ func getRemovedCharts(prevDir string, curDir string) ([]string, error) { } func getLabelSelector(appLabelSelector *metav1.LabelSelector) string { - retString := "" + allKeys := make([]string, 0) + for key := range appLabelSelector.MatchLabels { + allKeys = append(allKeys, key) + } + + sort.Strings(allKeys) + + allLabels := make([]string, 0) for key, val := range appLabelSelector.MatchLabels { - if retString == "" { - retString = fmt.Sprintf("%s=%s", key, val) - } else { - retString = fmt.Sprintf("%s,%s=%s", retString, key, val) - } + allLabels = append(allLabels, fmt.Sprintf("%s=%s", key, val)) } - return retString + return strings.Join(allLabels, ",") }