From cacc7c6710612477f801d9c5b40f7cc75eb0b0e0 Mon Sep 17 00:00:00 2001 From: Brandon Pollack Date: Fri, 31 Jan 2025 12:44:24 +0100 Subject: [PATCH] Enable tobool in pulumi-converter-terraform, already implemented in pulumi-std --- CHANGELOG_PENDING.md | 4 +++- .../builtin_functions/pcl/diagnostics.json | 5 ----- .../programs/builtin_functions/pcl/main.pp | 20 ++++++++++++++----- pkg/convert/tf.go | 6 +++++- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index a501c67..ee5afae 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -1,5 +1,7 @@ ### Improvements +- Allow generating of tobool invocation. + ### Bug Fixes - - Require v0.6.0 of the `terraform-provider` instead of v0.5.4 because the latter is no longer available. \ No newline at end of file + - Require v0.6.0 of the `terraform-provider` instead of v0.5.4 because the latter is no longer available. diff --git a/pkg/convert/testdata/programs/builtin_functions/pcl/diagnostics.json b/pkg/convert/testdata/programs/builtin_functions/pcl/diagnostics.json index 7f0e161..2e48d92 100644 --- a/pkg/convert/testdata/programs/builtin_functions/pcl/diagnostics.json +++ b/pkg/convert/testdata/programs/builtin_functions/pcl/diagnostics.json @@ -104,11 +104,6 @@ "warning:builtin_functions/main.tf:940,11-949,16:Function not yet implemented:Function templatefile not yet implemented, see pulumi/pulumi-converter-terraform#192", "warning:builtin_functions/main.tf:955,11-75:Function not yet implemented:Function textdecodebase64 not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)", "warning:builtin_functions/main.tf:961,11-54:Function not yet implemented:Function textencodebase64 not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)", - "warning:builtin_functions/main.tf:1000,11-23:Function not yet implemented:Function tobool not yet implemented, see pulumi/pulumi-converter-terraform#65", - "warning:builtin_functions/main.tf:1003,11-25:Function not yet implemented:Function tobool not yet implemented, see pulumi/pulumi-converter-terraform#65", - "warning:builtin_functions/main.tf:1006,11-23:Function not yet implemented:Function tobool not yet implemented, see pulumi/pulumi-converter-terraform#65", - "warning:builtin_functions/main.tf:1009,11-23:Function not yet implemented:Function tobool not yet implemented, see pulumi/pulumi-converter-terraform#65", - "warning:builtin_functions/main.tf:1012,11-20:Function not yet implemented:Function tobool not yet implemented, see pulumi/pulumi-converter-terraform#65", "warning:builtin_functions/main.tf:1027,11-36:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)", "warning:builtin_functions/main.tf:1030,11-43:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)", "warning:builtin_functions/main.tf:1036,11-22:Function not yet implemented:Function tonumber not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)", diff --git a/pkg/convert/testdata/programs/builtin_functions/pcl/main.pp b/pkg/convert/testdata/programs/builtin_functions/pcl/main.pp index c65546f..9783198 100644 --- a/pkg/convert/testdata/programs/builtin_functions/pcl/main.pp +++ b/pkg/convert/testdata/programs/builtin_functions/pcl/main.pp @@ -1377,19 +1377,29 @@ # Examples for tobool output "funcTobool0" { - value = notImplemented("tobool(true)") + value = invoke("std:index:tobool", { + input = true + }).result } output "funcTobool1" { - value = notImplemented("tobool(\"true\")") + value = invoke("std:index:tobool", { + input = "true" + }).result } output "funcTobool2" { - value = notImplemented("tobool(null)") + value = invoke("std:index:tobool", { + input = null + }).result } output "funcTobool3" { - value = notImplemented("tobool(\"no\")") + value = invoke("std:index:tobool", { + input = "no" + }).result } output "funcTobool4" { - value = notImplemented("tobool(1)") + value = invoke("std:index:tobool", { + input = 1 + }).result } diff --git a/pkg/convert/tf.go b/pkg/convert/tf.go index 44a5141..ae47f1e 100644 --- a/pkg/convert/tf.go +++ b/pkg/convert/tf.go @@ -719,6 +719,11 @@ var tfFunctionStd = map[string]struct { inputs: []string{"input"}, output: "result", }, + "tobool": { + token: "std:index:tobool", + inputs: []string{"input"}, + output: "result", + }, "transpose": { token: "std:index:transpose", inputs: []string{"input"}, @@ -3581,7 +3586,6 @@ var unimplementedFunctionBugs = map[string]string{ "regexall": "pulumi/pulumi-converter-terraform#191", "slice": "pulumi/pulumi-converter-terraform#65", "templatefile": "pulumi/pulumi-converter-terraform#192", - "tobool": "pulumi/pulumi-converter-terraform#65", "toset": "pulumi/pulumi-converter-terraform#137", "try": "pulumi/pulumi-converter-terraform#16", "yamlencode": "pulumi/pulumi-converter-terraform#190",