Skip to content

Commit b238617

Browse files
authored
Add debugger mode for the binary (#1019)
You can [run provider in a debug mode](https://www.terraform.io/plugin/sdkv2/debugging#running-terraform-with-a-provider-in-debug-mode) from VScode IDE by launching `Debug Provider` run configuration and invoking `terraform apply` with `TF_REATTACH_PROVIDERS` environment variable.
1 parent 0fb323d commit b238617

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

.vscode/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "Debug Provider",
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "debug",
12+
"program": "main.go",
13+
"args": ["debug"],
14+
},
715
{
816
"name": "Launch test function",
917
"type": "go",

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Version changelog
22

3+
## 0.4.4
4+
5+
* Added support for [running provider in a debug mode](https://www.terraform.io/plugin/sdkv2/debugging#running-terraform-with-a-provider-in-debug-mode) from Visual Studio Code through `Debug Provider` run configuration in order to troubleshoot more complicated issues.
6+
37
## 0.4.3
48

59
* Added support for `databricks_permissions` for `databricks_mlflow_experiment` and `databricks_mlflow_model` ([#1013](https://github.com/databrickslabs/terraform-provider-databricks/pull/1013)).

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ After this, you should be able to run `make coverage` to run the tests and see t
6969

7070
## Debugging
7171

72-
**TF_LOG=DEBUG terraform apply** allows you to see the internal logs from `terraform apply`.
72+
**TF_LOG_PROVIDER=DEBUG terraform apply** allows you to see the internal logs from `terraform apply`.
73+
74+
You can [run provider in a debug mode](https://www.terraform.io/plugin/sdkv2/debugging#running-terraform-with-a-provider-in-debug-mode) from VScode IDE by launching `Debug Provider` run configuration and invoking `terraform apply` with `TF_REATTACH_PROVIDERS` environment variable.
7375

7476
## Adding a new resource
7577

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"fmt"
56
"log"
67
"os"
@@ -24,6 +25,14 @@ func main() {
2425
}
2526
return
2627
}
28+
if len(os.Args) > 1 && os.Args[1] == "debug" {
29+
err := plugin.Debug(context.Background(), "registry.terraform.io/databrickslabs/databricks",
30+
&plugin.ServeOpts{ProviderFunc: provider.DatabricksProvider})
31+
if err != nil {
32+
log.Fatal(err.Error())
33+
}
34+
return
35+
}
2736
log.Printf(`Databricks Terraform Provider (experimental)
2837
2938
Version %s

0 commit comments

Comments
 (0)