Skip to content

Commit

Permalink
Add plain text output
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-db committed Mar 21, 2024
1 parent 70334a5 commit 20ff8e1
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions cmd/bundle/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package bundle

import (
"encoding/json"
"errors"
"fmt"

"github.com/databricks/cli/bundle/deploy/terraform"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
"github.com/spf13/cobra"
)
Expand All @@ -17,9 +17,36 @@ type Dependencies struct {

func newDependenciesCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "dependencies",
Short: "Prints CLI dependencies required for the bundle namespace",
Use: "internal-dependencies",
Short: "Prints CLI terraform dependencies required for the bundle namespace",
Args: root.NoArgs,
Annotations: map[string]string{
"template": `Terraform version: {{.Version}}
Terraform URL: https://releases.hashicorp.com/terraform/{{.Version}}
Databricks Terraform Provider version: {{.ProviderVersion}}
Databricks Terraform Provider URL: https://github.com/databricks/terraform-provider-databricks/releases/tag/v{{.ProviderVersion}}
Databricks CLI will download its terraform dependencies automatically.
If you run the CLI in air-gapped environment, you can download the dependencies manually and setup these environment variables:
DATABRICKS_TF_VERSION={{.Version}}
DATABRICKS_TF_EXEC_PATH=/path/to/terraform/binary
DATABRICKS_TF_PROVIDER_VERSION={{.ProviderVersion}}
DATABRICKS_TF_CLI_CONFIG_FILE=/path/to/terraform/cli/config.tfrc
Example of the *.tfrc config file:
disable_checkpoint = true
provider_installation {
filesystem_mirror {
path = "/path/to/a/folder/with/databricks/terraform/provider"
}
}
The folder with the databricks terraform provider should have this structure: /registry.terraform.io/databricks/databricks/terraform-provider-databricks_{{.ProviderVersion}}_ARCH.zip
Consult terraform docs for more information about the filesystem mirrors: https://developer.hashicorp.com/terraform/cli/config/config-file#filesystem_mirror
`,
},
// This command is currently intended for the Databricks VSCode extension only
Hidden: true,
}
Expand All @@ -30,7 +57,7 @@ func newDependenciesCommand() *cobra.Command {
}
switch root.OutputType(cmd) {
case flags.OutputText:
return fmt.Errorf("%w, only json output is supported", errors.ErrUnsupported)
cmdio.Render(cmd.Context(), dependencies.Terraform)
case flags.OutputJSON:
buf, err := json.MarshalIndent(dependencies, "", " ")
if err != nil {
Expand Down

0 comments on commit 20ff8e1

Please sign in to comment.