Skip to content

Commit 9836535

Browse files
committed
Accept new Fusion release tracks as dbt_version (#684)
Allow `fusion-stable`, `fusion-extended`, `fusion-nightly`, and `fusion-fallback` alongside `latest-fusion` on `dbtcloud_environment` and `dbtcloud_job`. Update the `force_node_selection` validator to treat any Fusion release track the same as `latest-fusion`.
1 parent 7c10923 commit 9836535

8 files changed

Lines changed: 35 additions & 19 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Changes
2+
body: Allow new Fusion release tracks (`fusion-stable`, `fusion-extended`, `fusion-nightly`, `fusion-fallback`) as `dbt_version` on `dbtcloud_environment` and `dbtcloud_job`, alongside `latest-fusion`. The `force_node_selection` validator now treats any Fusion release track the same as `latest-fusion` (#684).
3+
time: 2026-05-21T15:12:22.000000+00:00

docs/resources/environment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Resource to manage dbt Cloud environments for the different dbt Cloud projects.
1414

1515
```terraform
1616
resource "dbtcloud_environment" "ci_environment" {
17-
// the dbt_version is major.minor.0-latest , major.minor.0-pre, compatible, extended, versionless, latest or latest-fusion (by default, it is set to latest if not configured)
17+
// the dbt_version is major.minor.0-latest, major.minor.0-pre, compatible, extended, versionless, latest, or one of the Fusion release tracks: latest-fusion, fusion-stable, fusion-extended, fusion-nightly, fusion-fallback (by default, it is set to latest if not configured)
1818
dbt_version = "latest"
1919
name = "CI"
2020
project_id = dbtcloud_project.dbt_project.id
@@ -72,7 +72,7 @@ resource "dbtcloud_environment" "profiled_environment" {
7272
- `connection_id` (Number) A connection ID (used with Global Connections)
7373
- `credential_id` (Number) The Credential ID for this environment. A credential is not actionable for development environments, as users have to set their own development credentials in dbt Cloud.
7474
- `custom_branch` (String) The custom branch name to use
75-
- `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`, `compatible`, `extended`, `versionless`, `latest` or `latest-fusion`. While `versionless` is still supported, using `latest` is recommended. Defaults to `latest` if no version is provided
75+
- `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`, `compatible`, `extended`, `versionless`, `latest`, or one of the Fusion release tracks (`latest-fusion`, `fusion-stable`, `fusion-extended`, `fusion-nightly`, `fusion-fallback`). While `versionless` is still supported, using `latest` is recommended. Defaults to `latest` if no version is provided
7676
- `deployment_type` (String) The type of environment. Only valid for environments of type 'deployment' and for now can only be 'production', 'staging' or left empty for generic environments
7777
- `enable_model_query_history` (Boolean) Whether to enable model query history in this environment. As of Oct 2024, works only for Snowflake and BigQuery.
7878
- `extended_attributes_id` (Number) The ID of the extended attributes applied

docs/resources/job.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ An example can be found [in this GitHub issue](https://github.com/dbt-labs/terra
218218
### Optional
219219

220220
- `compare_changes_flags` (String) The model selector for checking changes in the compare changes Advanced CI feature
221-
- `dbt_version` (String) Version number of dbt to use in this job. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest` or `latest-fusion`. While `versionless` is still supported, using `latest` is recommended. If not set, the `dbt_version` configured on the environment is used.
221+
- `dbt_version` (String) Version number of dbt to use in this job. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest`, or one of the Fusion release tracks (`latest-fusion`, `fusion-stable`, `fusion-extended`, `fusion-nightly`, `fusion-fallback`). While `versionless` is still supported, using `latest` is recommended. If not set, the `dbt_version` configured on the environment is used.
222222
- `deferring_environment_id` (Number) Environment identifier that this job defers to (new deferring approach)
223223
- `deferring_job_id` (Number) Job identifier that this job defers to (legacy deferring approach)
224224
- `description` (String) Description for the job
225225
- `errors_on_lint_failure` (Boolean) Whether the CI job should fail when a lint error is found. Only used when `run_lint` is set to `true`. Defaults to `true`.
226226
- `execution` (Attributes) Execution settings for the job (see [below for nested schema](#nestedatt--execution))
227-
- `force_node_selection` (Boolean) Whether to force node selection (SAO - Select All Optimizations) for the job. If `dbt_version` is not set to `latest-fusion`, this must be set to `true` when specified.
227+
- `force_node_selection` (Boolean) Whether to force node selection (SAO - Select All Optimizations) for the job. If `dbt_version` is not set to a Fusion release track (e.g. `latest-fusion`), this must be set to `true` when specified.
228228
- `generate_docs` (Boolean) Flag for whether the job should generate documentation
229229
- `is_active` (Boolean) Should always be set to true as setting it to false is the same as creating a job in a deleted state. To create/keep a job in a 'deactivated' state, check the `triggers` config. Setting it to false essentially deletes the job. On resource creation, this field is enforced to be true.
230230
- `job_completion_trigger_condition` (Block List) Which other job should trigger this job when it finishes, and on which conditions (sometimes referred as 'job chaining'). (see [below for nested schema](#nestedblock--job_completion_trigger_condition))

examples/resources/dbtcloud_environment/resource.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "dbtcloud_environment" "ci_environment" {
2-
// the dbt_version is major.minor.0-latest , major.minor.0-pre, compatible, extended, versionless, latest or latest-fusion (by default, it is set to latest if not configured)
2+
// the dbt_version is major.minor.0-latest, major.minor.0-pre, compatible, extended, versionless, latest, or one of the Fusion release tracks: latest-fusion, fusion-stable, fusion-extended, fusion-nightly, fusion-fallback (by default, it is set to latest if not configured)
33
dbt_version = "latest"
44
name = "CI"
55
project_id = dbtcloud_project.dbt_project.id

pkg/framework/objects/environment/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func (r *environmentResource) Schema(
216216
Computed: true,
217217
Optional: true,
218218
Default: stringdefault.StaticString("latest"),
219-
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`, `compatible`, `extended`, `versionless`, `latest` or `latest-fusion`. While `versionless` is still supported, using `latest` is recommended. Defaults to `latest` if no version is provided",
219+
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`, `compatible`, `extended`, `versionless`, `latest`, or one of the Fusion release tracks (`latest-fusion`, `fusion-stable`, `fusion-extended`, `fusion-nightly`, `fusion-fallback`). While `versionless` is still supported, using `latest` is recommended. Defaults to `latest` if no version is provided",
220220
Validators: []validator.String{
221221
helper.DbtVersionValidator{}, // Custom validator to check the dbt version format
222222
},

pkg/framework/objects/job/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,12 @@ func (j *jobResource) Schema(
466466
},
467467
"dbt_version": resource_schema.StringAttribute{
468468
Optional: true,
469-
Description: "Version number of dbt to use in this job. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest` or `latest-fusion`. While `versionless` is still supported, using `latest` is recommended. If not set, the `dbt_version` configured on the environment is used.",
469+
Description: "Version number of dbt to use in this job. It needs to be in the format `major.minor.0-latest` (e.g. `1.5.0-latest`), `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest`, or one of the Fusion release tracks (`latest-fusion`, `fusion-stable`, `fusion-extended`, `fusion-nightly`, `fusion-fallback`). While `versionless` is still supported, using `latest` is recommended. If not set, the `dbt_version` configured on the environment is used.",
470470
},
471471
"force_node_selection": resource_schema.BoolAttribute{
472472
Optional: true,
473473
Computed: true,
474-
Description: "Whether to force node selection (SAO - Select All Optimizations) for the job. If `dbt_version` is not set to `latest-fusion`, this must be set to `true` when specified.",
474+
Description: "Whether to force node selection (SAO - Select All Optimizations) for the job. If `dbt_version` is not set to a Fusion release track (e.g. `latest-fusion`), this must be set to `true` when specified.",
475475
Validators: []validator.Bool{
476476
job_validators.ForceNodeSelectionValidator(),
477477
},

pkg/framework/objects/job/validators/force_node_selection_validator.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/dbt-labs/terraform-provider-dbtcloud/pkg/helper"
78
"github.com/hashicorp/terraform-plugin-framework/path"
89
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
910
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -15,12 +16,12 @@ type forceNodeSelectionValidator struct{}
1516

1617
// Description returns a plain text description of the validator's behavior, suitable for a practitioner to understand its impact.
1718
func (v forceNodeSelectionValidator) Description(ctx context.Context) string {
18-
return "When dbt_version is not 'latest-fusion', force_node_selection must be set to true"
19+
return "When dbt_version is not a Fusion release track (e.g. 'latest-fusion'), force_node_selection must be set to true"
1920
}
2021

2122
// MarkdownDescription returns a markdown formatted description of the validator's behavior, suitable for a practitioner to understand its impact.
2223
func (v forceNodeSelectionValidator) MarkdownDescription(ctx context.Context) string {
23-
return "When `dbt_version` is not `latest-fusion`, `force_node_selection` must be set to `true`"
24+
return "When `dbt_version` is not a Fusion release track (e.g. `latest-fusion`), `force_node_selection` must be set to `true`"
2425
}
2526

2627
// ValidateBool performs the validation.
@@ -46,22 +47,22 @@ func (v forceNodeSelectionValidator) ValidateBool(ctx context.Context, req valid
4647
return
4748
}
4849

49-
// Validation: if dbt_version is not "latest-fusion", force_node_selection must be true
50-
if dbtVersion.ValueString() != "latest-fusion" && !forceNodeSelection {
50+
// Validation: if dbt_version is not a Fusion release track, force_node_selection must be true
51+
if !helper.IsFusionVersion(dbtVersion.ValueString()) && !forceNodeSelection {
5152
resp.Diagnostics.AddAttributeError(
5253
req.Path,
5354
"Invalid force_node_selection Configuration",
5455
fmt.Sprintf(
55-
"When dbt_version is '%s' (not 'latest-fusion'), force_node_selection must be set to true. "+
56-
"Set force_node_selection = true or change dbt_version to 'latest-fusion'.",
56+
"When dbt_version is '%s' (not a Fusion release track such as 'latest-fusion'), force_node_selection must be set to true. "+
57+
"Set force_node_selection = true or change dbt_version to a Fusion release track.",
5758
dbtVersion.ValueString(),
5859
),
5960
)
6061
}
6162
}
6263

6364
// ForceNodeSelectionValidator returns a validator that ensures force_node_selection is true
64-
// when dbt_version is not "latest-fusion".
65+
// when dbt_version is not a Fusion release track.
6566
func ForceNodeSelectionValidator() validator.Bool {
6667
return forceNodeSelectionValidator{}
6768
}

pkg/helper/dbt_version_validator.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import (
1010

1111
type DbtVersionValidator struct{}
1212

13+
const validDbtVersionsDescription = "`major.minor.0-latest`, `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest`, `latest-fusion`, `fusion-stable`, `fusion-extended`, `fusion-nightly` or `fusion-fallback`"
14+
1315
func (v DbtVersionValidator) Description(ctx context.Context) string {
14-
return "Validates that the dbt_version is in the format `major.minor.0-latest`, `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest`, or `latest-fusion`."
16+
return "Validates that the dbt_version is in the format " + validDbtVersionsDescription + "."
1517
}
1618

1719
func (v DbtVersionValidator) MarkdownDescription(ctx context.Context) string {
18-
return "Validates that the `dbt_version` is in the format `major.minor.0-latest`, `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest` or `latest-fusion`."
20+
return "Validates that the `dbt_version` is in the format " + validDbtVersionsDescription + "."
1921
}
2022

2123
func (v DbtVersionValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
@@ -28,7 +30,7 @@ func (v DbtVersionValidator) ValidateString(ctx context.Context, req validator.S
2830
dbtVersion := req.ConfigValue.ValueString()
2931

3032
// Define the regex pattern for valid dbt_version formats
31-
validVersionPattern := `^(compatible|extended|latest|versionless|latest-fusion|[0-9]+\.[0-9]+\.0-(latest|pre))$`
33+
validVersionPattern := `^(compatible|extended|latest|versionless|latest-fusion|fusion-stable|fusion-extended|fusion-nightly|fusion-fallback|[0-9]+\.[0-9]+\.0-(latest|pre))$`
3234
matched, err := regexp.MatchString(validVersionPattern, dbtVersion)
3335
if err != nil {
3436
resp.Diagnostics.AddError(
@@ -42,7 +44,17 @@ func (v DbtVersionValidator) ValidateString(ctx context.Context, req validator.S
4244
if !matched {
4345
resp.Diagnostics.AddError(
4446
"Invalid dbt_version Format",
45-
fmt.Sprintf("The `dbt_version` must be in the format `major.minor.0-latest`, `major.minor.0-pre`, `compatible`, `extended`, `versionless`, `latest` or `latest-fusion`. Got: %s", dbtVersion),
47+
fmt.Sprintf("The `dbt_version` must be in the format "+validDbtVersionsDescription+". Got: %s", dbtVersion),
4648
)
4749
}
4850
}
51+
52+
// IsFusionVersion reports whether the supplied dbt_version string is one of
53+
// the Fusion release tracks.
54+
func IsFusionVersion(dbtVersion string) bool {
55+
switch dbtVersion {
56+
case "latest-fusion", "fusion-stable", "fusion-extended", "fusion-nightly", "fusion-fallback":
57+
return true
58+
}
59+
return false
60+
}

0 commit comments

Comments
 (0)