databricks / cli

Databricks CLI
Other
148 stars 56 forks source link

Feature Request: Cannot specify bundle template value via CLI #1606

Closed madslyng closed 3 months ago

madslyng commented 4 months ago

Describe the issue

Use-case: Create a new bundle based on a custom template, programmatically, where the user is not prompted for input.

We are attempting to automate bundle creation using the CLI. Specifically we are trying generate a new bundle in an existing repository, using an auto-generated name, that the generated bundle should use.

For instance if the template expects: .project_name, then we currently don't see a way where we can run databricks bundle init git@github.com:repo_name/poc-bundle-templates.git --template-dir poc-template --output-dir="./bundles", where the user doesn't get asked questions via a prompt.

That makes automation much more complicated as far as we can see.

Steps to reproduce the behavior

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

  1. Run databricks bundle init git@github.com:repo_name/poc-bundle-templates.git --template-dir poc-template --output-dir="./bundles"
  2. Observe that the CLI prompts the user for input

Expected Behavior

CLI command that accepts vars to be injected into the template upon execution of the command. For instance:

databricks bundle init git@github.com:repo_name/poc-bundle-templates.git --template-dir poc-template --output-dir="./bundles" --template-var="project_name=monkey"

Actual Behavior

Always asks user for input

Is this a regression?

No.

Debug Logs

─$ databricks bundle init git@github.com:repo_name/poc-templates.git --template-dir poc-template --output-dir="./bundles"

User prompt:

Project name [project_name]:

pietern commented 3 months ago

Thanks for creating the issue.

It is possible to specify template variables in a configuration file (with a JSON key/value map).

The flag for this is --config-file.

shreyas-goenka commented 3 months ago

@madslyng I'll close this issue since the --config-file flag already exists and should satisfy your use case. Please feel free to reopen the issue in case there's a gap not addressed by the flag for your use case.