Skip to content

Commit

Permalink
Enable lookup, it is part of pulumi-std.
Browse files Browse the repository at this point in the history
Related #65
Fixes #pulumi/pulumi#18416
  • Loading branch information
brandonpollack23 committed Feb 3, 2025
1 parent 6c80206 commit 92270eb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Allow generating of tobool invocation.
- Enable jsondecode which is already in pulumi-std
- Enable lookup which is already in pulumi-std

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"warning:builtin_functions/main.tf:460,11-88:Function not yet implemented:Function formatlist not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:builtin_functions/main.tf:472,11-38:Function not yet implemented:Function index not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:builtin_functions/main.tf:505,11-32:Function not yet implemented:Function keys not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:builtin_functions/main.tf:553,11-50:Function not yet implemented:Function lookup not yet implemented, see pulumi/pulumi-converter-terraform#65",
"warning:builtin_functions/main.tf:556,11-50:Function not yet implemented:Function lookup not yet implemented, see pulumi/pulumi-converter-terraform#65",
"warning:builtin_functions/main.tf:571,11-34:Function not yet implemented:Function map not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:builtin_functions/main.tf:577,11-97:Function not yet implemented:Function matchkeys not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:builtin_functions/main.tf:607,11-48:Function not yet implemented:Function merge not yet implemented, see pulumi/pulumi-converter-terraform#65",
Expand Down
18 changes: 16 additions & 2 deletions pkg/convert/testdata/programs/builtin_functions/pcl/main.pp
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,24 @@

# Examples for lookup
output "funcLookup0" {
value = notImplemented("lookup({a=\"ay\",b=\"bee\"},\"a\",\"what?\")")
value = invoke("std:index:lookup", {
map = {
a = "ay"
b = "bee"
}
key = "a"
default = "what?"
}).result
}
output "funcLookup1" {
value = notImplemented("lookup({a=\"ay\",b=\"bee\"},\"c\",\"what?\")")
value = invoke("std:index:lookup", {
map = {
a = "ay"
b = "bee"
}
key = "c"
default = "what?"
}).result
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"warning:/files.tf:20,32-63:Function not yet implemented:Function keys not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:20,23-89:Function not yet implemented:Function setunion not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:23,45-73:Function not yet implemented:Function regexall not yet implemented, see pulumi/pulumi-converter-terraform#191",
"warning:/files.tf:29,45-114:Function not yet implemented:Function lookup not yet implemented, see pulumi/pulumi-converter-terraform#65",
"warning:/files.tf:34,16-47:Function not yet implemented:Function keys not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:36,24-38:Function not yet implemented:Function tostring not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:38,19-45,11:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
Expand All @@ -20,7 +19,6 @@
"warning:/files.tf:20,32-63:Function not yet implemented:Function keys not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:20,23-89:Function not yet implemented:Function setunion not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:23,45-73:Function not yet implemented:Function regexall not yet implemented, see pulumi/pulumi-converter-terraform#191",
"warning:/files.tf:29,45-114:Function not yet implemented:Function lookup not yet implemented, see pulumi/pulumi-converter-terraform#65",
"warning:/files.tf:34,16-47:Function not yet implemented:Function keys not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:36,24-38:Function not yet implemented:Function tostring not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:38,19-45,11:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
outputFilePaths = notImplemented("setunion(keys(local.template_file_paths),local.static_file_paths)")
fileSuffixMatches = { for p in outputFilePaths : p => notImplemented("regexall(\"\\\\.[^\\\\.]+\\\\z\",p)") }
fileSuffixes = { for p, ms in fileSuffixMatches : p => length(ms) > 0 ? ms[0] : "" }
myFileTypes = { for p in outputFilePaths : p => notImplemented("lookup(var.file_types,local.file_suffixes[p],var.default_file_type)") }
files = notImplemented("merge(\n{\nforpinkeys(local.template_file_paths):p=>{\ncontent_type=local.file_types[p]\nsource_path=tostring(null)\ncontent=local.template_file_contents[p]\ndigests=tomap({\nmd5=md5(local.template_file_contents[p])\nsha1=sha1(local.template_file_contents[p])\nsha256=sha256(local.template_file_contents[p])\nsha512=sha512(local.template_file_contents[p])\nbase64sha256=base64sha256(local.template_file_contents[p])\nbase64sha512=base64sha512(local.template_file_contents[p])\n})\n}\n},\n{\nforpinlocal.static_file_paths:p=>{\ncontent_type=local.file_types[p]\nsource_path=local.static_file_local_paths[p]\ncontent=tostring(null)\ndigests=tomap({\nmd5=filemd5(local.static_file_local_paths[p])\nsha1=filesha1(local.static_file_local_paths[p])\nsha256=filesha256(local.static_file_local_paths[p])\nsha512=filesha512(local.static_file_local_paths[p])\nbase64sha256=filebase64sha256(local.static_file_local_paths[p])\nbase64sha512=filebase64sha512(local.static_file_local_paths[p])\n})\n}\n},\n)")
myFileTypes = { for p in outputFilePaths : p => invoke("std:index:lookup", {
map = fileTypes
key = fileSuffixes[p]
default = defaultFileType
}).result }
files = notImplemented("merge(\n{\nforpinkeys(local.template_file_paths):p=>{\ncontent_type=local.file_types[p]\nsource_path=tostring(null)\ncontent=local.template_file_contents[p]\ndigests=tomap({\nmd5=md5(local.template_file_contents[p])\nsha1=sha1(local.template_file_contents[p])\nsha256=sha256(local.template_file_contents[p])\nsha512=sha512(local.template_file_contents[p])\nbase64sha256=base64sha256(local.template_file_contents[p])\nbase64sha512=base64sha512(local.template_file_contents[p])\n})\n}\n},\n{\nforpinlocal.static_file_paths:p=>{\ncontent_type=local.file_types[p]\nsource_path=local.static_file_local_paths[p]\ncontent=tostring(null)\ndigests=tomap({\nmd5=filemd5(local.static_file_local_paths[p])\nsha1=filesha1(local.static_file_local_paths[p])\nsha256=filesha256(local.static_file_local_paths[p])\nsha512=filesha512(local.static_file_local_paths[p])\nbase64sha256=filebase64sha256(local.static_file_local_paths[p])\nbase64sha512=filebase64sha512(local.static_file_local_paths[p])\n})\n}\n},\n)")
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@
outputFilePaths = notImplemented("setunion(keys(local.template_file_paths),local.static_file_paths)")
fileSuffixMatches = { for p in outputFilePaths : p => notImplemented("regexall(\"\\\\.[^\\\\.]+\\\\z\",p)") }
fileSuffixes = { for p, ms in fileSuffixMatches : p => length(ms) > 0 ? ms[0] : "" }
myFileTypes = { for p in outputFilePaths : p => notImplemented("lookup(var.file_types,local.file_suffixes[p],var.default_file_type)") }
files = notImplemented("merge(\n{\nforpinkeys(local.template_file_paths):p=>{\ncontent_type=local.file_types[p]\nsource_path=tostring(null)\ncontent=local.template_file_contents[p]\ndigests=tomap({\nmd5=md5(local.template_file_contents[p])\nsha1=sha1(local.template_file_contents[p])\nsha256=sha256(local.template_file_contents[p])\nsha512=sha512(local.template_file_contents[p])\nbase64sha256=base64sha256(local.template_file_contents[p])\nbase64sha512=base64sha512(local.template_file_contents[p])\n})\n}\n},\n{\nforpinlocal.static_file_paths:p=>{\ncontent_type=local.file_types[p]\nsource_path=local.static_file_local_paths[p]\ncontent=tostring(null)\ndigests=tomap({\nmd5=filemd5(local.static_file_local_paths[p])\nsha1=filesha1(local.static_file_local_paths[p])\nsha256=filesha256(local.static_file_local_paths[p])\nsha512=filesha512(local.static_file_local_paths[p])\nbase64sha256=filebase64sha256(local.static_file_local_paths[p])\nbase64sha512=filebase64sha512(local.static_file_local_paths[p])\n})\n}\n},\n)")
myFileTypes = { for p in outputFilePaths : p => invoke("std:index:lookup", {
map = fileTypes
key = fileSuffixes[p]
default = defaultFileType
}).result }
files = notImplemented("merge(\n{\nforpinkeys(local.template_file_paths):p=>{\ncontent_type=local.file_types[p]\nsource_path=tostring(null)\ncontent=local.template_file_contents[p]\ndigests=tomap({\nmd5=md5(local.template_file_contents[p])\nsha1=sha1(local.template_file_contents[p])\nsha256=sha256(local.template_file_contents[p])\nsha512=sha512(local.template_file_contents[p])\nbase64sha256=base64sha256(local.template_file_contents[p])\nbase64sha512=base64sha512(local.template_file_contents[p])\n})\n}\n},\n{\nforpinlocal.static_file_paths:p=>{\ncontent_type=local.file_types[p]\nsource_path=local.static_file_local_paths[p]\ncontent=tostring(null)\ndigests=tomap({\nmd5=filemd5(local.static_file_local_paths[p])\nsha1=filesha1(local.static_file_local_paths[p])\nsha256=filesha256(local.static_file_local_paths[p])\nsha512=filesha512(local.static_file_local_paths[p])\nbase64sha256=filebase64sha256(local.static_file_local_paths[p])\nbase64sha512=filebase64sha512(local.static_file_local_paths[p])\n})\n}\n},\n)")
6 changes: 5 additions & 1 deletion pkg/convert/tf.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@ var tfFunctionStd = map[string]struct {
inputs: []string{"base", "input"},
output: "result",
},
"lookup": {
token: "std:index:lookup",
inputs: []string{"map", "key", "default"},
output: "result",
},
"lower": {
token: "std:index:lower",
inputs: []string{"input"},
Expand Down Expand Up @@ -3585,7 +3590,6 @@ var unimplementedFunctionBugs = map[string]string{
"flatten": "pulumi/pulumi-converter-terraform#138",
"format": "pulumi/pulumi-converter-terraform#65",
"formatdate": "pulumi/pulumi-converter-terraform#196",
"lookup": "pulumi/pulumi-converter-terraform#65",
"merge": "pulumi/pulumi-converter-terraform#65",
"regexall": "pulumi/pulumi-converter-terraform#191",
"slice": "pulumi/pulumi-converter-terraform#65",
Expand Down

0 comments on commit 92270eb

Please sign in to comment.