diff --git a/bundle/config/mutator/override_compute.go b/bundle/config/mutator/override_compute.go index 6b5c89be10..11a6611233 100644 --- a/bundle/config/mutator/override_compute.go +++ b/bundle/config/mutator/override_compute.go @@ -22,7 +22,12 @@ func (m *overrideCompute) Name() string { func overrideJobCompute(j *resources.Job, compute string) { for i := range j.Tasks { - task := &j.Tasks[i] + var task = &j.Tasks[i] + + if task.ForEachTask != nil { + task = &task.ForEachTask.Task + } + if task.NewCluster != nil || task.ExistingClusterId != "" || task.ComputeKey != "" || task.JobClusterKey != "" { task.NewCluster = nil task.JobClusterKey = "" diff --git a/bundle/config/mutator/override_compute_test.go b/bundle/config/mutator/override_compute_test.go index e5087167dd..7c0e1cefa3 100644 --- a/bundle/config/mutator/override_compute_test.go +++ b/bundle/config/mutator/override_compute_test.go @@ -115,6 +115,31 @@ func TestOverridePipelineTask(t *testing.T) { assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId) } +func TestOverrideForEachTask(t *testing.T) { + t.Setenv("DATABRICKS_CLUSTER_ID", "newClusterId") + b := &bundle.Bundle{ + Config: config.Root{ + Resources: config.Resources{ + Jobs: map[string]*resources.Job{ + "job1": {JobSettings: &jobs.JobSettings{ + Name: "job1", + Tasks: []jobs.Task{ + { + ForEachTask: &jobs.ForEachTask{}, + }, + }, + }}, + }, + }, + }, + } + + m := mutator.OverrideCompute() + diags := bundle.Apply(context.Background(), b, m) + require.NoError(t, diags.Error()) + assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[0].ForEachTask.Task) +} + func TestOverrideProduction(t *testing.T) { b := &bundle.Bundle{ Config: config.Root{