forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9db46dc
commit ecbab2b
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/provider" | ||
) | ||
|
||
func main() { | ||
// remove date and time stamp from log output as the plugin SDK already adds its own | ||
log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime)) | ||
|
||
opts := &plugin.ServeOpts{ | ||
Debug: true, | ||
ProviderFunc: provider.AzureProvider, | ||
ProviderAddr: "snyk/azurerm", | ||
} | ||
plugin.Serve(opts) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Debug | ||
|
||
To debug the provider | ||
## VSCODE | ||
|
||
create debug config: | ||
|
||
|
||
```json | ||
{ | ||
"name": "Remote", | ||
"type": "go", | ||
"request": "attach", | ||
"mode": "remote", | ||
"remotePath": "${workspaceFolder}", | ||
"port": 8888, | ||
"host": "127.0.0.1" | ||
} | ||
``` | ||
|
||
## Terminal 1 | ||
|
||
Compile the provider in debug mode | ||
|
||
```sh | ||
go build -gcflags="all=-N -l" ./cmd/debug | ||
``` | ||
|
||
Launch `dlv` as: | ||
|
||
```sh | ||
dlv exec --listen=:8888 --headless --api-version=2 ./debug -- -debug | ||
``` | ||
|
||
# VSCODE | ||
|
||
Attach vs code to the debug session. | ||
|
||
# Terminal 2 | ||
|
||
export the CLI config with: | ||
|
||
``` | ||
provider_installation { | ||
dev_overrides { | ||
"snyk/azurerm" = "/Users/ricardol/git/terraform-provider-azurerm/debug" | ||
} | ||
} | ||
``` | ||
|
||
TODO: this is not still working!!!! | ||
|
||
|
||
```sh | ||
export TF_CLI_CONFIG_FILE=/Users/ricardol/git/terraform-provider-azurerm/tmp/ex1/terraformrc | ||
export TF_REATTACH_PROVIDERS=.... | ||
``` |