Skip to content

Commit ef3f51d

Browse files
authored
Add support for project fields (#174)
This PR adds support on the `vercel_project` resource for... ** inhales ** - Preview Comments - Git Comments - Auto-assigning custom production domains (or disabling it) - Git LFS - Automatic function failover - Customer Success Code Visibility - Git Fork Protection - Prioritising production builds - Directory listing (wtf even is this) - Skew protection There's a lot of more advanced features among this set, so I think this is a nice one to land.
1 parent 09b2325 commit ef3f51d

15 files changed

+534
-190
lines changed

client/project.go

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type CreateProjectRequest struct {
4040
OutputDirectory *string `json:"outputDirectory"`
4141
PublicSource *bool `json:"publicSource"`
4242
RootDirectory *string `json:"rootDirectory"`
43-
ServerlessFunctionRegion *string `json:"serverlessFunctionRegion,omitempty"`
43+
ServerlessFunctionRegion string `json:"serverlessFunctionRegion,omitempty"`
4444
}
4545

4646
// CreateProject will create a project within Vercel.
@@ -161,16 +161,31 @@ type ProjectResponse struct {
161161
ProductionBranch *string `json:"productionBranch"`
162162
DeployHooks []DeployHook `json:"deployHooks"`
163163
} `json:"link"`
164-
Name string `json:"name"`
165-
OutputDirectory *string `json:"outputDirectory"`
166-
PublicSource *bool `json:"publicSource"`
167-
RootDirectory *string `json:"rootDirectory"`
168-
ServerlessFunctionRegion *string `json:"serverlessFunctionRegion"`
169-
VercelAuthentication *VercelAuthentication `json:"ssoProtection"`
170-
PasswordProtection *PasswordProtection `json:"passwordProtection"`
171-
TrustedIps *TrustedIps `json:"trustedIps"`
172-
ProtectionBypass map[string]ProtectionBypass `json:"protectionBypass"`
173-
AutoExposeSystemEnvVars *bool `json:"autoExposeSystemEnvs"`
164+
Name string `json:"name"`
165+
OutputDirectory *string `json:"outputDirectory"`
166+
PublicSource *bool `json:"publicSource"`
167+
RootDirectory *string `json:"rootDirectory"`
168+
ServerlessFunctionRegion *string `json:"serverlessFunctionRegion"`
169+
VercelAuthentication *VercelAuthentication `json:"ssoProtection"`
170+
PasswordProtection *PasswordProtection `json:"passwordProtection"`
171+
TrustedIps *TrustedIps `json:"trustedIps"`
172+
ProtectionBypass map[string]ProtectionBypass `json:"protectionBypass"`
173+
AutoExposeSystemEnvVars *bool `json:"autoExposeSystemEnvs"`
174+
EnablePreviewFeedback *bool `json:"enablePreviewFeedback"`
175+
AutoAssignCustomDomains bool `json:"autoAssignCustomDomains"`
176+
GitLFS bool `json:"gitLFS"`
177+
ServerlessFunctionZeroConfigFailover bool `json:"serverlessFunctionZeroConfigFailover"`
178+
CustomerSupportCodeVisibility bool `json:"customerSupportCodeVisibility"`
179+
GitForkProtection bool `json:"gitForkProtection"`
180+
ProductionDeploymentsFastLane bool `json:"productionDeploymentsFastLane"`
181+
DirectoryListing bool `json:"directoryListing"`
182+
SkewProtectionMaxAge int `json:"skewProtectionMaxAge"`
183+
GitComments *GitComments `json:"gitComments"`
184+
}
185+
186+
type GitComments struct {
187+
OnCommit bool `json:"onCommit"`
188+
OnPullRequest bool `json:"onPullRequest"`
174189
}
175190

176191
// GetProject retrieves information about an existing project from Vercel.
@@ -228,20 +243,30 @@ func (c *Client) ListProjects(ctx context.Context, teamID string) (r []ProjectRe
228243
// - setting the field to an empty value (e.g. "") will remove the setting for that field.
229244
// - omitting the value entirely from the request will _not_ update the field.
230245
type UpdateProjectRequest struct {
231-
BuildCommand *string `json:"buildCommand"`
232-
CommandForIgnoringBuildStep *string `json:"commandForIgnoringBuildStep"`
233-
DevCommand *string `json:"devCommand"`
234-
Framework *string `json:"framework"`
235-
InstallCommand *string `json:"installCommand"`
236-
Name *string `json:"name,omitempty"`
237-
OutputDirectory *string `json:"outputDirectory"`
238-
PublicSource *bool `json:"publicSource"`
239-
RootDirectory *string `json:"rootDirectory"`
240-
ServerlessFunctionRegion *string `json:"serverlessFunctionRegion"`
241-
VercelAuthentication *VercelAuthentication `json:"ssoProtection"`
242-
PasswordProtection *PasswordProtectionWithPassword `json:"passwordProtection"`
243-
TrustedIps *TrustedIps `json:"trustedIps"`
244-
AutoExposeSystemEnvVars *bool `json:"autoExposeSystemEnvs,omitempty"`
246+
BuildCommand *string `json:"buildCommand"`
247+
CommandForIgnoringBuildStep *string `json:"commandForIgnoringBuildStep"`
248+
DevCommand *string `json:"devCommand"`
249+
Framework *string `json:"framework"`
250+
InstallCommand *string `json:"installCommand"`
251+
Name *string `json:"name,omitempty"`
252+
OutputDirectory *string `json:"outputDirectory"`
253+
PublicSource *bool `json:"publicSource"`
254+
RootDirectory *string `json:"rootDirectory"`
255+
ServerlessFunctionRegion string `json:"serverlessFunctionRegion,omitempty"`
256+
VercelAuthentication *VercelAuthentication `json:"ssoProtection"`
257+
PasswordProtection *PasswordProtectionWithPassword `json:"passwordProtection"`
258+
TrustedIps *TrustedIps `json:"trustedIps"`
259+
AutoExposeSystemEnvVars bool `json:"autoExposeSystemEnvs"`
260+
EnablePreviewFeedback *bool `json:"enablePreviewFeedback"`
261+
AutoAssignCustomDomains bool `json:"autoAssignCustomDomains"`
262+
GitLFS bool `json:"gitLFS"`
263+
ServerlessFunctionZeroConfigFailover bool `json:"serverlessFunctionZeroConfigFailover"`
264+
CustomerSupportCodeVisibility bool `json:"customerSupportCodeVisibility"`
265+
GitForkProtection bool `json:"gitForkProtection"`
266+
ProductionDeploymentsFastLane bool `json:"productionDeploymentsFastLane"`
267+
DirectoryListing bool `json:"directoryListing"`
268+
SkewProtectionMaxAge int `json:"skewProtectionMaxAge"`
269+
GitComments *GitComments `json:"gitComments"`
245270
}
246271

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

docs/data-sources/project.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,31 @@ output "project_id" {
4242

4343
### Read-Only
4444

45+
- `auto_assign_custom_domains` (Boolean) Automatically assign custom production domains after each Production deployment via merge to the production branch or Vercel CLI deploy with --prod. Defaults to `true`
4546
- `automatically_expose_system_environment_variables` (Boolean) Vercel provides a set of Environment Variables that are automatically populated by the System, such as the URL of the Deployment or the name of the Git branch deployed. To expose them to your Deployments, enable this field
4647
- `build_command` (String) The build command for this project. If omitted, this value will be automatically detected.
48+
- `customer_success_code_visibility` (Boolean) Allows Vercel Customer Support to inspect all Deployments' source code in this project to assist with debugging.
4749
- `dev_command` (String) The dev command for this project. If omitted, this value will be automatically detected.
50+
- `directory_listing` (Boolean) If no index file is present within a directory, the directory contents will be displayed.
4851
- `environment` (Attributes Set) A list of environment variables that should be configured for the project. (see [below for nested schema](#nestedatt--environment))
4952
- `framework` (String) The framework that is being used for this project. If omitted, no framework is selected.
53+
- `function_failover` (Boolean) Automatically failover Serverless Functions to the nearest region. You can customize regions through vercel.json. A new Deployment is required for your changes to take effect.
54+
- `git_comments` (Attributes) Configuration for Git Comments. (see [below for nested schema](#nestedatt--git_comments))
55+
- `git_fork_protection` (Boolean) Ensures that pull requests targeting your Git repository must be authorized by a member of your Team before deploying if your Project has Environment Variables or if the pull request includes a change to vercel.json.
56+
- `git_lfs` (Boolean) Enables Git LFS support. Git LFS replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
5057
- `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))
5158
- `id` (String) The ID of this resource.
5259
- `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.
5360
- `install_command` (String) The install command for this project. If omitted, this value will be automatically detected.
5461
- `output_directory` (String) The output directory of the project. When null is used this value will be automatically detected.
5562
- `password_protection` (Attributes) Ensures visitors of your Preview Deployments must enter a password in order to gain access. (see [below for nested schema](#nestedatt--password_protection))
63+
- `preview_comments` (Boolean) Whether comments are enabled on your Preview Deployments.
64+
- `prioritise_production_builds` (Boolean) If enabled, builds for the Production environment will be prioritized over Preview environments.
65+
- `protection_bypass_for_automation` (Boolean) Allows automation services to bypass Vercel Authentication and Password Protection for both Preview and Production Deployments on this project when using an HTTP header named `x-vercel-protection-bypass`.
5666
- `public_source` (Boolean) Specifies whether the source code and logs of the deployments for this project should be public or not.
5767
- `root_directory` (String) The name of a directory or relative path to the source code of your project. When null is used it will default to the project root.
5868
- `serverless_function_region` (String) 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.
69+
- `skew_protection` (String) Ensures that outdated clients always fetch the correct version for a given deployment. This value defines how long Vercel keeps Skew Protection active.
5970
- `trusted_ips` (Attributes) Ensures only visitors from an allowed IP address can access your deployment. (see [below for nested schema](#nestedatt--trusted_ips))
6071
- `vercel_authentication` (Attributes) Ensures visitors to your Preview Deployments are logged into Vercel and have a minimum of Viewer access on your team. (see [below for nested schema](#nestedatt--vercel_authentication))
6172

@@ -72,6 +83,15 @@ Read-Only:
7283
- `value` (String) The value of the environment variable.
7384

7485

86+
<a id="nestedatt--git_comments"></a>
87+
### Nested Schema for `git_comments`
88+
89+
Required:
90+
91+
- `on_commit` (Boolean) Whether Commit comments are enabled
92+
- `on_pull_request` (Boolean) Whether Pull Request comments are enabled
93+
94+
7595
<a id="nestedatt--git_repository"></a>
7696
### Nested Schema for `git_repository`
7797

docs/resources/project.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,30 @@ resource "vercel_project" "example" {
5555

5656
### Optional
5757

58+
- `auto_assign_custom_domains` (Boolean) Automatically assign custom production domains after each Production deployment via merge to the production branch or Vercel CLI deploy with --prod. Defaults to `true`
5859
- `automatically_expose_system_environment_variables` (Boolean) Vercel provides a set of Environment Variables that are automatically populated by the System, such as the URL of the Deployment or the name of the Git branch deployed. To expose them to your Deployments, enable this field
5960
- `build_command` (String) The build command for this project. If omitted, this value will be automatically detected.
61+
- `customer_success_code_visibility` (Boolean) Allows Vercel Customer Support to inspect all Deployments' source code in this project to assist with debugging.
6062
- `dev_command` (String) The dev command for this project. If omitted, this value will be automatically detected.
63+
- `directory_listing` (Boolean) If no index file is present within a directory, the directory contents will be displayed.
6164
- `environment` (Attributes Set) A set of Environment Variables that should be configured for the project. (see [below for nested schema](#nestedatt--environment))
6265
- `framework` (String) The framework that is being used for this project. If omitted, no framework is selected.
66+
- `function_failover` (Boolean) Automatically failover Serverless Functions to the nearest region. You can customize regions through vercel.json. A new Deployment is required for your changes to take effect.
67+
- `git_comments` (Attributes) Configuration for Git Comments. (see [below for nested schema](#nestedatt--git_comments))
68+
- `git_fork_protection` (Boolean) Ensures that pull requests targeting your Git repository must be authorized by a member of your Team before deploying if your Project has Environment Variables or if the pull request includes a change to vercel.json. Defaults to `true`.
69+
- `git_lfs` (Boolean) Enables Git LFS support. Git LFS replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
6370
- `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))
6471
- `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.
6572
- `install_command` (String) The install command for this project. If omitted, this value will be automatically detected.
6673
- `output_directory` (String) The output directory of the project. If omitted, this value will be automatically detected.
6774
- `password_protection` (Attributes) Ensures visitors of your Preview Deployments must enter a password in order to gain access. (see [below for nested schema](#nestedatt--password_protection))
75+
- `preview_comments` (Boolean) Whether to enable comments on your Preview Deployments. If omitted, comments are controlled at the team level (default behaviour).
76+
- `prioritise_production_builds` (Boolean) If enabled, builds for the Production environment will be prioritized over Preview environments.
6877
- `protection_bypass_for_automation` (Boolean) Allow automation services to bypass Vercel Authentication and Password Protection for both Preview and Production Deployments on this project when using an HTTP header named `x-vercel-protection-bypass` with a value of the `password_protection_for_automation_secret` field.
6978
- `public_source` (Boolean) By default, visitors to the `/_logs` and `/_src` paths of your Production and Preview Deployments must log in with Vercel (requires being a member of your team) to see the Source, Logs and Deployment Status of your project. Setting `public_source` to `true` disables this behaviour, meaning the Source, Logs and Deployment Status can be publicly viewed.
7079
- `root_directory` (String) The name of a directory or relative path to the source code of your project. If omitted, it will default to the project root.
7180
- `serverless_function_region` (String) 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.
81+
- `skew_protection` (String) Ensures that outdated clients always fetch the correct version for a given deployment. This value defines how long Vercel keeps Skew Protection active.
7282
- `team_id` (String) The team ID to add the project to. Required when configuring a team resource if a default team has not been set in the provider.
7383
- `trusted_ips` (Attributes) Ensures only visitors from an allowed IP address can access your deployment. (see [below for nested schema](#nestedatt--trusted_ips))
7484
- `vercel_authentication` (Attributes) Ensures visitors to your Preview Deployments are logged into Vercel and have a minimum of Viewer access on your team. (see [below for nested schema](#nestedatt--vercel_authentication))
@@ -97,6 +107,15 @@ Read-Only:
97107
- `id` (String) The ID of the Environment Variable.
98108

99109

110+
<a id="nestedatt--git_comments"></a>
111+
### Nested Schema for `git_comments`
112+
113+
Required:
114+
115+
- `on_commit` (Boolean) Whether Commit comments are enabled
116+
- `on_pull_request` (Boolean) Whether Pull Request comments are enabled
117+
118+
100119
<a id="nestedatt--git_repository"></a>
101120
### Nested Schema for `git_repository`
102121

vercel/data_source_log_drain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func responseToLogDrainWithoutSecret(ctx context.Context, out client.LogDrain) (
141141
ID: types.StringValue(out.ID),
142142
TeamID: toTeamID(out.TeamID),
143143
DeliveryFormat: types.StringValue(out.DeliveryFormat),
144-
SamplingRate: fromFloat64Pointer(out.SamplingRate),
144+
SamplingRate: types.Float64PointerValue(out.SamplingRate),
145145
Endpoint: types.StringValue(out.Endpoint),
146146
Environments: environments,
147147
Headers: headers,

0 commit comments

Comments
 (0)