diff --git a/cmd/dkl-dir2config/render-context.go b/cmd/dkl-dir2config/render-context.go index a0bb646..cd3e36f 100644 --- a/cmd/dkl-dir2config/render-context.go +++ b/cmd/dkl-dir2config/render-context.go @@ -234,6 +234,24 @@ func (ctx *renderContext) templateFuncs(ctxMap map[string]interface{}) map[strin funcs := clusterFuncs(ctx.Cluster) for k, v := range map[string]interface{}{ + "default": func(value, defaultValue any) any { + switch v := value.(type) { + case string: + if v != "" { + return v + } + case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, float32, float64: + if v != 0 { + return v + } + + default: + if v != nil { + return v + } + } + return defaultValue + }, "tls_key": func(name string) (string, error) { return getKeyCert(name, "tls_key") },