mirror of https://github.com/databricks/cli.git
Fix compute override for foreach tasks (#1357)
## Changes Fix compute override for foreach tasks. ``` $ databricks bundle deploy --compute-id=xxx ``` ## Tests I added unit tests
This commit is contained in:
parent
4529b1ab98
commit
e42156411b
|
@ -22,7 +22,12 @@ func (m *overrideCompute) Name() string {
|
||||||
|
|
||||||
func overrideJobCompute(j *resources.Job, compute string) {
|
func overrideJobCompute(j *resources.Job, compute string) {
|
||||||
for i := range j.Tasks {
|
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 != "" {
|
if task.NewCluster != nil || task.ExistingClusterId != "" || task.ComputeKey != "" || task.JobClusterKey != "" {
|
||||||
task.NewCluster = nil
|
task.NewCluster = nil
|
||||||
task.JobClusterKey = ""
|
task.JobClusterKey = ""
|
||||||
|
|
|
@ -115,6 +115,31 @@ func TestOverridePipelineTask(t *testing.T) {
|
||||||
assert.Empty(t, b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)
|
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) {
|
func TestOverrideProduction(t *testing.T) {
|
||||||
b := &bundle.Bundle{
|
b := &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
|
Loading…
Reference in New Issue