From 141304e638711bf0265da037de3a7af568326f18 Mon Sep 17 00:00:00 2001 From: Krzysztof Klimonda Date: Tue, 10 Dec 2024 19:06:23 +0100 Subject: [PATCH] Make sure default package for property type is imported --- pkg/properties/normalized.go | 4 ++++ pkg/translate/terraform_provider/funcs.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/pkg/properties/normalized.go b/pkg/properties/normalized.go index 5ba80f3..52172b0 100644 --- a/pkg/properties/normalized.go +++ b/pkg/properties/normalized.go @@ -291,6 +291,10 @@ func (o *SpecParam) HasEntryName() bool { return o.Items.Type == "entry" } +func (o *SpecParam) DefaultType() string { + return o.Type +} + func (o *SpecParam) ValidatorType() string { if o.Type == "" { return "object" diff --git a/pkg/translate/terraform_provider/funcs.go b/pkg/translate/terraform_provider/funcs.go index ebcdf85..dabeb01 100644 --- a/pkg/translate/terraform_provider/funcs.go +++ b/pkg/translate/terraform_provider/funcs.go @@ -1237,6 +1237,9 @@ func createSchemaAttributeForParameter(schemaTyp properties.SchemaType, manager var defaultValue *defaultCtx if schemaTyp == properties.SchemaResource && param.Default != "" { + defaultImport := fmt.Sprintf("github.com/hashicorp/terraform-plugin-framework/resource/schema/%sdefault", param.DefaultType()) + manager.AddHashicorpImport(defaultImport, "") + var value string switch param.Type { case "string":