fix: modify only if hasServiceParamChanges (skip when git_revision only), bump TEST 5.1.16

This commit is contained in:
“Naeel”
2026-07-20 10:30:19 +04:00
parent d05456c4f9
commit 757aa2de98
5 changed files with 29 additions and 35 deletions
@@ -547,6 +547,31 @@ func (r *{{ToCamel .Name}}Resource) Update(ctx context.Context, req resource.Upd
{{- if .HasRedeploy }}
// --- Redeploy support (ARCHITECTURE.md) ---
// 1. Modify — только если изменились параметры сервиса
if hasServiceParamChanges {
{{- end }}
params := map[int]string{
{{- range .ModifyParams }}
{{- if not (IsNested .) }}
{{.ID}}: {{ParamFormat . (printf "plan.%s" (ToCamel .Code))}},
{{- end }}
{{- end }}
}
{{- range .ModifyParams }}
{{- if (IsNested .) }}
if plan.{{ToCamel .Code}} != nil {
params[{{.ID}}] = {{NestedJSONExpr . "plan"}}
}
{{- end }}
{{- end }}
if err := resources_core.UpdateResourceWithTimeout(ctx, r.client, instanceID.ValueString(), params, operationTimeout); err != nil {
resp.Diagnostics.AddError("Ошибка клиента", err.Error())
return
}
{{- if .HasRedeploy }}
}
// 2. Redeploy — только если изменился git_revision
if redeployRequested {
redeployParams := map[int]string{}
{{- range .RedeployParams }}
@@ -558,41 +583,10 @@ func (r *{{ToCamel .Name}}Resource) Update(ctx context.Context, req resource.Upd
redeployParams[{{.ID}}] = {{ParamFormat . (printf "plan.%s" (ToCamel .Code))}}
{{- end }}
{{- end }}
// Merge modify-params into redeploy to avoid state drift
{{- range .ModifyParams }}
{{- if (IsNested .) }}
if plan.{{ToCamel .Code}} != nil {
redeployParams[{{.ID}}] = {{NestedJSONExpr . "plan"}}
}
{{- else }}
redeployParams[{{.ID}}] = {{ParamFormat . (printf "plan.%s" (ToCamel .Code))}}
{{- end }}
{{- end }}
if err := r.client.RunRedeployOperation(ctx, instanceID.ValueString(), operationTimeout, redeployParams); err != nil {
resp.Diagnostics.AddError("Ошибка клиента", err.Error())
return
}
} else {
{{- end }}
params := map[int]string{
{{- range .ModifyParams }}
{{- if not (IsNested .) }}
{{.ID}}: {{ParamFormat . (printf "plan.%s" (ToCamel .Code))}},
{{- end }}
{{- end }}
}
{{- range .ModifyParams }}
{{- if (IsNested .) }}
if plan.{{ToCamel .Code}} != nil {
params[{{.ID}}] = {{NestedJSONExpr . "plan"}}
}
{{- end }}
{{- end }}
if err := resources_core.UpdateResourceWithTimeout(ctx, r.client, instanceID.ValueString(), params, operationTimeout); err != nil {
resp.Diagnostics.AddError("Ошибка клиента", err.Error())
return
}
{{- if .HasRedeploy }}
}
{{- end }}