Skip to content

Commit 4d27076

Browse files
authored
Support node_version on vercel_project resource + data source (#285)
Closes #252
1 parent 8e87274 commit 4d27076

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

client/project.go

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ type ProjectResponse struct {
205205
Security *Security `json:"security"`
206206
DeploymentExpiration *DeploymentExpiration `json:"deploymentExpiration"`
207207
ResourceConfig *ResourceConfig `json:"resourceConfig"`
208+
NodeVersion string `json:"nodeVersion"`
208209
}
209210

210211
type GitComments struct {
@@ -304,6 +305,7 @@ type UpdateProjectRequest struct {
304305
SkewProtectionMaxAge int `json:"skewProtectionMaxAge"`
305306
GitComments *GitComments `json:"gitComments"`
306307
ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"`
308+
NodeVersion string `json:"nodeVersion,omitempty"`
307309
}
308310

309311
// UpdateProject updates an existing projects configuration within Vercel.

docs/data-sources/project.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ data "vercel_project" "example" {
5454
- `id` (String) The ID of this resource.
5555
- `ignore_command` (String) When a commit is pushed to the Git repository that is connected with your Project, its SHA will determine if a new Build has to be issued. If the SHA was deployed before, no new Build will be issued. You can customize this behavior with a command that exits with code 1 (new Build needed) or code 0.
5656
- `install_command` (String) The install command for this project. If omitted, this value will be automatically detected.
57+
- `node_version` (String) The version of Node.js that is used in the Build Step and for Serverless Functions.
5758
- `oidc_token_config` (Attributes) Configuration for OpenID Connect (OIDC) tokens. (see [below for nested schema](#nestedatt--oidc_token_config))
5859
- `options_allowlist` (Attributes) Disable Deployment Protection for CORS preflight `OPTIONS` requests for a list of paths. (see [below for nested schema](#nestedatt--options_allowlist))
5960
- `output_directory` (String) The output directory of the project. When null is used this value will be automatically detected.

docs/resources/project.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ resource "vercel_project" "example" {
7171
- `git_repository` (Attributes) The Git Repository that will be connected to the project. When this is defined, any pushes to the specified connected Git Repository will be automatically deployed. This requires the corresponding Vercel for [Github](https://vercel.com/docs/concepts/git/vercel-for-github), [Gitlab](https://vercel.com/docs/concepts/git/vercel-for-gitlab) or [Bitbucket](https://vercel.com/docs/concepts/git/vercel-for-bitbucket) plugins to be installed. (see [below for nested schema](#nestedatt--git_repository))
7272
- `ignore_command` (String) When a commit is pushed to the Git repository that is connected with your Project, its SHA will determine if a new Build has to be issued. If the SHA was deployed before, no new Build will be issued. You can customize this behavior with a command that exits with code 1 (new Build needed) or code 0.
7373
- `install_command` (String) The install command for this project. If omitted, this value will be automatically detected.
74+
- `node_version` (String) The version of Node.js that is used in the Build Step and for Serverless Functions. A new Deployment is required for your changes to take effect.
7475
- `oidc_token_config` (Attributes) Configuration for OpenID Connect (OIDC) tokens. (see [below for nested schema](#nestedatt--oidc_token_config))
7576
- `options_allowlist` (Attributes) Disable Deployment Protection for CORS preflight `OPTIONS` requests for a list of paths. (see [below for nested schema](#nestedatt--options_allowlist))
7677
- `output_directory` (String) The output directory of the project. If omitted, this value will be automatically detected.

vercel/data_source_project.go

+6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ For more detailed information, please see the [Vercel documentation](https://ver
9494
Computed: true,
9595
Description: "The region on Vercel's network to which your Serverless Functions are deployed. It should be close to any data source your Serverless Function might depend on. A new Deployment is required for your changes to take effect. Please see [Vercel's documentation](https://vercel.com/docs/concepts/edge-network/regions) for a full list of regions.",
9696
},
97+
"node_version": schema.StringAttribute{
98+
Computed: true,
99+
Description: "The version of Node.js that is used in the Build Step and for Serverless Functions.",
100+
},
97101
"environment": schema.SetNestedAttribute{
98102
Description: "A list of environment variables that should be configured for the project.",
99103
Computed: true,
@@ -411,6 +415,7 @@ type ProjectDataSource struct {
411415
EnableAffectedProjectsDeployments types.Bool `tfsdk:"enable_affected_projects_deployments"`
412416
SkewProtection types.String `tfsdk:"skew_protection"`
413417
ResourceConfig *ResourceConfig `tfsdk:"resource_config"`
418+
NodeVersion types.String `tfsdk:"node_version"`
414419
}
415420

416421
func convertResponseToProjectDataSource(ctx context.Context, response client.ProjectResponse, plan Project, environmentVariables []client.EnvironmentVariable) (ProjectDataSource, error) {
@@ -480,6 +485,7 @@ func convertResponseToProjectDataSource(ctx context.Context, response client.Pro
480485
EnableAffectedProjectsDeployments: project.EnableAffectedProjectsDeployments,
481486
SkewProtection: project.SkewProtection,
482487
ResourceConfig: project.ResourceConfig,
488+
NodeVersion: project.NodeVersion,
483489
}, nil
484490
}
485491

vercel/resource_project.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,19 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ
118118
validateServerlessFunctionRegion(),
119119
},
120120
},
121+
"node_version": schema.StringAttribute{
122+
Optional: true,
123+
Computed: true,
124+
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
125+
Validators: []validator.String{
126+
stringvalidator.OneOf(
127+
"18.x",
128+
"20.x",
129+
"22.x",
130+
),
131+
},
132+
Description: "The version of Node.js that is used in the Build Step and for Serverless Functions. A new Deployment is required for your changes to take effect.",
133+
},
121134
"environment": schema.SetNestedAttribute{
122135
Description: "A set of Environment Variables that should be configured for the project.",
123136
Optional: true,
@@ -586,6 +599,7 @@ type Project struct {
586599
IgnoreCommand types.String `tfsdk:"ignore_command"`
587600
InstallCommand types.String `tfsdk:"install_command"`
588601
Name types.String `tfsdk:"name"`
602+
NodeVersion types.String `tfsdk:"node_version"`
589603
OutputDirectory types.String `tfsdk:"output_directory"`
590604
PublicSource types.Bool `tfsdk:"public_source"`
591605
RootDirectory types.String `tfsdk:"root_directory"`
@@ -645,7 +659,9 @@ func (p Project) RequiresUpdateAfterCreation() bool {
645659
!p.PrioritiseProductionBuilds.IsNull() ||
646660
!p.DirectoryListing.IsNull() ||
647661
!p.SkewProtection.IsNull() ||
648-
p.ResourceConfig != nil
662+
p.ResourceConfig != nil ||
663+
!p.NodeVersion.IsNull()
664+
649665
}
650666

651667
var nullProject = Project{
@@ -781,6 +797,7 @@ func (p *Project) toUpdateProjectRequest(ctx context.Context, oldName string) (r
781797
SkewProtectionMaxAge: toSkewProtectionAge(p.SkewProtection),
782798
GitComments: gc.toUpdateProjectRequest(),
783799
ResourceConfig: p.ResourceConfig.toUpdateProjectRequest(),
800+
NodeVersion: p.NodeVersion.ValueString(),
784801
}, nil
785802
}
786803

@@ -1394,6 +1411,7 @@ func convertResponseToProject(ctx context.Context, response client.ProjectRespon
13941411
SkewProtection: fromSkewProtectionMaxAge(response.SkewProtectionMaxAge),
13951412
GitComments: gitComments,
13961413
ResourceConfig: resourceConfig,
1414+
NodeVersion: types.StringValue(response.NodeVersion),
13971415
}, nil
13981416
}
13991417

0 commit comments

Comments
 (0)