Skip to content

Commit

Permalink
Merge pull request #25 from gary-beautypie/main
Browse files Browse the repository at this point in the history
Fix - Handle trigger defaults gracefully
  • Loading branch information
GtheSheep authored Oct 11, 2021
2 parents 831c0e8 + fdba511 commit fce14a8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
18 changes: 18 additions & 0 deletions examples/jobs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "dbt_cloud_job" "test" {
environment_id = <environment_id>
execute_steps = [
"dbt test"
]
generate_docs = false
is_active = true
name = "Test"
num_threads = 64
project_id = <project_id>
run_generate_sources = false
target_name = "default"
triggers = {
"custom_branch_only" : true,
"github_webhook" : false,
"schedule" : false
}
}
13 changes: 13 additions & 0 deletions examples/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_providers {
dbt = {
source = "GtheSheep/dbt-cloud"
version = "0.0.39"
}
}
}

provider "dbt" {
account_id = <ACCOUNT_ID>
token = "<TOKEN>>"
}
18 changes: 15 additions & 3 deletions pkg/dbt_cloud/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,22 @@ func (c *Client) CreateJob(projectId int, environmentId int, name string, execut
if !isActive {
state = 2
}
github_webhook, gw_found := triggers["github_webhook"]
if !gw_found {
github_webhook = false
}
schedule, s_found := triggers["schedule"]
if !s_found {
schedule = false
}
custom_branch_only, cbo_found := triggers["custom_branch_only"]
if !cbo_found {
custom_branch_only = false
}
jobTriggers := JobTrigger{
Github_Webhook: triggers["github_webhook"].(bool),
Schedule: triggers["schedule"].(bool),
Custom_Branch_Only: triggers["custom_branch_only"].(bool),
Github_Webhook: github_webhook.(bool),
Schedule: schedule.(bool),
Custom_Branch_Only: custom_branch_only.(bool),
}
jobSettings := JobSettings{
Threads: numThreads,
Expand Down

0 comments on commit fce14a8

Please sign in to comment.