fix: redeploy now sends CFS params from YAML (RunRedeployOperation + template + loader)
This commit is contained in:
@@ -27,6 +27,8 @@ resource "nubes_lucee" "applucee" {
|
|||||||
git_path = "https://gitea.services.ngcloud.ru/Nail/tfluceecrud.git"
|
git_path = "https://gitea.services.ngcloud.ru/Nail/tfluceecrud.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
git_revision = "94ebf06"
|
||||||
|
|
||||||
json_env = jsonencode({
|
json_env = jsonencode({
|
||||||
TABLE_NAME = "check_point"
|
TABLE_NAME = "check_point"
|
||||||
testds_class = "org.postgresql.Driver"
|
testds_class = "org.postgresql.Driver"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ TOKEN_FILE="secrets/dev.token"
|
|||||||
|
|
||||||
# Release versions
|
# Release versions
|
||||||
# Version
|
# Version
|
||||||
VERSION="3.1.10"
|
VERSION="3.1.11"
|
||||||
|
|
||||||
# Registry/S3 settings
|
# Registry/S3 settings
|
||||||
REGISTRY_HOST="registry.kube5s.ru"
|
REGISTRY_HOST="registry.kube5s.ru"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ TOKEN_FILE="secrets/prod.token"
|
|||||||
|
|
||||||
# Release versions
|
# Release versions
|
||||||
# Version
|
# Version
|
||||||
VERSION="2.1.9"
|
VERSION="2.1.10"
|
||||||
|
|
||||||
# Registry/S3 settings
|
# Registry/S3 settings
|
||||||
REGISTRY_HOST="registry.kube5s.ru"
|
REGISTRY_HOST="registry.kube5s.ru"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ NUBES_API_ENDPOINT="https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
|
|||||||
TOKEN_FILE="secrets/test.token"
|
TOKEN_FILE="secrets/test.token"
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
VERSION="5.1.12"
|
VERSION="5.1.13"
|
||||||
|
|
||||||
# Docs generation — ONLY from docs_gen/<stand>/ (never from docs/)
|
# Docs generation — ONLY from docs_gen/<stand>/ (never from docs/)
|
||||||
DOCS_GEN_DIR="provider/docs_gen/test"
|
DOCS_GEN_DIR="provider/docs_gen/test"
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ func LoadSpecs(dir string) ([]types.GenResource, []types.GenSubresource, []types
|
|||||||
switch op.Action {
|
switch op.Action {
|
||||||
case "redeploy":
|
case "redeploy":
|
||||||
gr.HasRedeploy = true
|
gr.HasRedeploy = true
|
||||||
|
gr.RedeployParams = ConvertParams(op.Params)
|
||||||
case "restart", "recovery", "reconcile":
|
case "restart", "recovery", "reconcile":
|
||||||
// Исключены
|
// Исключены
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -548,8 +548,20 @@ func (r *{{ToCamel .Name}}Resource) Update(ctx context.Context, req resource.Upd
|
|||||||
{{- if .HasRedeploy }}
|
{{- if .HasRedeploy }}
|
||||||
// --- Redeploy support (ARCHITECTURE.md) ---
|
// --- Redeploy support (ARCHITECTURE.md) ---
|
||||||
if redeployRequested {
|
if redeployRequested {
|
||||||
// Вызываем redeploy — пустой params (операция не требует CFS-параметров)
|
{{- if .RedeployParams }}
|
||||||
if err := r.client.RunRedeployOperation(ctx, instanceID.ValueString(), operationTimeout); err != nil {
|
redeployParams := map[int]string{
|
||||||
|
{{- range .RedeployParams }}
|
||||||
|
{{- if (IsNested .) }}
|
||||||
|
if plan.{{ToCamel .Code}} != nil {
|
||||||
|
redeployParams[{{.ID}}] = {{NestedJSONExpr . "plan"}}
|
||||||
|
}
|
||||||
|
{{- else }}
|
||||||
|
{{.ID}}: {{ParamFormat . (printf "plan.%s" (ToCamel .Code))}},
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
if err := r.client.RunRedeployOperation(ctx, instanceID.ValueString(), operationTimeout{{if .RedeployParams}}, redeployParams{{end}}); err != nil {
|
||||||
resp.Diagnostics.AddError("Ошибка клиента", err.Error())
|
resp.Diagnostics.AddError("Ошибка клиента", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ type GenResource struct {
|
|||||||
// Правило из ARCHITECTURE.md: только redeploy включается как inline action.
|
// Правило из ARCHITECTURE.md: только redeploy включается как inline action.
|
||||||
// restart, recovery, reconcile — исключены (ручные операции, только UI).
|
// restart, recovery, reconcile — исключены (ручные операции, только UI).
|
||||||
HasRedeploy bool
|
HasRedeploy bool
|
||||||
|
// RedeployParams — параметры redeploy-операции (если есть).
|
||||||
|
RedeployParams []Param
|
||||||
// NeedsJsonPlanMod: хотя бы один атрибут имеет data_type: json.
|
// NeedsJsonPlanMod: хотя бы один атрибут имеет data_type: json.
|
||||||
// Управляет добавлением импорта planmodifier в сгенерированный файл.
|
// Управляет добавлением импорта planmodifier в сгенерированный файл.
|
||||||
NeedsJsonPlanMod bool
|
NeedsJsonPlanMod bool
|
||||||
|
|||||||
@@ -534,9 +534,8 @@ func (c *UniversalClient) RunInstanceOperationUniversalWithDefaults(ctx context.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RunRedeployOperation запускает redeploy для сервисов, поддерживающих пересборку из git.
|
// RunRedeployOperation запускает redeploy для сервисов, поддерживающих пересборку из git.
|
||||||
// В отличие от modify, redeploy не требует CFS-параметров — операция запускается без них.
|
// Если params не nil — отправляет CFS-параметры перед запуском.
|
||||||
// Используется генератором (gen_v2) согласно ARCHITECTURE.md.
|
func (c *UniversalClient) RunRedeployOperation(ctx context.Context, instanceUid string, timeoutOverride string, params map[int]string) error {
|
||||||
func (c *UniversalClient) RunRedeployOperation(ctx context.Context, instanceUid string, timeoutOverride string) error {
|
|
||||||
state, err := c.GetInstanceState(ctx, instanceUid)
|
state, err := c.GetInstanceState(ctx, instanceUid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -571,6 +570,17 @@ func (c *UniversalClient) RunRedeployOperation(ctx context.Context, instanceUid
|
|||||||
return fmt.Errorf("не удалось получить UID операции redeploy")
|
return fmt.Errorf("не удалось получить UID операции redeploy")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for paramId, value := range params {
|
||||||
|
pPayload := genericParamReq{
|
||||||
|
InstanceOperationUid: opUid,
|
||||||
|
SvcOperationCfsParamId: paramId,
|
||||||
|
ParamValue: value,
|
||||||
|
}
|
||||||
|
if _, _, err := c.doRequest(ctx, "POST", "/instanceOperationCfsParams", pPayload); err != nil {
|
||||||
|
return fmt.Errorf("не удалось установить параметр %d для redeploy: %w", paramId, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if _, _, err := c.doRequest(ctx, "POST", fmt.Sprintf("/instanceOperations/%s/run", opUid), map[string]interface{}{}); err != nil {
|
if _, _, err := c.doRequest(ctx, "POST", fmt.Sprintf("/instanceOperations/%s/run", opUid), map[string]interface{}{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user