这是indexloc提供的服务,不要输入任何密码
Skip to content

Add support for previewDeploymentsDisabled in project #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type CreateProjectRequest struct {
ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"`
EnablePreviewFeedback *bool `json:"enablePreviewFeedback,omitempty"`
EnableProductionFeedback *bool `json:"enableProductionFeedback,omitempty"`
PreviewDeploymentsDisabled *bool `json:"previewDeploymentsDisabled,omitempty"`
}

// CreateProject will create a project within Vercel.
Expand Down Expand Up @@ -327,6 +328,7 @@ type UpdateProjectRequest struct {
GitComments *GitComments `json:"gitComments"`
ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"`
NodeVersion string `json:"nodeVersion,omitempty"`
PreviewDeploymentsDisabled *bool `json:"previewDeploymentsDisabled,omitempty"`
}

// UpdateProject updates an existing projects configuration within Vercel.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ data "vercel_project" "example" {
- `build_machine_type` (String) The build machine type to use for this project.
- `on_demand_concurrent_builds` (Boolean) Instantly scale build capacity to skip the queue, even if all build slots are in use. You can also choose a larger build machine; charges apply per minute if it exceeds your team's default.
- `team_id` (String) The team ID the project exists beneath. Required when configuring a team resource if a default team has not been set in the provider.
- `preview_deployments_disabled` (Boolean) Specifies whether preview deployments are disabled for this project.

### Read-Only

Expand Down
1 change: 1 addition & 0 deletions docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ resource "vercel_project" "example" {
- `output_directory` (String) The output directory of the project. If omitted, this value will be automatically detected.
- `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))
- `preview_comments` (Boolean, Deprecated) Enables the Vercel Toolbar on your preview deployments.
- `preview_deployments_disabled` (Boolean) Specifies whether preview deployments are disabled for this project.
- `prioritise_production_builds` (Boolean) If enabled, builds for the Production environment will be prioritized over Preview environments.
- `protection_bypass_for_automation` (Boolean) Allow automation services to bypass Deployment Protection on this project when using an HTTP header named `x-vercel-protection-bypass` with a value of the `protection_bypass_for_automation_secret` field.
- `protection_bypass_for_automation_secret` (String, Sensitive) If `protection_bypass_for_automation` is enabled, optionally set this value to specify a 32 character secret, otherwise a secret will be generated.
Expand Down
7 changes: 7 additions & 0 deletions vercel/data_source_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@ For more detailed information, please see the [Vercel documentation](https://ver
Optional: true,
Computed: true,
},
"preview_deployments_disabled": schema.BoolAttribute{
Description: "Specifies whether preview deployments are disabled for this project.",
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -444,6 +449,7 @@ type ProjectDataSource struct {
NodeVersion types.String `tfsdk:"node_version"`
OnDemandConcurrentBuilds types.Bool `tfsdk:"on_demand_concurrent_builds"`
BuildMachineTYpe types.String `tfsdk:"build_machine_type"`
PreviewDeploymentsDisabled types.Bool `tfsdk:"preview_deployments_disabled"`
}

func convertResponseToProjectDataSource(ctx context.Context, response client.ProjectResponse, plan Project, environmentVariables []client.EnvironmentVariable) (ProjectDataSource, error) {
Expand Down Expand Up @@ -511,6 +517,7 @@ func convertResponseToProjectDataSource(ctx context.Context, response client.Pro
NodeVersion: project.NodeVersion,
OnDemandConcurrentBuilds: project.OnDemandConcurrentBuilds,
BuildMachineTYpe: project.BuildMachineType,
PreviewDeploymentsDisabled: project.PreviewDeploymentsDisabled,
}, nil
}

Expand Down
9 changes: 9 additions & 0 deletions vercel/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,12 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ
stringvalidator.OneOf("enhanced", "turbo"),
},
},
"preview_deployments_disabled": schema.BoolAttribute{
Description: "Specifies whether preview deployments are disabled for this project.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.Bool{boolplanmodifier.UseStateForUnknown()},
},
},
}
}
Expand Down Expand Up @@ -644,6 +650,7 @@ type Project struct {
ResourceConfig types.Object `tfsdk:"resource_config"`
OnDemandConcurrentBuilds types.Bool `tfsdk:"on_demand_concurrent_builds"`
BuildMachineType types.String `tfsdk:"build_machine_type"`
PreviewDeploymentsDisabled types.Bool `tfsdk:"preview_deployments_disabled"`
}

type GitComments struct {
Expand Down Expand Up @@ -766,6 +773,7 @@ func (p *Project) toCreateProjectRequest(ctx context.Context, envs []Environment
ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds, p.BuildMachineType),
EnablePreviewFeedback: oneBoolPointer(p.EnablePreviewFeedback, p.PreviewComments),
EnableProductionFeedback: p.EnableProductionFeedback.ValueBoolPointer(),
PreviewDeploymentsDisabled: p.PreviewDeploymentsDisabled.ValueBoolPointer(),
}, diags
}

Expand Down Expand Up @@ -846,6 +854,7 @@ func (p *Project) toUpdateProjectRequest(ctx context.Context, oldName string) (r
GitComments: gc.toUpdateProjectRequest(),
ResourceConfig: resourceConfig.toClientResourceConfig(p.OnDemandConcurrentBuilds, p.BuildMachineType),
NodeVersion: p.NodeVersion.ValueString(),
PreviewDeploymentsDisabled: p.PreviewDeploymentsDisabled.ValueBoolPointer(),
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions vercel/resource_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func TestAcc_Project(t *testing.T) {
resource.TestCheckResourceAttr("vercel_project.test", "resource_config.function_default_timeout", "60"),
resource.TestCheckResourceAttr("vercel_project.test", "on_demand_concurrent_builds", "true"),
resource.TestCheckResourceAttr("vercel_project.test", "build_machine_type", "enhanced"),
resource.TestCheckResourceAttr("vercel_project.test", "preview_deployments_disabled", "false"),
),
},
// Update testing
Expand All @@ -102,6 +103,7 @@ func TestAcc_Project(t *testing.T) {
resource.TestCheckResourceAttr("vercel_project.test", "enable_production_feedback", "true"),
resource.TestCheckResourceAttr("vercel_project.test", "on_demand_concurrent_builds", "false"),
resource.TestCheckResourceAttr("vercel_project.test", "build_machine_type", ""),
resource.TestCheckResourceAttr("vercel_project.test", "preview_deployments_disabled", "true"),
),
},
// Test mutual exclusivity validation
Expand Down Expand Up @@ -650,6 +652,7 @@ resource "vercel_project" "test" {
on_demand_concurrent_builds = false
enable_preview_feedback = false
enable_production_feedback = true
preview_deployments_disabled = true
}
`, projectSuffix)
}
Expand Down Expand Up @@ -1019,6 +1022,7 @@ resource "vercel_project" "test" {
customer_success_code_visibility = true
git_fork_protection = true
prioritise_production_builds = true
preview_deployments_disabled = false
directory_listing = true
skew_protection = "7 days"
oidc_token_config = {
Expand Down
Loading