Skip to content

Commit fa38215

Browse files
authored
Re-enable Fluid + compute tier validator (#382)
Turns out this was just an issue with Unknown
1 parent cc9251c commit fa38215

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

vercel/resource_project.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import (
3131
)
3232

3333
var (
34-
_ resource.Resource = &projectResource{}
35-
_ resource.ResourceWithConfigure = &projectResource{}
36-
_ resource.ResourceWithImportState = &projectResource{}
37-
_ resource.ResourceWithModifyPlan = &projectResource{}
38-
// _ resource.ResourceWithConfigValidators = &projectResource{}
34+
_ resource.Resource = &projectResource{}
35+
_ resource.ResourceWithConfigure = &projectResource{}
36+
_ resource.ResourceWithImportState = &projectResource{}
37+
_ resource.ResourceWithModifyPlan = &projectResource{}
38+
_ resource.ResourceWithConfigValidators = &projectResource{}
3939
)
4040

4141
func newProjectResource() resource.Resource {
@@ -615,13 +615,11 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ
615615
}
616616
}
617617

618-
/*
619618
func (r *projectResource) ConfigValidators(ctx context.Context) []resource.ConfigValidator {
620619
return []resource.ConfigValidator{
621620
&fluidComputeBasicCPUValidator{},
622621
}
623622
}
624-
*/
625623

626624
// Project reflects the state terraform stores internally for a project.
627625
type Project struct {

vercel/resource_project_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func TestAcc_ProjectFluidCompute(t *testing.T) {
152152
}
153153
}
154154
`, projectSuffix)),
155-
ExpectError: regexp.MustCompile(strings.ReplaceAll("\"standard_legacy\" is not a valid memory type for Fluid compute", " ", `\s*`)),
155+
ExpectError: regexp.MustCompile(strings.ReplaceAll("Fluid compute is only supported with the standard or performance CPU types", " ", `\s*`)),
156156
},
157157
{
158158
// check creating a project with Fluid

vercel/resource_project_validators.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ func (v *fluidComputeBasicCPUValidator) ValidateResource(ctx context.Context, re
2525
if resp.Diagnostics.HasError() {
2626
return
2727
}
28+
29+
// If ResourceConfig is unknown (computed), skip validation
30+
// since we can't determine the configuration's validity during planning.
31+
if project.ResourceConfig.IsUnknown() || project.ResourceConfig.IsNull() {
32+
return
33+
}
34+
2835
resourceConfig, diags := project.resourceConfig(ctx)
2936
if diags.HasError() {
3037
resp.Diagnostics.Append(diags...)
@@ -33,6 +40,14 @@ func (v *fluidComputeBasicCPUValidator) ValidateResource(ctx context.Context, re
3340
if resourceConfig == nil {
3441
return
3542
}
43+
44+
// Note: Due to UnhandledUnknownAsEmpty: true in resourceConfig(),
45+
// unknown values are converted to zero values (false, "").
46+
// We can't distinguish between explicitly set zero values and unknown values here.
47+
// This is acceptable because:
48+
// 1. If values are truly unknown, they'll be validated at apply time by the API
49+
// 2. If values are explicitly set to zero values, validation should proceed
50+
3651
if !resourceConfig.Fluid.ValueBool() {
3752
return
3853
}

0 commit comments

Comments
 (0)