2023-12-06 15:24:02 +01:00
|
|
|
package generator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-11-18 17:12:12 +01:00
|
|
|
"katenary/generator/labels"
|
2023-12-06 15:24:02 +01:00
|
|
|
)
|
|
|
|
|
2024-11-18 17:12:12 +01:00
|
|
|
var componentLabel = labels.LabelName("component")
|
2023-12-06 15:24:02 +01:00
|
|
|
|
2024-04-05 07:56:27 +02:00
|
|
|
// GetLabels returns the labels for a service. It uses the appName to replace the __replace__ in the labels.
|
|
|
|
// This is used to generate the labels in the templates.
|
2023-12-06 15:24:02 +01:00
|
|
|
func GetLabels(serviceName, appName string) map[string]string {
|
|
|
|
labels := map[string]string{
|
2024-04-24 13:59:21 +02:00
|
|
|
componentLabel: serviceName,
|
2023-12-06 15:24:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
key := `{{- include "%s.labels" . | nindent __indent__ }}`
|
|
|
|
labels[`__replace_`+serviceName] = fmt.Sprintf(key, appName)
|
|
|
|
|
|
|
|
return labels
|
|
|
|
}
|
|
|
|
|
2024-04-05 07:56:27 +02:00
|
|
|
// GetMatchLabels returns the matchLabels for a service. It uses the appName to replace the __replace__ in the labels.
|
|
|
|
// This is used to generate the matchLabels in the templates.
|
2023-12-06 15:24:02 +01:00
|
|
|
func GetMatchLabels(serviceName, appName string) map[string]string {
|
|
|
|
labels := map[string]string{
|
2024-04-24 13:59:21 +02:00
|
|
|
componentLabel: serviceName,
|
2023-12-06 15:24:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
key := `{{- include "%s.selectorLabels" . | nindent __indent__ }}`
|
|
|
|
labels[`__replace_`+serviceName] = fmt.Sprintf(key, appName)
|
|
|
|
|
|
|
|
return labels
|
|
|
|
}
|