databricks-cli/cmd/bundle/bundle.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
2.0 KiB
Go
Raw Normal View History

package bundle
import (
2025-03-09 20:17:56 +00:00
"github.com/databricks/cli/clis"
"github.com/databricks/cli/cmd/auth"
"github.com/databricks/cli/cmd/bundle/deployment"
2025-03-09 20:17:56 +00:00
"github.com/databricks/cli/cmd/root"
"github.com/spf13/cobra"
)
2025-03-09 20:17:56 +00:00
func New(cliType clis.CLIType) *cobra.Command {
cmd := &cobra.Command{
Use: "bundle",
2025-03-09 20:17:56 +00:00
Short: "Manage Databricks assets as code",
Long: "Databricks Asset Bundles let you express data/AI/analytics projects as code.\n\nOnline documentation: https://docs.databricks.com/dev-tools/bundles",
GroupID: "development",
}
2025-03-09 20:17:56 +00:00
hideForDLT := cliType == clis.DLT
showForDLT := cliType == clis.General || cliType == clis.DAB
hideForGeneralCLI := cliType == clis.General
hideAlways := true
if cliType == clis.DLT {
cmd.Use = "dlt"
cmd.Short = "Use DLT to build efficient & scalable data pipelines."
cmd.Long = cmd.Short + "\n\nOnline documentation: https://docs.databricks.com/delta-live-tables"
}
initVariableFlag(cmd, hideForDLT)
cmd.AddCommand(newDeployCommand(cliType))
cmd.AddCommand(newDestroyCommand())
cmd.AddCommand(newLaunchCommand())
2025-03-09 20:17:56 +00:00
cmd.AddCommand(newRunCommand(cliType))
cmd.AddCommand(newDryRunCommand(showForDLT))
cmd.AddCommand(newSchemaCommand(hideForDLT))
cmd.AddCommand(newSyncCommand(hideForDLT))
cmd.AddCommand(newTestCommand(hideAlways))
cmd.AddCommand(newShowCommand(hideAlways))
validateCmd := newValidateCommand(hideForDLT, cliType)
cmd.AddCommand(validateCmd)
cmd.AddCommand(newInitCommand(cliType))
summaryCmd := newSummaryCommand(hideForDLT, cliType)
cmd.AddCommand(summaryCmd)
cmd.AddCommand(newGenerateCommand(hideForDLT))
Add `bundle debug terraform` command (#1294) - Add `bundle debug terraform` command. It prints versions of the Terraform and the Databricks Terraform provider. In the text mode it also explains how to setup the CLI in environments with restricted internet access. - Use `DATABRICKS_TF_EXEC_PATH` env var to point Databricks CLI to the Terraform binary. The CLI only uses it if `DATABRICKS_TF_VERSION` matches the currently used terraform version. - Use `DATABRICKS_TF_CLI_CONFIG_FILE` env var to point Terraform CLI config that points to the filesystem mirror for the Databricks provider. The CLI only uses it if `DATABRICKS_TF_PROVIDER_VERSION` matches the currently used provider version. Relevant PR on the VSCode extension side: https://github.com/databricks/databricks-vscode/pull/1147 Example output of the `databricks bundle debug terraform`: ``` Terraform version: 1.5.5 Terraform URL: https://releases.hashicorp.com/terraform/1.5.5 Databricks Terraform Provider version: 1.38.0 Databricks Terraform Provider URL: https://github.com/databricks/terraform-provider-databricks/releases/tag/v1.38.0 Databricks CLI downloads its Terraform dependencies automatically. If you run the CLI in an air-gapped environment, you can download the dependencies manually and set these environment variables: DATABRICKS_TF_VERSION=1.5.5 DATABRICKS_TF_EXEC_PATH=/path/to/terraform/binary DATABRICKS_TF_PROVIDER_VERSION=1.38.0 DATABRICKS_TF_CLI_CONFIG_FILE=/path/to/terraform/cli/config.tfrc Here is an example *.tfrc configuration file: disable_checkpoint = true provider_installation { filesystem_mirror { path = "/path/to/a/folder/with/databricks/terraform/provider" } } The filesystem mirror path should point to the folder with the Databricks Terraform Provider. The folder should have this structure: /registry.terraform.io/databricks/databricks/terraform-provider-databricks_1.38.0_ARCH.zip For more information about filesystem mirrors, see the Terraform documentation: https://developer.hashicorp.com/terraform/cli/config/config-file#filesystem_mirror ``` --------- Co-authored-by: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com>
2024-04-02 12:56:27 +00:00
cmd.AddCommand(newDebugCommand())
2025-03-09 20:17:56 +00:00
cmd.AddCommand(deployment.NewDeploymentCommand(hideForDLT, cliType))
cmd.AddCommand(newOpenCommand(cliType))
cmd.AddCommand(auth.NewTopLevelLoginCommand(hideForGeneralCLI))
if cliType != clis.General {
// HACK: set the output flag locally for the summary and validate commands
root.InitOutputFlag(summaryCmd)
root.InitOutputFlag(validateCmd)
}
return cmd
}