Skip to content

Commit 53a68cd

Browse files
authored
feat: add the option to debug the coder terraform provider (#378)
Setting the debug flag runs the provider as a standalone process and provides an environment variable that can be set for Terraform to use it. One can then attach a debugger to the provider process.
1 parent d90c181 commit 53a68cd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

main.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"flag"
5+
46
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
57

68
"github.com/coder/terraform-provider-coder/v2/provider"
@@ -11,8 +13,15 @@ import (
1113
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
1214

1315
func main() {
14-
servePprof()
15-
plugin.Serve(&plugin.ServeOpts{
16+
debug := flag.Bool("debug", false, "Enable debug mode for the provider")
17+
flag.Parse()
18+
19+
opts := &plugin.ServeOpts{
20+
Debug: *debug,
21+
ProviderAddr: "registry.terraform.io/coder/coder",
1622
ProviderFunc: provider.New,
17-
})
23+
}
24+
25+
servePprof()
26+
plugin.Serve(opts)
1827
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy