Skip to content

Commit

Permalink
Add Dbt project test (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-aleksandrboldyrev authored Sep 18, 2024
1 parent 8e99df5 commit 534e5aa
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.3.2](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.3.1...v1.3.2)

## Added
- DBT project test in resource `fivetran_dbt_git_project_config`
- `schema_change_handling` is no longer required for `fivetran_connector_schema_config` resource

## [1.3.1](https://github.com/fivetran/terraform-provider-fivetran/compare/v1.3.0...v1.3.1)
Expand Down
2 changes: 1 addition & 1 deletion fivetran/framework/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

const Version = "1.3.0" // Current provider version
const Version = "1.3.2" // Current provider version

type fivetranProvider struct {
mockClient httputils.HttpClient
Expand Down
20 changes: 20 additions & 0 deletions fivetran/framework/resources/dbt_git_project_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func (r *dbtGitProjectConfig) Create(ctx context.Context, req resource.CreateReq
data.ReadFromResponse(projectResponse)

if data.EnsureReadiness.Equal(types.BoolValue(false)) {
testReponse, err := r.GetClient().NewDbtProjectTest().ProjectID(data.ProjectId.ValueString()).Do(ctx)
if err != nil {
resp.Diagnostics.AddError(
"Dbt Project Test.",
fmt.Sprintf("%v; code: %v", err, testReponse.Code),
)

return
}

if ok, _ := ensureProjectIsReady(ctx, client, data.ProjectId.ValueString()); !ok {
resp.Diagnostics.AddWarning(
"Unable to finish set up dbt Git Project Config Resource.",
Expand Down Expand Up @@ -173,6 +183,16 @@ func (r *dbtGitProjectConfig) Update(ctx context.Context, req resource.UpdateReq
plan.ReadFromResponse(projectResponse)

if plan.EnsureReadiness.Equal(types.BoolValue(false)) {
testReponse, err := r.GetClient().NewDbtProjectTest().ProjectID(plan.ProjectId.ValueString()).Do(ctx)
if err != nil {
resp.Diagnostics.AddError(
"Dbt Project Test.",
fmt.Sprintf("%v; code: %v", err, testReponse.Code),
)

return
}

if ok, _ := ensureProjectIsReady(ctx, client, plan.ProjectId.ValueString()); !ok {
resp.Diagnostics.AddWarning(
"Unable to finish set up dbt Git Project Config Resource.",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/fivetran/terraform-provider-fivetran

require (
github.com/fivetran/go-fivetran v0.9.2
github.com/fivetran/go-fivetran v0.9.4
github.com/hashicorp/terraform-plugin-framework v1.8.0
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fivetran/go-fivetran v0.9.2 h1:H3AY9nB3mJ7Kjd2vzT3bQfko5JZ/vVYu1zuM47bRaG8=
github.com/fivetran/go-fivetran v0.9.2/go.mod h1:EIy5Uwn1zylQCr/7O+8rrwvmjvhW3PPpzHkQj26ON7Y=
github.com/fivetran/go-fivetran v0.9.4 h1:9F7XzoezZxnhCW331NpN49ace8YfsJ8+92oyjxIj88o=
github.com/fivetran/go-fivetran v0.9.4/go.mod h1:EIy5Uwn1zylQCr/7O+8rrwvmjvhW3PPpzHkQj26ON7Y=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
Expand Down

0 comments on commit 534e5aa

Please sign in to comment.