mirror of
https://github.com/hanzoai/nchain.git
synced 2026-10-30 18:27:22 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers, and int32Ptr went once new(expr) could say it; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package manifests
|
|
|
|
import maps0 "maps"
|
|
|
|
const (
|
|
// Standard Kubernetes recommended labels.
|
|
labelName = "app.kubernetes.io/name"
|
|
labelInstance = "app.kubernetes.io/instance"
|
|
labelComponent = "app.kubernetes.io/component"
|
|
labelPartOf = "app.kubernetes.io/part-of"
|
|
labelVersion = "app.kubernetes.io/version"
|
|
labelManagedBy = "app.kubernetes.io/managed-by"
|
|
|
|
managedByValue = "nchain-operator"
|
|
)
|
|
|
|
// StandardLabels returns the full set of app.kubernetes.io/* labels for a
|
|
// managed resource. Empty values are omitted.
|
|
func StandardLabels(name, component, partOf, version string) map[string]string {
|
|
labels := map[string]string{
|
|
labelName: name,
|
|
labelInstance: name,
|
|
labelManagedBy: managedByValue,
|
|
}
|
|
if component != "" {
|
|
labels[labelComponent] = component
|
|
}
|
|
if partOf != "" {
|
|
labels[labelPartOf] = partOf
|
|
}
|
|
if version != "" {
|
|
labels[labelVersion] = version
|
|
}
|
|
return labels
|
|
}
|
|
|
|
// SelectorLabels returns the minimal label set used in pod selectors.
|
|
// These labels must be immutable after creation.
|
|
func SelectorLabels(name string) map[string]string {
|
|
return map[string]string{
|
|
labelName: name,
|
|
labelInstance: name,
|
|
}
|
|
}
|
|
|
|
// MergeLabels merges multiple label maps into a single map. Later maps
|
|
// take precedence when keys collide.
|
|
func MergeLabels(maps ...map[string]string) map[string]string {
|
|
out := make(map[string]string)
|
|
for _, m := range maps {
|
|
maps0.Copy(out, m)
|
|
}
|
|
return out
|
|
}
|