Skip to content

Commit c378c1c

Browse files
authored
Add a capability of providing a dev_override for the Databricks Terraform provider (#3336)
## Changes <!-- Brief summary of your changes that is easy to understand --> Add a capability of providing a dev_override for the Databricks Terraform provider in acceptance tests via an environment variable. Usage: `DATABRICKS_TF_PROVIDER_DEV_OVERRIDE=<PATH_TO_LOCAL_FOLDER> make test` ## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> This allows CLI developers to use a "dev preview" of Databricks Terraform Provider in the acceptance tests. ## Tests <!-- How have you tested the changes? --> Manually checked that in the absence of `DATABRICKS_TF_PROVIDER_DEV_OVERRIDE` the generated .terraformrc remains intact. When `DATABRICKS_TF_PROVIDER_DEV_OVERRIDE` is provided a new section is added to the file and acceptance tests start using a local custom version of the Databricks Terraform provider: ``` # Set these env variables before running databricks cli: # export DATABRICKS_TF_CLI_CONFIG_FILE=<REDACTED> # export DATABRICKS_TF_EXEC_PATH=<REDACTED> provider_installation { dev_overrides { "databricks/databricks" = <REDACTED> } filesystem_mirror { path = <REDACTED> include = ["registry.terraform.io/databricks/databricks"] } } ``` <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 4f9b8e3 commit c378c1c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

acceptance/install_terraform.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,22 @@ def main():
103103
terraformrc_path = target / ".terraformrc"
104104
if not terraformrc_path.exists():
105105
path = json.dumps(str(tfplugins_path.absolute()))
106+
107+
# Check for dev override environment variable
108+
dev_override_path = os.environ.get("DATABRICKS_TF_PROVIDER_DEV_OVERRIDE")
109+
dev_overrides_section = ""
110+
if dev_override_path:
111+
dev_overrides_section = f""" dev_overrides {{
112+
"databricks/databricks" = "{dev_override_path}"
113+
}}
114+
"""
115+
106116
text = f"""# Set these env variables before running databricks cli:
107117
# export DATABRICKS_TF_CLI_CONFIG_FILE={terraformrc_path.absolute()}
108118
# export DATABRICKS_TF_EXEC_PATH={terraform_path.absolute()}
109119
110120
provider_installation {{
111-
filesystem_mirror {{
121+
{dev_overrides_section} filesystem_mirror {{
112122
path = {path}
113123
include = ["registry.terraform.io/databricks/databricks"]
114124
}}

0 commit comments

Comments
 (0)