Skip to content

Commit 1afdf85

Browse files
Sean Robertsndhoule
authored andcommitted
fix: expose prevent_non_git_prod_deploys on build resource
1 parent d7d051c commit 1afdf85

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

docs/resources/site_build_settings.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ description: |-
1414

1515
```terraform
1616
resource "netlify_site_build_settings" "blog" {
17-
site_id = data.netlify_site.blog.id
18-
build_command = "npm run build"
19-
publish_directory = "dist"
20-
production_branch = "main"
21-
branch_deploy_branches = ["preview", "staging"]
17+
site_id = data.netlify_site.blog.id
18+
build_command = "npm run build"
19+
publish_directory = "dist"
20+
production_branch = "main"
21+
branch_deploy_branches = ["preview", "staging"]
22+
prevent_non_git_prod_deploys = true
2223
}
2324
```
2425

@@ -43,6 +44,7 @@ resource "netlify_site_build_settings" "blog" {
4344
- `functions_region` (String)
4445
- `package_directory` (String)
4546
- `pretty_urls` (Boolean)
47+
- `prevent_non_git_prod_deploys` (Boolean) When enabled, prevents production deploys from sources other than the linked git repository.
4648
- `stop_builds` (Boolean)
4749
- `waf_policy_id` (String) See more details in the netlify_waf_policy resource.
4850

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
resource "netlify_site_build_settings" "blog" {
2-
site_id = data.netlify_site.blog.id
3-
build_command = "npm run build"
4-
publish_directory = "dist"
5-
production_branch = "main"
6-
branch_deploy_branches = ["preview", "staging"]
2+
site_id = data.netlify_site.blog.id
3+
build_command = "npm run build"
4+
publish_directory = "dist"
5+
production_branch = "main"
6+
branch_deploy_branches = ["preview", "staging"]
7+
prevent_non_git_prod_deploys = true
78
}

internal/provider/site_build_settings_resource.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ type siteBuildSettingsResourceModel struct {
4646
StopBuilds types.Bool `tfsdk:"stop_builds"`
4747
// Runtime types.String `tfsdk:"runtime"` // ?!?! is this plugins.package?
4848

49-
ProductionBranch types.String `tfsdk:"production_branch"`
50-
BranchDeployAllBranches types.Bool `tfsdk:"branch_deploy_all_branches"`
51-
BranchDeployBranches []types.String `tfsdk:"branch_deploy_branches"`
52-
DeployPreviews types.Bool `tfsdk:"deploy_previews"`
49+
ProductionBranch types.String `tfsdk:"production_branch"`
50+
BranchDeployAllBranches types.Bool `tfsdk:"branch_deploy_all_branches"`
51+
BranchDeployBranches []types.String `tfsdk:"branch_deploy_branches"`
52+
DeployPreviews types.Bool `tfsdk:"deploy_previews"`
53+
PreventNonGitProdDeploys types.Bool `tfsdk:"prevent_non_git_prod_deploys"`
5354

5455
BuildImage types.String `tfsdk:"build_image"`
5556
// NodeJSVersion types.String `tfsdk:"node_js_version"` // versions.node.active / default: versions.node.active or versions.node.default
@@ -152,6 +153,12 @@ func (r *siteBuildSettingsResource) Schema(_ context.Context, _ resource.SchemaR
152153
Computed: true,
153154
Default: booldefault.StaticBool(true),
154155
},
156+
"prevent_non_git_prod_deploys": schema.BoolAttribute{
157+
Optional: true,
158+
Computed: true,
159+
Default: booldefault.StaticBool(false),
160+
Description: "When enabled, prevents production deploys from sources other than the linked git repository.",
161+
},
155162
"build_image": schema.StringAttribute{
156163
Optional: true,
157164
Computed: true,
@@ -288,6 +295,7 @@ func (r *siteBuildSettingsResource) read(ctx context.Context, state *siteBuildSe
288295
} else {
289296
state.DeployPreviews = types.BoolValue(!*site.BuildSettings.SkipPrs)
290297
}
298+
state.PreventNonGitProdDeploys = types.BoolPointerValue(site.PreventNonGitProdDeploys)
291299
state.BuildImage = types.StringValue(site.BuildImage)
292300
state.FunctionsRegion = types.StringPointerValue(site.FunctionsRegion)
293301
state.PrettyURLs = types.BoolPointerValue(site.ProcessingSettings.Html.PrettyUrls)
@@ -340,6 +348,7 @@ func (r *siteBuildSettingsResource) write(ctx context.Context, plan *siteBuildSe
340348
PrettyUrls: plan.PrettyURLs.ValueBoolPointer(),
341349
},
342350
},
351+
PreventNonGitProdDeploys: plan.PreventNonGitProdDeploys.ValueBoolPointer(),
343352
}
344353

345354
if plan.BuildImage.IsUnknown() {

0 commit comments

Comments
 (0)