From 99bcdcf4f24838468629903e47c7262fc962b7aa Mon Sep 17 00:00:00 2001 From: keerthanamsys <149489753+keerthanamsys@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:22:58 +0530 Subject: [PATCH] Update eval_provider.go Signed-off-by: keerthanamsys <149489753+keerthanamsys@users.noreply.github.com> --- internal/tofu/eval_provider.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/tofu/eval_provider.go b/internal/tofu/eval_provider.go index cc4185fb0a..9e016f97de 100644 --- a/internal/tofu/eval_provider.go +++ b/internal/tofu/eval_provider.go @@ -22,6 +22,20 @@ import ( "github.com/opentofu/opentofu/internal/tfdiags" ) +func EvalProviderAliasKey(value cty.Value) string { + switch { + case value.Type().Equals(cty.Bool): + return fmt.Sprintf("%t", value.True()) // Convert `true` -> "true", `false` -> "false" + case value.Type().Equals(cty.Number): + return fmt.Sprintf("%v", value.AsBigFloat()) // Convert number to string + case value.Type().Equals(cty.String): + return value.AsString() // Already a string + default: + panic(fmt.Sprintf("Invalid provider alias key type: %v", value.Type())) + } +} + + func buildProviderConfig(ctx EvalContext, addr addrs.AbsProviderConfig, config *configs.Provider) hcl.Body { var configBody hcl.Body if config != nil {