Added annotations to output

This commit is contained in:
Ilya Kuznetsov 2025-01-21 18:16:06 +01:00
parent 47c8fb3651
commit 6f20e88b4a
No known key found for this signature in database
GPG Key ID: 91F3DDCF5D21CDDF
3 changed files with 27 additions and 11 deletions

View File

@ -1,4 +1,5 @@
=== variable file
>>> $CLI bundle validate -o json --var-file=var_files/normal.json
{
"job_cluster_key": "mlops_stacks-cluster",
@ -8,6 +9,7 @@
}
}
=== default variable file (see .databricks/*)
>>> $CLI bundle validate -o json --target with-default-variable-file
{
"job_cluster_key": "mlops_stacks-cluster-2",
@ -17,6 +19,7 @@
}
}
=== variable file and variable flag
>>> $CLI bundle validate -o json --var-file=var_files/normal.json --var=cluster_key=mlops_stacks-cluster-overriden
{
"job_cluster_key": "mlops_stacks-cluster-overriden",
@ -26,6 +29,7 @@
}
}
=== variable file and environment variable
>>> BUNDLE_VAR_cluster_key=incorrectly-overriden $CLI bundle validate -o json --var-file=var_files/normal.json
{
"job_cluster_key": "mlops_stacks-cluster",
@ -35,6 +39,7 @@
}
}
=== file not found
>>> errcode $CLI bundle validate -o json --var-file=var_files/not_found.json
Error: failed to read variables file: open var_files/not_found.json:<stripped>
@ -48,6 +53,7 @@ Exit code: 1
}
}
=== file cannot be parsed
>>> errcode $CLI bundle validate -o json --var-file=var_files/invalid_json.json
Error: failed to parse variables file: error decoding JSON at :0:0: invalid character 'o' in literal false (expecting 'a')
@ -61,6 +67,7 @@ Exit code: 1
}
}
=== file has wrong structure
>>> errcode $CLI bundle validate -o json --var-file=var_files/wrong_file_structure.json
Error: failed to parse variables file: var_files/wrong_file_structure.json:1:1: expected a map, found a sequence
in var_files/wrong_file_structure.json:1:1
@ -78,6 +85,7 @@ Exit code: 1
}
}
=== file has variable name that is not defined
>>> errcode $CLI bundle validate -o json --var-file=var_files/undeclared.json
Error: variable undeclared_var has not been defined
@ -91,6 +99,7 @@ Exit code: 1
}
}
=== file has variable name that is complex but default is string
>>> errcode $CLI bundle validate -o json --var-file=var_files/complex_to_string.json
Error: expected a map to index "variables.cluster.value.node_type_id", found string
@ -104,6 +113,7 @@ Exit code: 1
}
}
=== file has variable name that is string but default is complex
>>> errcode $CLI bundle validate -o json --var-file=var_files/string_to_complex.json
Error: failed to assign map[node_type_id:Standard_DS3_v2] to cluster_key: variable type is not complex
@ -117,6 +127,7 @@ Exit code: 1
}
}
=== variable is required but it's not provided in the file
>>> errcode $CLI bundle validate -o json --target without-defaults --var-file=var_files/without_required.json
Error: no value assigned to required variable cluster. Assignment can be done using "--var" or "--var-file", by setting the BUNDLE_VAR_cluster environment variable, or in .databricks/bundle/<target>/vars.json file

View File

@ -1,35 +1,35 @@
cluster_expr=".resources.jobs.job1.job_clusters[0]"
# variable file
title "variable file"
trace $CLI bundle validate -o json --var-file=var_files/normal.json | jq $cluster_expr
# default variable file (see .databricks/*)
title "default variable file (see .databricks/*)"
trace $CLI bundle validate -o json --target with-default-variable-file | jq $cluster_expr
# variable file and variable flag
title "variable file and variable flag"
trace $CLI bundle validate -o json --var-file=var_files/normal.json --var="cluster_key=mlops_stacks-cluster-overriden" | jq $cluster_expr
# variable file and environment variable
title "variable file and environment variable"
trace BUNDLE_VAR_cluster_key=incorrectly-overriden $CLI bundle validate -o json --var-file=var_files/normal.json | jq $cluster_expr
# file not found
title "file not found"
trace errcode $CLI bundle validate -o json --var-file=var_files/not_found.json 2> >(sed 's/\(Error: failed to read variables file: open var_files\/not_found.json:\).*/\1<stripped>/' >&2) > tmp.txt
jq "$cluster_expr" tmp.txt
# file cannot be parsed
title "file cannot be parsed"
trace errcode $CLI bundle validate -o json --var-file=var_files/invalid_json.json | jq $cluster_expr
# file has wrong structure
title "file has wrong structure"
trace errcode $CLI bundle validate -o json --var-file=var_files/wrong_file_structure.json | jq $cluster_expr
# file has variable name that is not defined
title "file has variable name that is not defined"
trace errcode $CLI bundle validate -o json --var-file=var_files/undeclared.json | jq $cluster_expr
# file has variable name that is complex but default is string
title "file has variable name that is complex but default is string"
trace errcode $CLI bundle validate -o json --var-file=var_files/complex_to_string.json | jq $cluster_expr
# file has variable name that is string but default is complex
title "file has variable name that is string but default is complex"
trace errcode $CLI bundle validate -o json --var-file=var_files/string_to_complex.json | jq $cluster_expr
# variable is required but it's not provided in the file
title "variable is required but it's not provided in the file"
trace errcode $CLI bundle validate -o json --target without-defaults --var-file=var_files/without_required.json | jq $cluster_expr

View File

@ -40,3 +40,8 @@ git-repo-init() {
git add databricks.yml
git commit -qm 'Add databricks.yml'
}
title() {
local label="$1"
printf "\n=== %s" "$label"
}