Skip to content

Commit d901869

Browse files
author
Sean Roberts
committed
feat: have prevent non git deploys settable on the build resource
1 parent d7d051c commit d901869

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type siteBuildSettingsResourceModel struct {
5050
BranchDeployAllBranches types.Bool `tfsdk:"branch_deploy_all_branches"`
5151
BranchDeployBranches []types.String `tfsdk:"branch_deploy_branches"`
5252
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)