@@ -2,10 +2,10 @@ package resourcemutator
22
33import (
44 "context"
5- "fmt"
65
76 "github.com/databricks/cli/bundle"
87 "github.com/databricks/cli/libs/diag"
8+ "github.com/databricks/cli/libs/structs/structpath"
99 "github.com/databricks/databricks-sdk-go/service/jobs"
1010)
1111
@@ -50,9 +50,9 @@ func (a *applyDefaultTaskSource) Apply(ctx context.Context, b *bundle.Bundle) di
5050
5151 for i := range job .Tasks {
5252 task := & job .Tasks [i ]
53- taskPath := fmt . Sprintf ( "resources. jobs.%s.tasks[%d] " , name , i )
53+ taskPath := structpath . NewPath ( nil , "resources" , " jobs" , name , "tasks" , i )
5454 if task .ForEachTask != nil {
55- setGitTaskSource (b , taskPath + ". for_each_task. task" , & task .ForEachTask .Task )
55+ setGitTaskSource (b , structpath . NewPath ( taskPath , " for_each_task" , " task") , & task .ForEachTask .Task )
5656 }
5757 setGitTaskSource (b , taskPath , task )
5858 }
@@ -64,32 +64,32 @@ func (a *applyDefaultTaskSource) Apply(ctx context.Context, b *bundle.Bundle) di
6464// supports the field, unless the user already set it.
6565// The task types are the ones that support the `source` field:
6666// https://docs.databricks.com/api/workspace/jobs/create
67- func setGitTaskSource (b * bundle.Bundle , taskPath string , task * jobs.Task ) {
67+ func setGitTaskSource (b * bundle.Bundle , taskPath * structpath. PathNode , task * jobs.Task ) {
6868 type taskSource struct {
69- key string
69+ path [] any
7070 source * jobs.Source
7171 }
7272 var sources []taskSource
7373 if task .DbtTask != nil {
74- sources = append (sources , taskSource {"dbt_task" , & task .DbtTask .Source })
74+ sources = append (sources , taskSource {[] any { "dbt_task" , "source" } , & task .DbtTask .Source })
7575 }
7676 if task .GenAiComputeTask != nil {
77- sources = append (sources , taskSource {"gen_ai_compute_task" , & task .GenAiComputeTask .Source })
77+ sources = append (sources , taskSource {[] any { "gen_ai_compute_task" , "source" } , & task .GenAiComputeTask .Source })
7878 }
7979 if task .NotebookTask != nil {
80- sources = append (sources , taskSource {"notebook_task" , & task .NotebookTask .Source })
80+ sources = append (sources , taskSource {[] any { "notebook_task" , "source" } , & task .NotebookTask .Source })
8181 }
8282 if task .SparkPythonTask != nil {
83- sources = append (sources , taskSource {"spark_python_task" , & task .SparkPythonTask .Source })
83+ sources = append (sources , taskSource {[] any { "spark_python_task" , "source" } , & task .SparkPythonTask .Source })
8484 }
8585 if task .SqlTask != nil && task .SqlTask .File != nil {
86- sources = append (sources , taskSource {"sql_task. file" , & task .SqlTask .File .Source })
86+ sources = append (sources , taskSource {[] any { "sql_task" , " file", "source" } , & task .SqlTask .File .Source })
8787 }
8888 for _ , s := range sources {
8989 // An explicit `source: ""` is set by the user, although the typed value is
9090 // empty; not every task type has ForceSendFields to record it, but it is
9191 // defined in the configuration.
92- if * s .source != "" || b .Config .DefinitionLocation ( taskPath + "." + s . key + ".source" ).File != "" {
92+ if * s .source != "" || b .Config .DefinitionLocationOf ( structpath . NewPath ( taskPath , s . path ... ) ).File != "" {
9393 continue
9494 }
9595 * s .source = jobs .SourceGit
0 commit comments