diff --git a/acceptance/bundle/templates-machinery/helper_upper_lower/databricks_template_schema.json b/acceptance/bundle/templates-machinery/helper_upper_lower/databricks_template_schema.json new file mode 100644 index 00000000000..10665de4dae --- /dev/null +++ b/acceptance/bundle/templates-machinery/helper_upper_lower/databricks_template_schema.json @@ -0,0 +1,9 @@ +{ + "properties": { + "s": { + "type": "string", + "description": "An input string", + "default": "AbCd0123😀" + } + } +} diff --git a/acceptance/bundle/templates-machinery/helpers/out.test.toml b/acceptance/bundle/templates-machinery/helper_upper_lower/out.test.toml similarity index 100% rename from acceptance/bundle/templates-machinery/helpers/out.test.toml rename to acceptance/bundle/templates-machinery/helper_upper_lower/out.test.toml diff --git a/acceptance/bundle/templates-machinery/helper_upper_lower/output.txt b/acceptance/bundle/templates-machinery/helper_upper_lower/output.txt new file mode 100644 index 00000000000..c395eeecfbd --- /dev/null +++ b/acceptance/bundle/templates-machinery/helper_upper_lower/output.txt @@ -0,0 +1,7 @@ + +>>> [CLI] bundle init . +✨ Successfully initialized template + +>>> cat hello.txt +abcd0123😀 +ABCD0123😀 diff --git a/acceptance/bundle/templates-machinery/helper_upper_lower/script b/acceptance/bundle/templates-machinery/helper_upper_lower/script new file mode 100644 index 00000000000..62d58afa4c8 --- /dev/null +++ b/acceptance/bundle/templates-machinery/helper_upper_lower/script @@ -0,0 +1,4 @@ +trace $CLI bundle init . + +trace cat hello.txt +rm hello.txt diff --git a/acceptance/bundle/templates-machinery/helper_upper_lower/template/hello.txt.tmpl b/acceptance/bundle/templates-machinery/helper_upper_lower/template/hello.txt.tmpl new file mode 100644 index 00000000000..c5ec245621c --- /dev/null +++ b/acceptance/bundle/templates-machinery/helper_upper_lower/template/hello.txt.tmpl @@ -0,0 +1,2 @@ +{{ .s | lower }} +{{ .s | upper }} diff --git a/acceptance/bundle/templates-machinery/helpers/databricks_template_schema.json b/acceptance/bundle/templates-machinery/helper_username/databricks_template_schema.json similarity index 100% rename from acceptance/bundle/templates-machinery/helpers/databricks_template_schema.json rename to acceptance/bundle/templates-machinery/helper_username/databricks_template_schema.json diff --git a/acceptance/bundle/templates-machinery/helper_username/out.test.toml b/acceptance/bundle/templates-machinery/helper_username/out.test.toml new file mode 100644 index 00000000000..8f3575be7b5 --- /dev/null +++ b/acceptance/bundle/templates-machinery/helper_username/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"] diff --git a/acceptance/bundle/templates-machinery/helpers/output.txt b/acceptance/bundle/templates-machinery/helper_username/output.txt similarity index 100% rename from acceptance/bundle/templates-machinery/helpers/output.txt rename to acceptance/bundle/templates-machinery/helper_username/output.txt diff --git a/acceptance/bundle/templates-machinery/helpers/script b/acceptance/bundle/templates-machinery/helper_username/script similarity index 100% rename from acceptance/bundle/templates-machinery/helpers/script rename to acceptance/bundle/templates-machinery/helper_username/script diff --git a/acceptance/bundle/templates-machinery/helpers/template/helpers.txt.tmpl b/acceptance/bundle/templates-machinery/helper_username/template/helpers.txt.tmpl similarity index 100% rename from acceptance/bundle/templates-machinery/helpers/template/helpers.txt.tmpl rename to acceptance/bundle/templates-machinery/helper_username/template/helpers.txt.tmpl diff --git a/libs/template/helpers.go b/libs/template/helpers.go index d103e714f84..c258775a435 100644 --- a/libs/template/helpers.go +++ b/libs/template/helpers.go @@ -8,6 +8,7 @@ import ( "net/url" "os" "regexp" + "strings" "text/template" "github.com/databricks/cli/libs/cmdctx" @@ -167,5 +168,11 @@ func loadHelpers(ctx context.Context) template.FuncMap { cachedIsServicePrincipal = &result return result, nil }, + "lower": func(s string) string { + return strings.ToLower(s) + }, + "upper": func(s string) string { + return strings.ToUpper(s) + }, } }