fix: modify only if hasServiceParamChanges (skip when git_revision only), bump TEST 5.1.16
This commit is contained in:
@@ -3,7 +3,7 @@ NUBES_API_ENDPOINT="https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
|
||||
TOKEN_FILE="secrets/test.token"
|
||||
|
||||
# Version
|
||||
VERSION="5.1.15"
|
||||
VERSION="5.1.16"
|
||||
|
||||
# Docs generation — ONLY from docs_gen/<stand>/ (never from docs/)
|
||||
DOCS_GEN_DIR="provider/docs_gen/test"
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user