Skip to content

DAB Custom Templates - lowercase input variables #3237

@FedericoRaimondi

Description

@FedericoRaimondi

Describe the issue

I would like to lowercase the variable input from user when creating from a custom template

Configuration

I tired with a library/template.tmpl file with the following content:

{{ define `project_name_clean` -}}
    {{- strings.ToLower ((regexp `-`).ReplaceAllString ((regexp `[^A-Za-z0-9_-]`).ReplaceAllString (print .project_name) ``) `_`) -}}
{{- end }}

Steps to reproduce the behavior

Please list the steps required to reproduce the issue, for example:

  1. Create a simple custom template
  2. Run databricks bundle init your_template
  3. Error: template: variables.tmpl:2: function "strings" not defined

Expected Behavior

I see it's probably because this function isn't support by the go template (not very familiar with it tbh)

Actual Behavior

If it's possible: more docs around possible functions to use in custom templates.
If not possible to achieve; then it would be a good addition to custom templates.

OS and CLI version

Please provide the version of the CLI (eg: v0.1.2) and the operating system (eg: windows). You can run databricks --version to get the version of your Databricks CLI

  • Databricks CLI v0.251.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    DABsDABs related issuesEnhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions