diff --git a/TEST_STAND/POSTGRES/main.tf b/TEST_STAND/POSTGRES/main.tf index 02fd629..1271438 100644 --- a/TEST_STAND/POSTGRES/main.tf +++ b/TEST_STAND/POSTGRES/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { nubes = { source = "registry.kube5s.ru/nubes-test/nubes" - version = "5.1.5" + version = "5.1.6" } } } diff --git a/TEST_STAND/POSTGRES/nubes_postgres.tf b/TEST_STAND/POSTGRES/nubes_postgres.tf index 4e1420e..10811f8 100644 --- a/TEST_STAND/POSTGRES/nubes_postgres.tf +++ b/TEST_STAND/POSTGRES/nubes_postgres.tf @@ -1,5 +1,5 @@ resource "nubes_postgres" "npg" { - resource_name = "pgtst01" + resource_name = "pgtst02" startup_configuration = { resource_realm = var.realm @@ -46,6 +46,12 @@ resource "nubes_postgres" "npg" { operation_timeout = "11m" adopt_existing_on_create = true + + # mtls_configuration = { + # type = "off" + # duration_c_a = 175200 + # duration_server = 87600 + # } } diff --git a/TEST_STAND/POSTGRES/userUNDdb.tf b/TEST_STAND/POSTGRES/userUNDdb.tf0 similarity index 100% rename from TEST_STAND/POSTGRES/userUNDdb.tf rename to TEST_STAND/POSTGRES/userUNDdb.tf0 diff --git a/TOOLS/ARCHITECTURE.md b/TOOLS/ARCHITECTURE.md index 2354fb9..a4de1fa 100644 --- a/TOOLS/ARCHITECTURE.md +++ b/TOOLS/ARCHITECTURE.md @@ -122,6 +122,10 @@ Each operation has a kind: в пользовательском `.tf`, подставлять zero-value по `dataType`: - `integer` → `"0"`, `boolean` → `"false"`, `map-fixed` → `"{}"`, `array` → `"[]"`, `string` → `""` - Это предотвращает NullPointerException на стороне API при добавлении новых полей. +- **map-fixed default из DataDescriptor** (`buildMapFixedDefault`): если API возвращает + `dataDescriptor` для `map-fixed`-параметра, а значение отсутствует или равно `"{}"`, + строится JSON из дефолтов sub-параметров (`{"type":"off","durationCA":"175200",...}`). + Это гарантирует что API получит все обязательные sub-поля с их значениями по умолчанию. - **modify всегда через WithDefaults** (`RunInstanceOperationUniversalWithDefaults`): modify-операции запрашивают `cfsParams` у API и отправляют все параметры, включая новые, с дефолтами из API. diff --git a/TOOLS/config/dev/profile.env b/TOOLS/config/dev/profile.env index 5f3b7a0..fd367ae 100644 --- a/TOOLS/config/dev/profile.env +++ b/TOOLS/config/dev/profile.env @@ -4,7 +4,7 @@ TOKEN_FILE="secrets/dev.token" # Release versions # Version -VERSION="3.1.4" +VERSION="3.1.5" # Registry/S3 settings REGISTRY_HOST="registry.kube5s.ru" diff --git a/TOOLS/config/prod/profile.env b/TOOLS/config/prod/profile.env index ff6008e..2cbdcee 100644 --- a/TOOLS/config/prod/profile.env +++ b/TOOLS/config/prod/profile.env @@ -4,7 +4,7 @@ TOKEN_FILE="secrets/prod.token" # Release versions # Version -VERSION="2.1.3" +VERSION="2.1.4" # Registry/S3 settings REGISTRY_HOST="registry.kube5s.ru" diff --git a/TOOLS/config/test/profile.env b/TOOLS/config/test/profile.env index f96b5b5..7239311 100644 --- a/TOOLS/config/test/profile.env +++ b/TOOLS/config/test/profile.env @@ -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.6" +VERSION="5.1.7" # Docs generation — ONLY from docs_gen// (never from docs/) DOCS_GEN_DIR="provider/docs_gen/test" diff --git a/provider/internal/core/client.go b/provider/internal/core/client.go index e8f3293..40eb7ad 100644 --- a/provider/internal/core/client.go +++ b/provider/internal/core/client.go @@ -162,17 +162,25 @@ type universalOperation struct { CfsParams []universalCfsParam `json:"cfsParams"` } +type universalSubParam struct { + DefaultValue string `json:"defaultValue"` + DataType string `json:"dataType"` + SvcOperationCfsSubparam string `json:"svcOperationCfsSubparam"` + IsRequired bool `json:"isRequired"` +} + type universalCfsParam struct { - SvcOperationCfsParamId int `json:"svcOperationCfsParamId"` - ParamValue *string `json:"paramValue"` - DefaultValue *string `json:"defaultValue"` - IsRequired bool `json:"isRequired"` - DataType string `json:"dataType"` - Name string `json:"name"` - Code string `json:"code"` - Label string `json:"label"` - SvcOperationCfsParam string `json:"svcOperationCfsParam"` - RefSvcId *int `json:"refSvcId"` + SvcOperationCfsParamId int `json:"svcOperationCfsParamId"` + ParamValue *string `json:"paramValue"` + DefaultValue *string `json:"defaultValue"` + IsRequired bool `json:"isRequired"` + DataType string `json:"dataType"` + Name string `json:"name"` + Code string `json:"code"` + Label string `json:"label"` + SvcOperationCfsParam string `json:"svcOperationCfsParam"` + RefSvcId *int `json:"refSvcId"` + DataDescriptor map[string]universalSubParam `json:"dataDescriptor"` } // CreateGenericInstanceUniversalV6 implements the universal flow: @@ -311,6 +319,19 @@ func (c *UniversalClient) CreateGenericInstanceUniversalV6(ctx context.Context, return instanceUid, nil } +// buildMapFixedDefault строит JSON-объект из дефолтов sub-параметров map-fixed. +func buildMapFixedDefault(param universalCfsParam) string { + result := make(map[string]string, len(param.DataDescriptor)) + for key, sub := range param.DataDescriptor { + result[key] = sub.DefaultValue + } + b, err := json.Marshal(result) + if err != nil { + return "{}" + } + return string(b) +} + func normalizeUniversalValueV6(val string, param universalCfsParam) string { trimmed := strings.TrimSpace(val) if strings.EqualFold(trimmed, "null") { @@ -319,11 +340,20 @@ func normalizeUniversalValueV6(val string, param universalCfsParam) string { if trimmed == "\"\"" { trimmed = "" } + + // map-fixed с DataDescriptor: если значение пустое или "{}" — строим JSON из дефолтов sub-params. + dataType := strings.ToLower(param.DataType) + if (dataType == "map-fixed" || strings.HasPrefix(dataType, "map")) && len(param.DataDescriptor) > 0 { + if trimmed == "" || trimmed == "{}" { + return buildMapFixedDefault(param) + } + return trimmed + } + if trimmed != "" { return trimmed } - dataType := strings.ToLower(param.DataType) nameHint := strings.ToLower(param.Name + " " + param.Code + " " + param.Label + " " + param.SvcOperationCfsParam) if strings.Contains(dataType, "array") || strings.Contains(nameHint, "array") || strings.Contains(nameHint, "list") {