Skip to content

Commit 570911e

Browse files
Add git job_source to job resource (#2538)
* Add git job_source to job resource * lint * fix test * Use go sdk type
1 parent ac6dc23 commit 570911e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

jobs/resource_job.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ type CronSchedule struct {
161161

162162
// BEGIN Jobs + Repo integration preview
163163
type GitSource struct {
164-
Url string `json:"git_url" tf:"alias:url"`
165-
Provider string `json:"git_provider,omitempty" tf:"alias:provider"`
166-
Branch string `json:"git_branch,omitempty" tf:"alias:branch"`
167-
Tag string `json:"git_tag,omitempty" tf:"alias:tag"`
168-
Commit string `json:"git_commit,omitempty" tf:"alias:commit"`
164+
Url string `json:"git_url" tf:"alias:url"`
165+
Provider string `json:"git_provider,omitempty" tf:"alias:provider"`
166+
Branch string `json:"git_branch,omitempty" tf:"alias:branch"`
167+
Tag string `json:"git_tag,omitempty" tf:"alias:tag"`
168+
Commit string `json:"git_commit,omitempty" tf:"alias:commit"`
169+
JobSource *jobs.JobSource `json:"job_source,omitempty"`
169170
}
170171

171172
// End Jobs + Repo integration preview

jobs/resource_job_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/databricks/databricks-sdk-go/apierr"
1111
"github.com/databricks/databricks-sdk-go/service/compute"
12+
"github.com/databricks/databricks-sdk-go/service/jobs"
1213
"github.com/databricks/terraform-provider-databricks/clusters"
1314
"github.com/databricks/terraform-provider-databricks/common"
1415
"github.com/databricks/terraform-provider-databricks/libraries"
@@ -1081,6 +1082,11 @@ func TestResourceJobCreateFromGitSource(t *testing.T) {
10811082
Url: "https://github.com/databricks/terraform-provider-databricks",
10821083
Tag: "0.4.8",
10831084
Provider: "gitHub",
1085+
JobSource: &jobs.JobSource{
1086+
JobConfigPath: "a/b/c/databricks.yml",
1087+
ImportFromGitBranch: "main",
1088+
DirtyState: "NOT_SYNCED",
1089+
},
10841090
},
10851091
},
10861092
Response: Job{
@@ -1115,6 +1121,11 @@ func TestResourceJobCreateFromGitSource(t *testing.T) {
11151121
git_source {
11161122
url = "https://github.com/databricks/terraform-provider-databricks"
11171123
tag = "0.4.8"
1124+
job_source {
1125+
job_config_path = "a/b/c/databricks.yml"
1126+
import_from_git_branch = "main"
1127+
dirty_state = "NOT_SYNCED"
1128+
}
11181129
}
11191130
11201131
task {
@@ -1204,7 +1215,7 @@ func TestResourceJobCreateFromGitSourceWithoutProviderFail(t *testing.T) {
12041215
}
12051216
}
12061217
`,
1207-
}.ExpectError(t, "git source is not empty but Git Provider is not specified and cannot be guessed by url &{Url:https://custom.git.hosting.com/databricks/terraform-provider-databricks Provider: Branch: Tag:0.4.8 Commit:}")
1218+
}.ExpectError(t, "git source is not empty but Git Provider is not specified and cannot be guessed by url &{Url:https://custom.git.hosting.com/databricks/terraform-provider-databricks Provider: Branch: Tag:0.4.8 Commit: JobSource:<nil>}")
12081219
}
12091220

12101221
func TestResourceJobCreateSingleNode_Fail(t *testing.T) {

0 commit comments

Comments
 (0)