From f52ffe6e12f250c042279f5bcae835f5b9a23719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Nie=C3=9F?= Date: Sun, 4 Sep 2022 13:55:36 +0200 Subject: [PATCH] feat: Add debug option to main() --- .../netbox_ipam_ip_addresses/resource.tf | 1 + main.go | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/resources/netbox_ipam_ip_addresses/resource.tf b/examples/resources/netbox_ipam_ip_addresses/resource.tf index 430447ba9..74071cfdc 100644 --- a/examples/resources/netbox_ipam_ip_addresses/resource.tf +++ b/examples/resources/netbox_ipam_ip_addresses/resource.tf @@ -49,3 +49,4 @@ resource "netbox_ipam_ip_addresses" "ip_test" { type = "multiple" value = "0,1" } +} diff --git a/main.go b/main.go index ebf1281f9..d045e22f8 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,8 @@ package main import ( - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "flag" + "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" "github.com/smutel/terraform-provider-netbox/v4/netbox" ) @@ -13,11 +14,16 @@ import ( //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs func main() { - opts := &plugin.ServeOpts{ - ProviderFunc: func() *schema.Provider { - return netbox.Provider() - }, - } + var debug bool + + flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") + flag.Parse() + + opts := &plugin.ServeOpts{ + Debug: debug, + ProviderAddr: "registry.terraform.io/smutel/netbox", + ProviderFunc: netbox.Provider, + } - plugin.Serve(opts) + plugin.Serve(opts) }