Skip to content

Commit fce14a8

Browse files
authored
Merge pull request #25 from gary-beautypie/main
Fix - Handle trigger defaults gracefully
2 parents 831c0e8 + fdba511 commit fce14a8

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

examples/jobs.tf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
resource "dbt_cloud_job" "test" {
2+
environment_id = <environment_id>
3+
execute_steps = [
4+
"dbt test"
5+
]
6+
generate_docs = false
7+
is_active = true
8+
name = "Test"
9+
num_threads = 64
10+
project_id = <project_id>
11+
run_generate_sources = false
12+
target_name = "default"
13+
triggers = {
14+
"custom_branch_only" : true,
15+
"github_webhook" : false,
16+
"schedule" : false
17+
}
18+
}

examples/providers.tf

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
terraform {
2+
required_providers {
3+
dbt = {
4+
source = "GtheSheep/dbt-cloud"
5+
version = "0.0.39"
6+
}
7+
}
8+
}
9+
10+
provider "dbt" {
11+
account_id = <ACCOUNT_ID>
12+
token = "<TOKEN>>"
13+
}

pkg/dbt_cloud/job.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,22 @@ func (c *Client) CreateJob(projectId int, environmentId int, name string, execut
8686
if !isActive {
8787
state = 2
8888
}
89+
github_webhook, gw_found := triggers["github_webhook"]
90+
if !gw_found {
91+
github_webhook = false
92+
}
93+
schedule, s_found := triggers["schedule"]
94+
if !s_found {
95+
schedule = false
96+
}
97+
custom_branch_only, cbo_found := triggers["custom_branch_only"]
98+
if !cbo_found {
99+
custom_branch_only = false
100+
}
89101
jobTriggers := JobTrigger{
90-
Github_Webhook: triggers["github_webhook"].(bool),
91-
Schedule: triggers["schedule"].(bool),
92-
Custom_Branch_Only: triggers["custom_branch_only"].(bool),
102+
Github_Webhook: github_webhook.(bool),
103+
Schedule: schedule.(bool),
104+
Custom_Branch_Only: custom_branch_only.(bool),
93105
}
94106
jobSettings := JobSettings{
95107
Threads: numThreads,

0 commit comments

Comments
 (0)