From c6715e81be6cd429fb70ed964210ca3b2cb959be Mon Sep 17 00:00:00 2001 From: Repinoid Date: Mon, 21 Sep 2026 20:26:41 +0300 Subject: [PATCH] =?UTF-8?q?fix(generator):=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=B2=D0=B0=D1=82=D1=8C=20supportsSuspend=20=D0=B2?= =?UTF-8?q?=20diagnostics;=20=D0=BD=D0=B5=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20suspend=5Fon=5Fdes?= =?UTF-8?q?troy=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=20=D0=B1=D0=B5=D0=B7=20suspend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TOOLS/resource-generator/internal/templates/instance.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TOOLS/resource-generator/internal/templates/instance.go b/TOOLS/resource-generator/internal/templates/instance.go index 3be19d4..7e2c617 100644 --- a/TOOLS/resource-generator/internal/templates/instance.go +++ b/TOOLS/resource-generator/internal/templates/instance.go @@ -70,7 +70,9 @@ type {{ToCamel .Name}}Model struct { {{ToCamel .Code}} {{ParamType .}} ` + "`" + `tfsdk:"{{ToSnake .Code}}"` + "`" + ` {{- end }} {{- end }} + {{- if .SupportsSuspendDestroy }} SuspendOnDestroy types.Bool ` + "`" + `tfsdk:"suspend_on_destroy"` + "`" + ` + {{- end }} AdoptExistingOnCreate types.Bool ` + "`" + `tfsdk:"adopt_existing_on_create"` + "`" + ` {{- range .OutputParams }} {{ToCamel .Code}} {{OutputType .}} ` + "`" + `tfsdk:"{{ToSnake .Code}}"` + "`" + ` @@ -117,7 +119,9 @@ func (r *{{ToCamel .Name}}Resource) Schema(ctx context.Context, req resource.Sch // Если не задано — modify работает без изменений. "git_revision": schema.StringAttribute{Optional: true, MarkdownDescription: "Git revision (commit hash/tag). Changing this triggers redeploy instead of modify."}, {{- end }} + {{- if .SupportsSuspendDestroy }} "suspend_on_destroy": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool({{.SuspendOnDestroy}})}, + {{- end }} "adopt_existing_on_create": schema.BoolAttribute{Optional: true, Computed: true, Default: booldefault.StaticBool({{.AdoptExistingOnCreate}})}, {{- range .OutputParams }} {{- if or (OutputIsMap .) (OutputIsList .) }} @@ -264,7 +268,7 @@ func (r *{{ToCamel .Name}}Resource) ModifyPlan(ctx context.Context, req resource {{- end }} domainServiceIDs := []int{ {{- range .DomainServiceIDs }}{{.}}, {{- end }} } - resp.Diagnostics.Append(resources_core.PlanExistingResourceDiagnosticsWithParamsAndDomainAndServices(ctx, r.client, {{.ServiceID}}, config.ResourceName.ValueString(), adoptExistingOnCreate, params, desiredDomain, domainServiceIDs)...) + resp.Diagnostics.Append(resources_core.PlanExistingResourceDiagnosticsWithParamsAndDomainAndServices(ctx, r.client, {{.ServiceID}}, config.ResourceName.ValueString(), adoptExistingOnCreate, params, desiredDomain, domainServiceIDs, {{.SupportsSuspendDestroy}})...) } func (r *{{ToCamel .Name}}Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { @@ -307,7 +311,7 @@ func (r *{{ToCamel .Name}}Resource) Create(ctx context.Context, req resource.Cre } {{- end }} domainServiceIDs := []int{ {{- range .DomainServiceIDs }}{{.}}, {{- end }} } - resp.Diagnostics.Append(resources_core.CreateExistingResourceDiagnosticsWithDomainAndServices(ctx, r.client, {{.ServiceID}}, resourceName, data.AdoptExistingOnCreate.ValueBool(), desiredDomain, domainServiceIDs)...) + resp.Diagnostics.Append(resources_core.CreateExistingResourceDiagnosticsWithDomainAndServices(ctx, r.client, {{.ServiceID}}, resourceName, data.AdoptExistingOnCreate.ValueBool(), desiredDomain, domainServiceIDs, {{.SupportsSuspendDestroy}})...) // ⛔ Проверяем HasError ДО create — при hard-error (running без adopt, suspend без adopt, // not created, конфликт) сайд-эффект create не должен выполняться. if resp.Diagnostics.HasError() {