fix: resolve s3Uid name→UUID for uuid sub-params inside map-fixed

This commit is contained in:
“Naeel”
2026-07-19 10:45:22 +04:00
parent 0a027c2ebf
commit 65b78f2a78
9 changed files with 102 additions and 22 deletions
@@ -1,9 +1,24 @@
resource "nubes_lucee" "app1" { resource "nubes_lucee" "app1" {
resource_name = "lucy_0" resource_name = "lucy_0"
resource_realm = var.realm
domain = "tflucee"
git_path = "https://github.com/xahys/testlucee" startup_configuration = {
resource_realm = var.realm
}
cluster_configuration = {
cpu = 300
memory = 512
replicas = 1
}
access_configuration = {
domain = "tflucee"
}
app_configuration = {
version = "5.4"
git_path = "https://github.com/xahys/testlucee"
}
json_env = jsonencode({ json_env = jsonencode({
# 🔗 Настройки Data Source 'testds' для Lucee (Application.cfc) # 🔗 Настройки Data Source 'testds' для Lucee (Application.cfc)
@@ -31,10 +46,5 @@ resource "nubes_lucee" "app1" {
) )
}) })
resource_c_p_u = 300
resource_memory = 512
resource_instances = 1
app_version = "5.4"
depends_on = [nubes_postgres.npg_lucee] depends_on = [nubes_postgres.npg_lucee]
} }
+6 -6
View File
@@ -2,7 +2,7 @@ terraform {
required_providers { required_providers {
nubes = { nubes = {
source = "registry.kube5s.ru/nubes-test/nubes" source = "registry.kube5s.ru/nubes-test/nubes"
version = "5.1.3" version = "5.1.7"
} }
} }
} }
@@ -12,11 +12,11 @@ variable "api_token" {
sensitive = true sensitive = true
description = "Nubes API token" description = "Nubes API token"
} }
variable "s3_uid" { # variable "s3_uid" {
type = string # type = string
sensitive = true # sensitive = true
description = "Nubes S3 UID" # description = "Nubes S3 UID"
} # }
variable "realm" { variable "realm" {
type = string type = string
sensitive = true sensitive = true
+2 -1
View File
@@ -32,7 +32,8 @@ resource "nubes_postgres" "npg_lucee" {
}]) }])
backup_configuration = { backup_configuration = {
s3_uid = var.s3_uid s3_uid = var.s3_name
# s3_uid = var.s3_uid
retain = 14 retain = 14
schedule = "0 0 * * *" schedule = "0 0 * * *"
} }
+1 -1
View File
@@ -2,7 +2,7 @@ terraform {
required_providers { required_providers {
nubes = { nubes = {
source = "registry.kube5s.ru/nubes-test/nubes" source = "registry.kube5s.ru/nubes-test/nubes"
version = "5.1.6" version = "5.1.7"
} }
} }
} }
+4
View File
@@ -126,6 +126,10 @@ Each operation has a kind:
`dataDescriptor` для `map-fixed`-параметра, а значение отсутствует или равно `"{}"`, `dataDescriptor` для `map-fixed`-параметра, а значение отсутствует или равно `"{}"`,
строится JSON из дефолтов sub-параметров (`{"type":"off","durationCA":"175200",...}`). строится JSON из дефолтов sub-параметров (`{"type":"off","durationCA":"175200",...}`).
Это гарантирует что API получит все обязательные sub-поля с их значениями по умолчанию. Это гарантирует что API получит все обязательные sub-поля с их значениями по умолчанию.
- **s3Uid-резолв в map-fixed** (`resolveRefSvcParamValues`): для map-fixed-параметров
с `DataDescriptor`, содержащих uuid sub-params с именем по паттерну `s3.*uid`,
значения-не-UUID резолвятся в UUID через S3 (сервис 12). Позволяет использовать
displayName вместо UUID для S3-ссылок во всех сервисах (Postgres, MariaDB, Clickhouse).
- **modify всегда через WithDefaults** (`RunInstanceOperationUniversalWithDefaults`): - **modify всегда через WithDefaults** (`RunInstanceOperationUniversalWithDefaults`):
modify-операции запрашивают `cfsParams` у API и отправляют все параметры, modify-операции запрашивают `cfsParams` у API и отправляют все параметры,
включая новые, с дефолтами из API. включая новые, с дефолтами из API.
+1 -1
View File
@@ -4,7 +4,7 @@ TOKEN_FILE="secrets/dev.token"
# Release versions # Release versions
# Version # Version
VERSION="3.1.5" VERSION="3.1.6"
# Registry/S3 settings # Registry/S3 settings
REGISTRY_HOST="registry.kube5s.ru" REGISTRY_HOST="registry.kube5s.ru"
+1 -1
View File
@@ -4,7 +4,7 @@ TOKEN_FILE="secrets/prod.token"
# Release versions # Release versions
# Version # Version
VERSION="2.1.4" VERSION="2.1.5"
# Registry/S3 settings # Registry/S3 settings
REGISTRY_HOST="registry.kube5s.ru" REGISTRY_HOST="registry.kube5s.ru"
+1 -1
View File
@@ -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.7" VERSION="5.1.8"
# 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"
+68 -3
View File
@@ -1195,7 +1195,6 @@ func (c *UniversalClient) resolveRefSvcParamValues(ctx context.Context, opParams
newValue := value newValue := value
if refSvcId, ok := refById[paramId]; ok { if refSvcId, ok := refById[paramId]; ok {
if strings.TrimSpace(value) == "" { if strings.TrimSpace(value) == "" {
// Опциональный ref-параметр не задан — оставляем пустым
newValue = "" newValue = ""
} else if !isUUIDLike(value) { } else if !isUUIDLike(value) {
uid, err := c.findInstanceUidByDisplayNameRefSvc(ctx, refSvcId, value) uid, err := c.findInstanceUidByDisplayNameRefSvc(ctx, refSvcId, value)
@@ -1207,10 +1206,11 @@ func (c *UniversalClient) resolveRefSvcParamValues(ctx context.Context, opParams
} }
newValue = uid newValue = uid
} else { } else {
// FIX(uuid-case): UUID-like value passed directly — normalise to lowercase.
// Аналогично refSvcId==12: нормализуем для API, регистр восстановится в state.
newValue = strings.ToLower(value) newValue = strings.ToLower(value)
} }
} else if strings.TrimSpace(value) != "" {
// map-fixed: резолвим s3Uid-подобные uuid sub-params внутри JSON.
newValue = c.resolveS3UidInMapFixed(paramId, value, opParams)
} }
resolved[paramId] = newValue resolved[paramId] = newValue
} }
@@ -1218,6 +1218,71 @@ func (c *UniversalClient) resolveRefSvcParamValues(ctx context.Context, opParams
return resolved, nil return resolved, nil
} }
// resolveS3UidInMapFixed парсит JSON map-fixed-параметра, находит uuid sub-params
// с именем по паттерну s3.*uid и резолвит значения-не-UUID в UUID через S3 (сервис 12).
func (c *UniversalClient) resolveS3UidInMapFixed(paramId int, jsonValue string, opParams []universalCfsParam) string {
// Найти DataDescriptor для этого параметра
var dd map[string]universalSubParam
for _, p := range opParams {
if p.SvcOperationCfsParamId == paramId && len(p.DataDescriptor) > 0 {
dd = p.DataDescriptor
break
}
}
if len(dd) == 0 {
return jsonValue
}
// Найти uuid sub-params с s3.*uid в имени
s3uidKeys := make(map[string]bool)
re := strings.ToLower
for key, sub := range dd {
lowKey := re(key)
lowSub := re(sub.SvcOperationCfsSubparam)
if (strings.Contains(lowKey, "s3") && strings.Contains(lowKey, "uid")) ||
(strings.Contains(lowSub, "s3") && strings.Contains(lowSub, "uid")) {
if strings.Contains(re(sub.DataType), "uuid") {
s3uidKeys[key] = true
}
}
}
if len(s3uidKeys) == 0 {
return jsonValue
}
// Парсим JSON
var obj map[string]interface{}
if err := json.Unmarshal([]byte(jsonValue), &obj); err != nil {
return jsonValue
}
changed := false
for key, val := range obj {
if !s3uidKeys[key] {
continue
}
strVal, ok := val.(string)
if !ok || strVal == "" || isUUIDLike(strVal) {
continue
}
uid, err := c.findInstanceUidByDisplayNameRefSvc(context.Background(), 12, strVal)
if err != nil || uid == "" {
continue
}
obj[key] = uid
changed = true
}
if !changed {
return jsonValue
}
b, err := json.Marshal(obj)
if err != nil {
return jsonValue
}
return string(b)
}
func (c *UniversalClient) findInstanceUidByDisplayNameRefSvc(ctx context.Context, serviceId int, displayName string) (string, error) { func (c *UniversalClient) findInstanceUidByDisplayNameRefSvc(ctx context.Context, serviceId int, displayName string) (string, error) {
// Собираем ВСЕ совпадения, затем выбираем лучшее (running > suspended > остальные). // Собираем ВСЕ совпадения, затем выбираем лучшее (running > suspended > остальные).
// Deleted инстансы пропускаются — они не должны участвовать в resolve. // Deleted инстансы пропускаются — они не должны участвовать в resolve.