fix(generator): read-back параметры без Default -> Optional+Computed (универсальное правило ShouldBeOptionalComputed)
This commit is contained in:
@@ -27,28 +27,32 @@ func WriteInstanceResource(outDir string, svc types.GenResource) error {
|
||||
filePath := filepath.Join(outDir, fileName)
|
||||
|
||||
tpl, err := template.New("resource").Funcs(template.FuncMap{
|
||||
"ToCamel": helpers.ToCamel,
|
||||
"ToSnake": helpers.ToSnake,
|
||||
"ParamType": helpers.ParamType,
|
||||
"ParamDefaultExpr": helpers.ParamDefaultExpr,
|
||||
"ParamFormat": helpers.ParamFormat,
|
||||
"ParamParse": helpers.ParamParse,
|
||||
"ParamDescription": helpers.ParamDescription,
|
||||
"OutputType": helpers.OutputParamType,
|
||||
"OutputIsMap": helpers.OutputParamIsMap,
|
||||
"OutputIsList": helpers.OutputParamIsList,
|
||||
"OutputSensitive": helpers.OutputParamSensitive,
|
||||
"IsNested": helpers.IsNested,
|
||||
"IsNestedList": helpers.IsNestedList,
|
||||
"NestedModelName": helpers.NestedModelName,
|
||||
"NestedTfType": helpers.NestedTfType,
|
||||
"NestedSchemaType": helpers.NestedSchemaType,
|
||||
"NestedSchemaBlock": helpers.NestedSchemaBlock,
|
||||
"NestedSchemaEnd": helpers.NestedSchemaEnd,
|
||||
"NestedJSONExpr": helpers.NestedJSONExpr,
|
||||
"SubSchemaType": helpers.SubSchemaType,
|
||||
"SubDefaultExpr": helpers.SubDefaultExpr,
|
||||
"bt": func() string { return "`" },
|
||||
"ToCamel": helpers.ToCamel,
|
||||
"ToSnake": helpers.ToSnake,
|
||||
"ParamType": helpers.ParamType,
|
||||
"ParamDefaultExpr": helpers.ParamDefaultExpr,
|
||||
// ShouldBeOptionalComputed — единое правило: параметр, который провайдер
|
||||
// читает обратно из state_params, обязан быть Optional+Computed, если он
|
||||
// не Required и без Default. См. подробное объяснение в helpers.go.
|
||||
"ShouldBeOptionalComputed": helpers.ShouldBeOptionalComputed,
|
||||
"ParamFormat": helpers.ParamFormat,
|
||||
"ParamParse": helpers.ParamParse,
|
||||
"ParamDescription": helpers.ParamDescription,
|
||||
"OutputType": helpers.OutputParamType,
|
||||
"OutputIsMap": helpers.OutputParamIsMap,
|
||||
"OutputIsList": helpers.OutputParamIsList,
|
||||
"OutputSensitive": helpers.OutputParamSensitive,
|
||||
"IsNested": helpers.IsNested,
|
||||
"IsNestedList": helpers.IsNestedList,
|
||||
"NestedModelName": helpers.NestedModelName,
|
||||
"NestedTfType": helpers.NestedTfType,
|
||||
"NestedSchemaType": helpers.NestedSchemaType,
|
||||
"NestedSchemaBlock": helpers.NestedSchemaBlock,
|
||||
"NestedSchemaEnd": helpers.NestedSchemaEnd,
|
||||
"NestedJSONExpr": helpers.NestedJSONExpr,
|
||||
"SubSchemaType": helpers.SubSchemaType,
|
||||
"SubDefaultExpr": helpers.SubDefaultExpr,
|
||||
"bt": func() string { return "`" },
|
||||
}).Parse(templates.Instance)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -142,13 +146,13 @@ func WriteModifierResource(outDir string, modifier types.GenModifier) error {
|
||||
filePath := filepath.Join(outDir, fileName)
|
||||
|
||||
tpl, err := template.New("modifier").Funcs(template.FuncMap{
|
||||
"ToCamel": helpers.ToCamel,
|
||||
"ToSnake": helpers.ToSnake,
|
||||
"ParamType": helpers.ParamType,
|
||||
"ParamDefaultExpr": helpers.ParamDefaultExpr,
|
||||
"ParamFormat": helpers.ParamFormat,
|
||||
"ParamDescription": helpers.ParamDescription,
|
||||
"bt": func() string { return "`" },
|
||||
"ToCamel": helpers.ToCamel,
|
||||
"ToSnake": helpers.ToSnake,
|
||||
"ParamType": helpers.ParamType,
|
||||
"ParamDefaultExpr": helpers.ParamDefaultExpr,
|
||||
"ParamFormat": helpers.ParamFormat,
|
||||
"ParamDescription": helpers.ParamDescription,
|
||||
"bt": func() string { return "`" },
|
||||
}).Parse(templates.Modifier)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user