Move merge fix-ups after variable resolution (#2125)

## Changes
Move mutator.Merge{JobClusters,JobParameters,JobTasks,PipelineClusters}
after variable resolution. This helps with the case when key contains a
variable.

@pietern mentioned here
https://github.com/databricks/cli/pull/2101#pullrequestreview-2539168762
it should be safe.

## Tests
Existing acceptance that was capturing the bug is updated with corrected
output.
This commit is contained in:
Denis Bilenko 2025-01-13 14:01:31 +01:00 committed by GitHub
parent cae21b36de
commit 1ead1b2e36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 19 deletions

View File

@ -20,7 +20,6 @@ targets:
jobs:
foo:
job_clusters:
# This does not work because merging is done before resolution
- job_cluster_key: "${var.mykey}"
new_cluster:
node_type_id: i3.xlarge

View File

@ -9,17 +9,12 @@
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"job_clusters": [
{
"job_cluster_key": "key",
"new_cluster": {
"spark_version": "13.3.x-scala2.12"
}
},
{
"job_cluster_key": "key",
"new_cluster": {
"node_type_id": "i3.xlarge",
"num_workers": 1
"num_workers": 1,
"spark_version": "13.3.x-scala2.12"
}
}
],
@ -51,17 +46,12 @@ Validation OK!
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"job_clusters": [
{
"job_cluster_key": "key",
"new_cluster": {
"spark_version": "13.3.x-scala2.12"
}
},
{
"job_cluster_key": "key",
"new_cluster": {
"node_type_id": "i3.2xlarge",
"num_workers": 4
"num_workers": 4,
"spark_version": "13.3.x-scala2.12"
}
}
],

View File

@ -33,10 +33,6 @@ func Initialize() bundle.Mutator {
// If it is an ancestor, this updates all paths to be relative to the sync root path.
mutator.SyncInferRoot(),
mutator.MergeJobClusters(),
mutator.MergeJobParameters(),
mutator.MergeJobTasks(),
mutator.MergePipelineClusters(),
mutator.InitializeWorkspaceClient(),
mutator.PopulateCurrentUser(),
mutator.LoadGitDetails(),
@ -70,6 +66,12 @@ func Initialize() bundle.Mutator {
"workspace",
"variables",
),
mutator.MergeJobClusters(),
mutator.MergeJobParameters(),
mutator.MergeJobTasks(),
mutator.MergePipelineClusters(),
// Provide permission config errors & warnings after initializing all variables
permissions.PermissionDiagnostics(),
mutator.SetRunAs(),