Skip to content

Commit 86a5840

Browse files
authored
Merge pull request #237 from dbt-labs/release-0.2.21
2 parents 0c27632 + 3fdaefc commit 86a5840

File tree

12 files changed

+76
-28
lines changed

12 files changed

+76
-28
lines changed

CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
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.20...HEAD)
5+
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.21...HEAD)
6+
7+
## [0.2.21](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.20...v0.2.21)
8+
9+
## Changes
10+
11+
- Flag `fetch_deploy_key` as deprecated for `dbtcloud_repository`. The key is always fetched for the genetic git clone approach
12+
13+
## Documentations
14+
15+
- Add info about `versionless` dbt environment (Private Beta)
16+
- [#235](https://github.com/dbt-labs/terraform-provider-dbtcloud/issues/235) Fix docs on the examples for Fabric credentials
617

718
## [0.2.20](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.19...v0.2.20)
819

docs/data-sources/repository.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ description: |-
2222

2323
### Optional
2424

25-
- `fetch_deploy_key` (Boolean) Whether we should return the public deploy key
25+
- `fetch_deploy_key` (Boolean, Deprecated) Whether we should return the public deploy key
2626

2727
### Read-Only
2828

docs/guides/1_getting_started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ terraform {
5151
required_providers {
5252
dbtcloud = {
5353
source = "dbt-labs/dbtcloud"
54-
version = "0.2.2"
54+
version = "0.2.20"
5555
}
5656
}
5757
}

docs/resources/environment.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ description: |-
1818
// legacy names will be removed from 0.3 onwards
1919
2020
resource "dbtcloud_environment" "ci_environment" {
21-
// the dbt_version is always major.minor.0-latest or major.minor.0-pre
21+
// the dbt_version is major.minor.0-latest , major.minor.0-pre or versionless (Beta on 15 Feb 2024, to always be on the latest dbt version)
2222
dbt_version = "1.6.0-latest"
2323
name = "CI"
2424
project_id = dbtcloud_project.dbt_project.id
@@ -50,7 +50,7 @@ resource "dbtcloud_environment" "dev_environment" {
5050

5151
### Required
5252

53-
- `dbt_version` (String) Version number of dbt to use in this environment. It needs to be in the format `major.minor.0-latest` or `major.minor.0-pre`, e.g. `1.5.0-latest`
53+
- `dbt_version` (String) Version number of dbt to use in this environment. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre` or `versionless`. In a future version of the provider `versionless` will be the default if no version is provided
5454
- `name` (String) Environment name
5555
- `project_id` (Number) Project ID to create the environment in
5656
- `type` (String) The type of environment (must be either development or deployment)

docs/resources/repository.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ resource "dbtcloud_repository" "ado_repo" {
106106
- `azure_active_directory_project_id` (String) The Azure Dev Ops project ID. It can be retrieved via the Azure API or using the data source `dbtcloud_azure_dev_ops_project` and the project name - (for ADO native integration only)
107107
- `azure_active_directory_repository_id` (String) The Azure Dev Ops repository ID. It can be retrieved via the Azure API or using the data source `dbtcloud_azure_dev_ops_repository` along with the ADO Project ID and the repository name - (for ADO native integration only)
108108
- `azure_bypass_webhook_registration_failure` (Boolean) If set to False (the default), the connection will fail if the service user doesn't have access to set webhooks (required for auto-triggering CI jobs). If set to True, the connection will be successful but no automated CI job will be triggered - (for ADO native integration only)
109-
- `fetch_deploy_key` (Boolean) Whether we should return the public deploy key - (for the `deploy_key` strategy)
109+
- `fetch_deploy_key` (Boolean, Deprecated) Whether we should return the public deploy key - (for the `deploy_key` strategy)
110110
- `git_clone_strategy` (String) Git clone strategy for the repository. Can be `deploy_key` (default) for cloning via SSH Deploy Key, `github_app` for GitHub native integration, `deploy_token` for the GitLab native integration and `azure_active_directory_app` for ADO native integration
111111
- `github_installation_id` (Number) Identifier for the GitHub App - (for GitHub native integration only)
112112
- `gitlab_project_id` (Number) Identifier for the Gitlab project - (for GitLab native integration only)

examples/resources/dbtcloud_environment/resource.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// legacy names will be removed from 0.3 onwards
44

55
resource "dbtcloud_environment" "ci_environment" {
6-
// the dbt_version is always major.minor.0-latest or major.minor.0-pre
6+
// the dbt_version is major.minor.0-latest , major.minor.0-pre or versionless (Beta on 15 Feb 2024, to always be on the latest dbt version)
77
dbt_version = "1.6.0-latest"
88
name = "CI"
99
project_id = dbtcloud_project.dbt_project.id

guides/1_getting_started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ terraform {
5151
required_providers {
5252
dbtcloud = {
5353
source = "dbt-labs/dbtcloud"
54-
version = "0.2.2"
54+
version = "0.2.20"
5555
}
5656
}
5757
}

pkg/data_sources/repository.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var repositorySchema = map[string]*schema.Schema{
2525
Type: schema.TypeBool,
2626
Optional: true,
2727
Default: false,
28+
Deprecated: "This field is deprecated and will be removed in a future version of the provider. The key is always fetched when the clone strategy is `deploy_key`",
2829
Description: "Whether we should return the public deploy key",
2930
},
3031
"is_active": &schema.Schema{
@@ -71,16 +72,22 @@ func DatasourceRepository() *schema.Resource {
7172
}
7273
}
7374

74-
func datasourceRepositoryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
75+
func datasourceRepositoryRead(
76+
ctx context.Context,
77+
d *schema.ResourceData,
78+
m interface{},
79+
) diag.Diagnostics {
7580
c := m.(*dbt_cloud.Client)
7681

7782
var diags diag.Diagnostics
7883

7984
repositoryID := d.Get("repository_id").(int)
8085
projectID := d.Get("project_id").(int)
81-
fetchDeployKey := d.Get("fetch_deploy_key").(bool)
8286

83-
repository, err := c.GetRepository(strconv.Itoa(repositoryID), strconv.Itoa(projectID), fetchDeployKey)
87+
repository, err := c.GetRepository(
88+
strconv.Itoa(repositoryID),
89+
strconv.Itoa(projectID),
90+
)
8491
if err != nil {
8592
return diag.FromErr(err)
8693
}

pkg/dbt_cloud/repository.go

-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ type RepositoryResponse struct {
4343

4444
func (c *Client) GetRepository(
4545
repositoryID, projectID string,
46-
fetch_deploy_key bool,
4746
) (*Repository, error) {
4847

4948
repositoryUrl := fmt.Sprintf(
@@ -53,9 +52,6 @@ func (c *Client) GetRepository(
5352
projectID,
5453
repositoryID,
5554
)
56-
if fetch_deploy_key {
57-
repositoryUrl += "?include_related['deploy_key']"
58-
}
5955

6056
req, err := http.NewRequest("GET", repositoryUrl, nil)
6157
if err != nil {

pkg/resources/environment.go

+41-7
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func ResourceEnvironment() *schema.Resource {
4444
"dbt_version": &schema.Schema{
4545
Type: schema.TypeString,
4646
Required: true,
47-
Description: "Version number of dbt to use in this environment. It needs to be in the format `major.minor.0-latest` or `major.minor.0-pre`, e.g. `1.5.0-latest`",
47+
Description: "Version number of dbt to use in this environment. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre` or `versionless`. In a future version of the provider `versionless` will be the default if no version is provided",
4848
},
4949
"type": &schema.Schema{
5050
Type: schema.TypeString,
@@ -59,7 +59,14 @@ func ResourceEnvironment() *schema.Resource {
5959
"deployment":
6060
return
6161
}
62-
errs = append(errs, fmt.Errorf("%q must be either development or deployment, got: %q", key, type_))
62+
errs = append(
63+
errs,
64+
fmt.Errorf(
65+
"%q must be either development or deployment, got: %q",
66+
key,
67+
type_,
68+
),
69+
)
6370
return
6471
},
6572
},
@@ -99,7 +106,11 @@ func ResourceEnvironment() *schema.Resource {
99106
}
100107
}
101108

102-
func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
109+
func resourceEnvironmentCreate(
110+
ctx context.Context,
111+
d *schema.ResourceData,
112+
m interface{},
113+
) diag.Diagnostics {
103114
c := m.(*dbt_cloud.Client)
104115

105116
var diags diag.Diagnostics
@@ -115,7 +126,18 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m in
115126
deploymentType := d.Get("deployment_type").(string)
116127
extendedAttributesID := d.Get("extended_attributes_id").(int)
117128

118-
environment, err := c.CreateEnvironment(isActive, projectId, name, dbtVersion, type_, useCustomBranch, customBranch, credentialId, deploymentType, extendedAttributesID)
129+
environment, err := c.CreateEnvironment(
130+
isActive,
131+
projectId,
132+
name,
133+
dbtVersion,
134+
type_,
135+
useCustomBranch,
136+
customBranch,
137+
credentialId,
138+
deploymentType,
139+
extendedAttributesID,
140+
)
119141
if err != nil {
120142
return diag.FromErr(err)
121143
}
@@ -127,7 +149,11 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, m in
127149
return diags
128150
}
129151

130-
func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
152+
func resourceEnvironmentRead(
153+
ctx context.Context,
154+
d *schema.ResourceData,
155+
m interface{},
156+
) diag.Diagnostics {
131157
c := m.(*dbt_cloud.Client)
132158

133159
var diags diag.Diagnostics
@@ -188,7 +214,11 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, m inte
188214
return diags
189215
}
190216

191-
func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
217+
func resourceEnvironmentUpdate(
218+
ctx context.Context,
219+
d *schema.ResourceData,
220+
m interface{},
221+
) diag.Diagnostics {
192222
c := m.(*dbt_cloud.Client)
193223

194224
projectId, err := strconv.Atoi(strings.Split(d.Id(), dbt_cloud.ID_DELIMITER)[0])
@@ -269,7 +299,11 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, m in
269299
return resourceEnvironmentRead(ctx, d, m)
270300
}
271301

272-
func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
302+
func resourceEnvironmentDelete(
303+
ctx context.Context,
304+
d *schema.ResourceData,
305+
m interface{},
306+
) diag.Diagnostics {
273307
c := m.(*dbt_cloud.Client)
274308

275309
var diags diag.Diagnostics

pkg/resources/repository.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func ResourceRepository() *schema.Resource {
9191
Optional: true,
9292
Default: false,
9393
Description: "Whether we should return the public deploy key - (for the `deploy_key` strategy)",
94+
Deprecated: "This field is deprecated and will be removed in a future version of the provider, please remove it from your configuration. The key is always fetched when the clone strategy is `deploy_key`",
9495
},
9596
"deploy_key": &schema.Schema{
9697
Type: schema.TypeString,
@@ -157,9 +158,8 @@ func resourceRepositoryRead(
157158

158159
projectIdString := strings.Split(d.Id(), dbt_cloud.ID_DELIMITER)[0]
159160
repositoryIdString := strings.Split(d.Id(), dbt_cloud.ID_DELIMITER)[1]
160-
fetchDeployKey := d.Get("fetch_deploy_key").(bool)
161161

162-
repository, err := c.GetRepository(repositoryIdString, projectIdString, fetchDeployKey)
162+
repository, err := c.GetRepository(repositoryIdString, projectIdString)
163163
if err != nil {
164164
if strings.HasPrefix(err.Error(), "resource-not-found") {
165165
d.SetId("")
@@ -219,10 +219,9 @@ func resourceRepositoryUpdate(
219219

220220
projectIdString := strings.Split(d.Id(), dbt_cloud.ID_DELIMITER)[0]
221221
repositoryIdString := strings.Split(d.Id(), dbt_cloud.ID_DELIMITER)[1]
222-
fetchDeployKey := d.Get("fetch_deploy_key").(bool)
223222

224223
if d.HasChange("is_active") {
225-
repository, err := c.GetRepository(repositoryIdString, projectIdString, fetchDeployKey)
224+
repository, err := c.GetRepository(repositoryIdString, projectIdString)
226225
if err != nil {
227226
return diag.FromErr(err)
228227
}

pkg/resources/repository_acceptance_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ resource "dbtcloud_project" "test_project" {
134134
resource "dbtcloud_repository" "test_repository_github" {
135135
remote_url = "%s"
136136
project_id = dbtcloud_project.test_project.id
137+
fetch_deploy_key = true
137138
depends_on = [dbtcloud_project.test_project]
138139
}
139140
`, projectName, repoUrl)
@@ -182,7 +183,7 @@ func testAccCheckDbtCloudRepositoryExists(resource string) resource.TestCheckFun
182183
projectId := strings.Split(rs.Primary.ID, dbt_cloud.ID_DELIMITER)[0]
183184
repositoryId := strings.Split(rs.Primary.ID, dbt_cloud.ID_DELIMITER)[1]
184185

185-
_, err := apiClient.GetRepository(repositoryId, projectId, false)
186+
_, err := apiClient.GetRepository(repositoryId, projectId)
186187
if err != nil {
187188
return fmt.Errorf("error fetching item with resource %s. %s", resource, err)
188189
}
@@ -200,7 +201,7 @@ func testAccCheckDbtCloudRepositoryDestroy(s *terraform.State) error {
200201
projectId := strings.Split(rs.Primary.ID, dbt_cloud.ID_DELIMITER)[0]
201202
repositoryId := strings.Split(rs.Primary.ID, dbt_cloud.ID_DELIMITER)[1]
202203

203-
_, err := apiClient.GetRepository(repositoryId, projectId, false)
204+
_, err := apiClient.GetRepository(repositoryId, projectId)
204205
if err == nil {
205206
return fmt.Errorf("Repository still exists")
206207
}

0 commit comments

Comments
 (0)