Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading variables from file #2171

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a794490
feat: Read variables from file
ilyakuz-db Jan 16, 2025
3f0b5f8
test: Acceptance test for flag overrides
ilyakuz-db Jan 16, 2025
a75c6af
fix: Rename to --var-file
ilyakuz-db Jan 17, 2025
66dae81
fix: More detailed error for json parsing
ilyakuz-db Jan 17, 2025
d0db1d7
fix: Cleanup
ilyakuz-db Jan 17, 2025
2c9adcb
fix: More acceptance tests
ilyakuz-db Jan 17, 2025
15c9c5c
fix: Flaky test
ilyakuz-db Jan 18, 2025
01a6a66
fix: Remove extra tests
ilyakuz-db Jan 20, 2025
c5109cd
Merge branch 'main' of github.com:databricks/cli into feat/variable-f…
ilyakuz-db Jan 20, 2025
f52423c
fix: Update `help` snapshots
ilyakuz-db Jan 20, 2025
2a1c4d1
fix: Message in test
ilyakuz-db Jan 20, 2025
bdb8f1e
fix: Message in acceptance tests
ilyakuz-db Jan 20, 2025
19b5018
fix: Flaky test
ilyakuz-db Jan 20, 2025
44aba7e
fix: Remove platform specific part from output
ilyakuz-db Jan 20, 2025
e4164c1
fix: Try `jq -b` to preserve window output
ilyakuz-db Jan 20, 2025
bfec3c4
Merge branch 'main' of github.com:databricks/cli into feat/variable-f…
ilyakuz-db Jan 20, 2025
6dd8fc2
fix: Less flaky sed execution
ilyakuz-db Jan 21, 2025
1656bf5
fix: Remove redundant test
ilyakuz-db Jan 21, 2025
422585c
feat: Default value for variable path
ilyakuz-db Jan 21, 2025
47c8fb3
chore: Regenerate other snapshots
ilyakuz-db Jan 21, 2025
6f20e88
Added annotations to output
ilyakuz-db Jan 21, 2025
ad6343a
Cleanup in flag description
ilyakuz-db Jan 21, 2025
e0c81f0
Regenerate help snapshots
ilyakuz-db Jan 21, 2025
38b7d27
Remove unnecessary locations
ilyakuz-db Jan 21, 2025
3e1a335
Fix test with error message
ilyakuz-db Jan 21, 2025
229fdb2
Use variable-overrides.json name
ilyakuz-db Jan 22, 2025
6e8f5f3
Fix message in test
ilyakuz-db Jan 22, 2025
cf42459
Add file path to parsing error
ilyakuz-db Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-deploy/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Flags:
-h, --help help for deploy

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default message is hardcoded to avoid having invalid path value in variable

11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-deployment/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ Flags:
-h, --help help for deployment

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")

Use "databricks bundle deployment [command] --help" for more information about a command.
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-destroy/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ Flags:
-h, --help help for destroy

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
13 changes: 7 additions & 6 deletions acceptance/bundle/help/bundle-generate-dashboard/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ Flags:
--watch watch for changes to the dashboard and update the configuration

Global Flags:
--debug enable debug logging
--key string resource key to use for the generated configuration
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
--key string resource key to use for the generated configuration
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
13 changes: 7 additions & 6 deletions acceptance/bundle/help/bundle-generate-job/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ Flags:
-s, --source-dir string Dir path where the downloaded files will be stored (default "src")

Global Flags:
--debug enable debug logging
--key string resource key to use for the generated configuration
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
--key string resource key to use for the generated configuration
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
13 changes: 7 additions & 6 deletions acceptance/bundle/help/bundle-generate-pipeline/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ Flags:
-s, --source-dir string Dir path where the downloaded files will be stored (default "src")

Global Flags:
--debug enable debug logging
--key string resource key to use for the generated configuration
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
--key string resource key to use for the generated configuration
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-generate/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ Flags:
--key string resource key to use for the generated configuration

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")

Use "databricks bundle generate [command] --help" for more information about a command.
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-init/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ Flags:
--template-dir string Directory path within a Git repository containing the template.

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-open/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Flags:
-h, --help help for open

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-run/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ Flags:
--restart Restart the run if it is already running.

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-schema/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ Flags:
-h, --help help for schema

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-summary/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Flags:
-h, --help help for summary

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
9 changes: 5 additions & 4 deletions acceptance/bundle/help/bundle-sync/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Flags:
--watch watch local file system for changes

Global Flags:
--debug enable debug logging
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
11 changes: 6 additions & 5 deletions acceptance/bundle/help/bundle-validate/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ Flags:
-h, --help help for validate

Global Flags:
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--debug enable debug logging
-o, --output type output type: text or json (default text)
-p, --profile string ~/.databrickscfg profile
-t, --target string bundle target to use (if applicable)
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")
5 changes: 3 additions & 2 deletions acceptance/bundle/help/bundle/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Available Commands:
validate Validate configuration

Flags:
-h, --help help for bundle
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
-h, --help help for bundle
--var strings set values for variables defined in bundle config. Example: --var="foo=bar"
--var-file string path to a JSON file containing variables. Example: --var-file="/path/to/vars.json" (default ".databricks/bundle/<target>/vars.json")

Global Flags:
--debug enable debug logging
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/variables/empty/output.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Error: no value assigned to required variable a. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_a environment variable
Error: no value assigned to required variable a. Assignment can be done using "--var" or "--var-file", by setting the BUNDLE_VAR_a environment variable, or in .databricks/bundle/<target>/vars.json file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other suggestions for good user message are welcome! It became quite complicated

Name: empty${var.a}
Target: default
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/variables/env_overrides/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"prod-a env-var-b"

>>> errcode $CLI bundle validate -t env-missing-a-required-variable-assignment
Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable
Error: no value assigned to required variable b. Assignment can be done using "--var" or "--var-file", by setting the BUNDLE_VAR_b environment variable, or in .databricks/bundle/<target>/vars.json file

Name: test bundle
Target: env-missing-a-required-variable-assignment
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/variables/vanilla/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"abc def"

>>> errcode $CLI bundle validate
Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable
Error: no value assigned to required variable b. Assignment can be done using "--var" or "--var-file", by setting the BUNDLE_VAR_b environment variable, or in .databricks/bundle/<target>/vars.json file

Name: ${var.a} ${var.b}
Target: default
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"cluster": {
"node_type_id": "Standard_DS3_v3"
},
"cluster_key": "mlops_stacks-cluster-2",
"cluster_workers": 9
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.databricks
35 changes: 35 additions & 0 deletions acceptance/bundle/variables/var_file_overrides/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
bundle:
name: TestResolveVariablesFromFile

variables:
cluster:
type: "complex"
cluster_key:
cluster_workers:

resources:
jobs:
job1:
job_clusters:
- job_cluster_key: ${var.cluster_key}
new_cluster:
node_type_id: "${var.cluster.node_type_id}"
num_workers: ${var.cluster_workers}

targets:
with-defaults:
default: true
variables:
cluster_workers:
default: 1
cluster:
type: "complex"
default:
node_type_id: "default"
cluster_key:
default: "default"

without-defaults:

# see .databricks/bundle/default_target/ for variable values
with-default-variable-file:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need a target here? The default variables are read for any target, right? so it's the same as without-defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made separate target to avoid affecting other tests by this default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g. I put .databrick/bundle/without-defaults/variable-overrides.json file and previous test implicitly has this additional variable sources which may lead to confusion if anything goes wrong

Loading
Loading