mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-22 14:07:10 +00:00
* feat(webhook): add watchdog webhook to core Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * fix(controller): ensure managed metadata for namespaces on update Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore(controller): refactor core webhooks to generics Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: fix helm plugin installation Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: rename webhook to tenant-label Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> --------- Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com>
31 lines
751 B
Go
31 lines
751 B
Go
// Copyright 2020-2025 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package template
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/valyala/fasttemplate"
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
|
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
|
|
)
|
|
|
|
// TemplateForTenantAndNamespace applies templating to all values in the provided map in place.
|
|
func TemplateForTenantAndNamespace(m map[string]string, tnt *capsulev1beta2.Tenant, ns *corev1.Namespace) {
|
|
for k, v := range m {
|
|
if !strings.Contains(v, "{{ ") && !strings.Contains(v, " }}") {
|
|
continue
|
|
}
|
|
|
|
t := fasttemplate.New(v, "{{ ", " }}")
|
|
tmplString := t.ExecuteString(map[string]interface{}{
|
|
"tenant.name": tnt.Name,
|
|
"namespace": ns.Name,
|
|
})
|
|
|
|
m[k] = tmplString
|
|
}
|
|
}
|