Skip to content

Commit

Permalink
Adding some bug context to error output messaging. (#193)
Browse files Browse the repository at this point in the history
Related Bugs: #16 #65 #138 #190 #191 #192
  • Loading branch information
brandonpollack23 authored Oct 4, 2024
1 parent aec634e commit ce9fd09
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 178 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Improvements

- Added references to issues for missing functions in output.

### Bug Fixes

- Fix errors being encountered but not reported to the user
Expand Down
286 changes: 143 additions & 143 deletions pkg/convert/testdata/programs/builtin_functions/pcl/diagnostics.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
"warning:/main.tf:2,19-80:Function not yet implemented:Function cidrsubnets not yet implemented",
"warning:/main.tf:7,59-73:Function not yet implemented:Function tostring not yet implemented",
"warning:/outputs.tf:2,17-43:Function not yet implemented:Function tomap not yet implemented"
"warning:/main.tf:2,19-80:Function not yet implemented:Function cidrsubnets not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/main.tf:7,59-73:Function not yet implemented:Function tostring not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/outputs.tf:2,17-43:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)"
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
"warning:/main.tf:2,19-80:Function not yet implemented:Function cidrsubnets not yet implemented",
"warning:/main.tf:7,59-73:Function not yet implemented:Function tostring not yet implemented",
"warning:/outputs.tf:2,17-43:Function not yet implemented:Function tomap not yet implemented"
"warning:/main.tf:2,19-80:Function not yet implemented:Function cidrsubnets not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/main.tf:7,59-73:Function not yet implemented:Function tostring not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/outputs.tf:2,17-43:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)"
]
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
[
"warning:/files.tf:2,20-47:Function not yet implemented:Function fileset not yet implemented",
"warning:/files.tf:3,23-6,5:Function not yet implemented:Function toset not yet implemented",
"warning:/files.tf:10,10-46:Function not yet implemented:Function contains not yet implemented",
"warning:/files.tf:14,51-107:Function not yet implemented:Function templatefile not yet implemented",
"warning:/files.tf:20,32-63:Function not yet implemented:Function keys not yet implemented",
"warning:/files.tf:20,23-89:Function not yet implemented:Function setunion not yet implemented",
"warning:/files.tf:23,45-73:Function not yet implemented:Function regexall not yet implemented",
"warning:/files.tf:29,45-114:Function not yet implemented:Function lookup not yet implemented",
"warning:/files.tf:34,16-47:Function not yet implemented:Function keys not yet implemented",
"warning:/files.tf:36,24-38:Function not yet implemented:Function tostring not yet implemented",
"warning:/files.tf:38,19-45,11:Function not yet implemented:Function tomap not yet implemented",
"warning:/files.tf:52,24-38:Function not yet implemented:Function tostring not yet implemented",
"warning:/files.tf:53,19-60,11:Function not yet implemented:Function tomap not yet implemented",
"warning:/files.tf:32,11-63,4:Function not yet implemented:Function merge not yet implemented",
"warning:/files.tf:2,20-47:Function not yet implemented:Function fileset not yet implemented",
"warning:/files.tf:3,23-6,5:Function not yet implemented:Function toset not yet implemented",
"warning:/files.tf:10,10-46:Function not yet implemented:Function contains not yet implemented",
"warning:/files.tf:14,51-107:Function not yet implemented:Function templatefile not yet implemented",
"warning:/files.tf:20,32-63:Function not yet implemented:Function keys not yet implemented",
"warning:/files.tf:20,23-89:Function not yet implemented:Function setunion not yet implemented",
"warning:/files.tf:23,45-73:Function not yet implemented:Function regexall not yet implemented",
"warning:/files.tf:29,45-114:Function not yet implemented:Function lookup not yet implemented",
"warning:/files.tf:34,16-47:Function not yet implemented:Function keys not yet implemented",
"warning:/files.tf:36,24-38:Function not yet implemented:Function tostring not yet implemented",
"warning:/files.tf:38,19-45,11:Function not yet implemented:Function tomap not yet implemented",
"warning:/files.tf:52,24-38:Function not yet implemented:Function tostring not yet implemented",
"warning:/files.tf:53,19-60,11:Function not yet implemented:Function tomap not yet implemented",
"warning:/files.tf:32,11-63,4:Function not yet implemented:Function merge not yet implemented"
"warning:/files.tf:2,20-47:Function not yet implemented:Function fileset not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:3,23-6,5:Function not yet implemented:Function toset not yet implemented, see pulumi/pulumi-converter-terraform#137",
"warning:/files.tf:10,10-46:Function not yet implemented:Function contains not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:14,51-107:Function not yet implemented:Function templatefile not yet implemented, see pulumi/pulumi-converter-terraform#192",
"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)",
"warning:/files.tf:52,24-38:Function not yet implemented:Function tostring not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:53,19-60,11:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:32,11-63,4:Function not yet implemented:Function merge not yet implemented, see pulumi/pulumi-converter-terraform#65",
"warning:/files.tf:2,20-47:Function not yet implemented:Function fileset not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:3,23-6,5:Function not yet implemented:Function toset not yet implemented, see pulumi/pulumi-converter-terraform#137",
"warning:/files.tf:10,10-46:Function not yet implemented:Function contains not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:14,51-107:Function not yet implemented:Function templatefile not yet implemented, see pulumi/pulumi-converter-terraform#192",
"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)",
"warning:/files.tf:52,24-38:Function not yet implemented:Function tostring not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:53,19-60,11:Function not yet implemented:Function tomap not yet implemented, see pulumi/pulumi-converter-terraform#65 (catch all bug)",
"warning:/files.tf:32,11-63,4:Function not yet implemented:Function merge not yet implemented, see pulumi/pulumi-converter-terraform#65"
]
6 changes: 6 additions & 0 deletions pkg/convert/testdata/states/count/import.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
"Type": "simple:index:resource",
"Name": "a_resource-0",
"ID": "abc123",
"LogicalName": "",
"IsComponent": false,
"IsRemote": false,
"Version": "",
"PluginDownloadURL": ""
},
{
"Type": "simple:index:resource",
"Name": "a_resource-1",
"ID": "def456",
"LogicalName": "",
"IsComponent": false,
"IsRemote": false,
"Version": "",
"PluginDownloadURL": ""
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/convert/testdata/states/range/import.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
"Type": "simple:index:resource",
"Name": "a_resource-hello",
"ID": "abc123",
"LogicalName": "",
"IsComponent": false,
"IsRemote": false,
"Version": "",
"PluginDownloadURL": ""
},
{
"Type": "simple:index:resource",
"Name": "a_resource-goodbye",
"ID": "def456",
"LogicalName": "",
"IsComponent": false,
"IsRemote": false,
"Version": "",
"PluginDownloadURL": ""
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/convert/testdata/states/simple/import.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"Type": "simple:index:resource",
"Name": "a_resource",
"ID": "abc123",
"LogicalName": "",
"IsComponent": false,
"IsRemote": false,
"Version": "",
"PluginDownloadURL": ""
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/convert/testdata/states/unknown/import.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"Type": "unknown:index:resource",
"Name": "a_resource",
"ID": "abc123",
"LogicalName": "",
"IsComponent": false,
"IsRemote": false,
"Version": "",
"PluginDownloadURL": ""
}
Expand Down
29 changes: 28 additions & 1 deletion pkg/convert/tf.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ func convertFunctionCallExpr(state *convertState,
Subject: &callRange,
Severity: hcl.DiagWarning,
Summary: "Function not yet implemented",
Detail: fmt.Sprintf("Function %s not yet implemented", call.Name),
Detail: fmt.Sprintf("Function %s not yet implemented, see %s", call.Name, getTrackingBug(call)),
})

return notImplemented(state, call.Range())
Expand Down Expand Up @@ -3239,3 +3239,30 @@ func componentProgramBinderFromAfero(fs afero.Fs) pcl.ComponentProgramBinder {
return componentProgram, programDiags, err
}
}

var unimplementedFunctionBugs = map[string]string{
"coalesce": "pulumi/pulumi-converter-terraform#65",
"coalescelist": "pulumi/pulumi-converter-terraform#65",
"compact": "pulumi/pulumi-converter-terraform#65",
"distinct": "pulumi/pulumi-converter-terraform#65",
"flatten": "pulumi/pulumi-converter-terraform#138",
"format": "pulumi/pulumi-converter-terraform#65",
"lookup": "pulumi/pulumi-converter-terraform#65",
"merge": "pulumi/pulumi-converter-terraform#65",
"regexall": "pulumi/pulumi-converter-terraform#191",
"slice": "pulumi/pulumi-converter-terraform#65",
"templatefile": "pulumi/pulumi-converter-terraform#192",
"toset": "pulumi/pulumi-converter-terraform#137",
"try": "pulumi/pulumi-converter-terraform#16",
"yamlencode": "pulumi/pulumi-converter-terraform#190",
}

// getTrackingBug returns the tracking bug for the given function call, if any.
func getTrackingBug(call *hclsyntax.FunctionCallExpr) string {
r, ok := unimplementedFunctionBugs[call.Name]
if !ok {
return "pulumi/pulumi-converter-terraform#65 (catch all bug)"
}

return r
}

0 comments on commit ce9fd09

Please sign in to comment.