argo-cd/util/notification/expression/expr.go
Matthieu MOREL 1d65d8be6c
chore(util): Fix modernize linter (#26323)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2026-02-08 17:48:27 +02:00

36 lines
899 B
Go

package expression
import (
"maps"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
service "github.com/argoproj/argo-cd/v3/util/notification/argocd"
"github.com/argoproj/argo-cd/v3/util/notification/expression/repo"
"github.com/argoproj/argo-cd/v3/util/notification/expression/strings"
"github.com/argoproj/argo-cd/v3/util/notification/expression/time"
)
var helpers = map[string]any{}
func init() {
helpers = make(map[string]any)
register("time", time.NewExprs())
register("strings", strings.NewExprs())
}
func register(namespace string, entry map[string]any) {
helpers[namespace] = entry
}
func Spawn(app *unstructured.Unstructured, argocdService service.Service, vars map[string]any) map[string]any {
clone := make(map[string]any)
for k := range vars {
clone[k] = vars[k]
}
maps.Copy(clone, helpers)
clone["repo"] = repo.NewExprs(argocdService, app)
return clone
}