From 261809ba99265555dd5f9190040964cd87b7ba06 Mon Sep 17 00:00:00 2001 From: Repinoid Date: Tue, 22 Sep 2026 19:21:42 +0300 Subject: [PATCH] =?UTF-8?q?fix(generator):=20is=5Fmodifiable=3Dtrue=20?= =?UTF-8?q?=E2=86=92=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=20?= =?UTF-8?q?=D0=9D=D0=95=20create-only=20(=D0=BA=D0=B0=D0=BD=D0=BE=D0=BD:?= =?UTF-8?q?=20=D0=BC=D0=B5=D0=BD=D1=8F=D0=B5=D1=82=D1=81=D1=8F=20=D0=B2=20?= =?UTF-8?q?UI=20=E2=86=92=20=D0=BC=D0=B5=D0=BD=D1=8F=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=B2=20Terraform)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TOOLS/resource-generator/internal/loader/loader.go | 1 + TOOLS/resource-generator/internal/params/params.go | 6 ++++++ TOOLS/resource-generator/internal/types/types.go | 3 +++ 3 files changed, 10 insertions(+) diff --git a/TOOLS/resource-generator/internal/loader/loader.go b/TOOLS/resource-generator/internal/loader/loader.go index e298621..7cb9b17 100644 --- a/TOOLS/resource-generator/internal/loader/loader.go +++ b/TOOLS/resource-generator/internal/loader/loader.go @@ -290,6 +290,7 @@ func ConvertParams(params []types.ParamSpec) []types.Param { IsJson: strings.EqualFold(strings.TrimSpace(p.DataType), "json"), HasSubParams: isNested, SubParams: subParams, + IsModifiable: p.IsModifiable, }) } return out diff --git a/TOOLS/resource-generator/internal/params/params.go b/TOOLS/resource-generator/internal/params/params.go index 46abd93..acce2cb 100644 --- a/TOOLS/resource-generator/internal/params/params.go +++ b/TOOLS/resource-generator/internal/params/params.go @@ -111,6 +111,8 @@ func AlignParamTypes(params []types.Param, schema []types.Param) []types.Param { } // ComputeCreateOnly вычисляет набор полей, которые есть только в create (не в modify). +// Канон: параметр изменяемый (is_modifiable == true) → НЕ create-only, +// потому что «можно менять в UI → можно менять в Terraform». func ComputeCreateOnly(createParams []types.Param, modifyParams []types.Param) map[string]struct{} { modifyCodes := make(map[string]struct{}, len(modifyParams)) for _, p := range modifyParams { @@ -127,6 +129,10 @@ func ComputeCreateOnly(createParams []types.Param, modifyParams []types.Param) m if key == "" { continue } + // is_modifiable:true → параметр можно менять → не create-only. + if p.IsModifiable != nil && *p.IsModifiable { + continue + } if _, ok := modifyCodes[key]; !ok { createOnly[key] = struct{}{} } diff --git a/TOOLS/resource-generator/internal/types/types.go b/TOOLS/resource-generator/internal/types/types.go index 2041df3..b422abc 100644 --- a/TOOLS/resource-generator/internal/types/types.go +++ b/TOOLS/resource-generator/internal/types/types.go @@ -49,6 +49,9 @@ type Param struct { Sensitive bool CreateOnly bool ForceNew bool + // IsModifiable — флаг is_modifiable из API (можно менять в UI → можно менять в Terraform). + // nil означает «не указано» (как правило, изменяемо). + IsModifiable *bool // IsJson — атрибут является JSON-строкой (data_type: json в YAML-спеке). // При IsJson=true в схему добавляется JsonNormalize план-модификатор, // чтобы план и API-ответ (компактный JSON) всегда совпадали.