Skip to content

Commit c128bd5

Browse files
authored
Merge pull request #248 from dbt-labs/release-0.2.24
2 parents 29f2e93 + 14ca90b commit c128bd5

File tree

3 files changed

+55
-8
lines changed

3 files changed

+55
-8
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.23...HEAD)
5+
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.24...HEAD)
6+
7+
## [0.2.24](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.23...v0.2.24)
8+
9+
## Fixes
10+
11+
- [#247](https://github.com/dbt-labs/terraform-provider-dbtcloud/issues/247) Segfault when the env var for the token is empty
12+
- [Internal] Issue with `job_ids` required to be set going forward, even if it is empty
613

714
## [0.2.23](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.22...v0.2.23)
815

pkg/dbt_cloud/client.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,19 @@ type APIError struct {
9191

9292
// NewClient -
9393
func NewClient(account_id *int, token *string, host_url *string) (*Client, error) {
94+
95+
if (token == nil) || (*token == "") {
96+
return nil, fmt.Errorf("token is set but it is empty")
97+
}
98+
9499
c := Client{
95100
HTTPClient: &http.Client{Timeout: 30 * time.Second},
96101
HostURL: *host_url,
97102
Token: *token,
98103
AccountID: *account_id,
99104
}
100105

101-
if (account_id != nil) && (token != nil) {
106+
if account_id != nil {
102107
url := fmt.Sprintf("%s/v2/accounts/", *host_url)
103108

104109
// authenticate

pkg/dbt_cloud/webhook.go

+41-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type WebhookRead struct {
1919
Description string `json:"description,omitempty"`
2020
ClientUrl string `json:"client_url"`
2121
EventTypes []string `json:"event_types,omitempty"`
22-
JobIds []string `json:"job_ids,omitempty"`
22+
JobIds []string `json:"job_ids"`
2323
Active bool `json:"active,omitempty"`
2424
HmacSecret *string `json:"hmac_secret,omitempty"`
2525
HttpStatusCode *string `json:"http_status_code,omitempty"`
@@ -32,12 +32,21 @@ type WebhookWrite struct {
3232
Description string `json:"description,omitempty"`
3333
ClientUrl string `json:"client_url"`
3434
EventTypes []string `json:"event_types,omitempty"`
35-
JobIds []int `json:"job_ids,omitempty"`
35+
JobIds []int `json:"job_ids"`
3636
Active bool `json:"active,omitempty"`
3737
}
3838

3939
func (c *Client) GetWebhook(webhookID string) (*WebhookRead, error) {
40-
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v3/accounts/%s/webhooks/subscription/%s", c.HostURL, strconv.Itoa(c.AccountID), webhookID), nil)
40+
req, err := http.NewRequest(
41+
"GET",
42+
fmt.Sprintf(
43+
"%s/v3/accounts/%s/webhooks/subscription/%s",
44+
c.HostURL,
45+
strconv.Itoa(c.AccountID),
46+
webhookID,
47+
),
48+
nil,
49+
)
4150
if err != nil {
4251
return nil, err
4352
}
@@ -81,7 +90,15 @@ func (c *Client) CreateWebhook(
8190
return nil, err
8291
}
8392

84-
req, err := http.NewRequest("POST", fmt.Sprintf("%s/v3/accounts/%s/webhooks/subscriptions", c.HostURL, strconv.Itoa(c.AccountID)), strings.NewReader(string(newWebhookData)))
93+
req, err := http.NewRequest(
94+
"POST",
95+
fmt.Sprintf(
96+
"%s/v3/accounts/%s/webhooks/subscriptions",
97+
c.HostURL,
98+
strconv.Itoa(c.AccountID),
99+
),
100+
strings.NewReader(string(newWebhookData)),
101+
)
85102
if err != nil {
86103
return nil, err
87104
}
@@ -106,7 +123,16 @@ func (c *Client) UpdateWebhook(webhookId string, webhook WebhookWrite) (*Webhook
106123
return nil, err
107124
}
108125

109-
req, err := http.NewRequest("PUT", fmt.Sprintf("%s/v3/accounts/%s/webhooks/subscription/%s", c.HostURL, strconv.Itoa(c.AccountID), webhookId), strings.NewReader(string(webhookData)))
126+
req, err := http.NewRequest(
127+
"PUT",
128+
fmt.Sprintf(
129+
"%s/v3/accounts/%s/webhooks/subscription/%s",
130+
c.HostURL,
131+
strconv.Itoa(c.AccountID),
132+
webhookId,
133+
),
134+
strings.NewReader(string(webhookData)),
135+
)
110136
if err != nil {
111137
return nil, err
112138
}
@@ -126,7 +152,16 @@ func (c *Client) UpdateWebhook(webhookId string, webhook WebhookWrite) (*Webhook
126152
}
127153

128154
func (c *Client) DeleteWebhook(webhookId string) (string, error) {
129-
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v3/accounts/%s/webhooks/subscription/%s", c.HostURL, strconv.Itoa(c.AccountID), webhookId), nil)
155+
req, err := http.NewRequest(
156+
"DELETE",
157+
fmt.Sprintf(
158+
"%s/v3/accounts/%s/webhooks/subscription/%s",
159+
c.HostURL,
160+
strconv.Itoa(c.AccountID),
161+
webhookId,
162+
),
163+
nil,
164+
)
130165
if err != nil {
131166
return "", err
132167
}

0 commit comments

Comments
 (0)